Sha256: 2c878299014eed8867a9c89c853e546ff752fbbf2b1f5c060d67d42070184c7b

Contents?: true

Size: 573 Bytes

Versions: 3

Compression:

Stored size: 573 Bytes

Contents

module Mail
  class SimplePostmark < Struct.new(:settings)
    include HTTParty

    base_uri 'http://api.postmarkapp.com'
    headers 'Accept' => 'application/json', 'ContentType' => 'application/json'
    delegate :post, :headers, to: self

    def deliver!(mail)
      headers = self.headers.merge('X-Postmark-Server-Token' => settings[:api_key].to_s)
      body = mail.to_postmark.to_json
      
      response = post('/email', headers: headers, body: body)
      raise ::SimplePostmark::APIError.new(response) unless response.success?
      response
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
simple_postmark-0.7.0 lib/simple_postmark/delivery_method.rb
simple_postmark-0.6.0 lib/simple_postmark/delivery_method.rb
simple_postmark-0.5.2 lib/simple_postmark/delivery_method.rb