Sha256: 25881f7d2a9e847da136b13aa2280050416e9f51fcf7be1d5046a14157aa76f8

Contents?: true

Size: 691 Bytes

Versions: 26

Compression:

Stored size: 691 Bytes

Contents

module Mail
  class Postmark

    attr_accessor :settings

    def initialize(values)
      self.settings = { :api_token => ENV['POSTMARK_API_TOKEN'] }.merge(values)
    end

    def deliver!(mail)
      response = if mail.templated?
                   api_client.deliver_message_with_template(mail)
                 else
                   api_client.deliver_message(mail)
                 end

      if settings[:return_response]
        response
      else
        self
      end
    end

    def api_client
      settings = self.settings.dup
      api_token = settings.delete(:api_token) || settings.delete(:api_key)
      ::Postmark::ApiClient.new(api_token, settings)
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
postmark-1.25.1 lib/postmark/handlers/mail.rb
postmark-1.25.0 lib/postmark/handlers/mail.rb
postmark-1.24.1 lib/postmark/handlers/mail.rb
postmark-1.24.0 lib/postmark/handlers/mail.rb
postmark-1.23.0 lib/postmark/handlers/mail.rb
postmark-1.22.3 lib/postmark/handlers/mail.rb
postmark-1.22.2 lib/postmark/handlers/mail.rb
postmark-1.22.1 lib/postmark/handlers/mail.rb
postmark-1.22.0 lib/postmark/handlers/mail.rb
postmark-1.21.8 lib/postmark/handlers/mail.rb
postmark-1.21.7 lib/postmark/handlers/mail.rb
postmark-1.21.6 lib/postmark/handlers/mail.rb
postmark-1.21.5 lib/postmark/handlers/mail.rb
postmark-1.21.4 lib/postmark/handlers/mail.rb
postmark-1.21.3 lib/postmark/handlers/mail.rb
postmark-1.21.2 lib/postmark/handlers/mail.rb
postmark-1.21.1 lib/postmark/handlers/mail.rb
postmark-1.21.0 lib/postmark/handlers/mail.rb
postmark-1.20.0 lib/postmark/handlers/mail.rb
postmark-1.19.2 lib/postmark/handlers/mail.rb