class Mailkick::Service::Postmark

Constants

REASONS_MAP

Public Class Methods

discoverable?() click to toggle source
# File lib/mailkick/service/postmark.rb, line 24
def self.discoverable?
  !!(defined?(::Postmark) && ENV["POSTMARK_API_KEY"])
end
new(options = {}) click to toggle source
# File lib/mailkick/service/postmark.rb, line 12
def initialize(options = {})
  @client = ::Postmark::ApiClient.new(options[:api_key] || ENV["POSTMARK_API_KEY"])
end

Public Instance Methods

bounces() click to toggle source
# File lib/mailkick/service/postmark.rb, line 20
def bounces
  fetch(@client.bounces)
end
opt_outs() click to toggle source
# File lib/mailkick/service/postmark.rb, line 16
def opt_outs
  bounces
end

Protected Instance Methods

fetch(response) click to toggle source
# File lib/mailkick/service/postmark.rb, line 30
def fetch(response)
  response.map do |record|
    {
      email: record[:email],
      time: ActiveSupport::TimeZone["UTC"].parse(record[:bounced_at]),
      reason: REASONS_MAP.fetch(record[:type], "bounce")
    }
  end
end