Class: Mailkick::Service::AwsSes

Inherits:
Mailkick::Service show all
Defined in:
lib/mailkick/service/aws_ses.rb

Constant Summary collapse

REASONS_MAP =
{
  "BOUNCE" => "bounce",
  "COMPLAINT" => "spam"
}

Constants inherited from Mailkick::Service

SendGridV2

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Mailkick::Service

#fetch_opt_outs

Constructor Details

#initializeAwsSes

Returns a new instance of AwsSes.



11
12
# File 'lib/mailkick/service/aws_ses.rb', line 11

def initialize
end

Class Method Details

.discoverable?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/mailkick/service/aws_ses.rb', line 35

def self.discoverable?
  !!defined?(::Aws::SESV2::Client)
end

Instance Method Details

#opt_outsObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/mailkick/service/aws_ses.rb', line 14

def opt_outs
  response = client.list_suppressed_destinations({
    reasons: ["BOUNCE", "COMPLAINT"],
    # TODO make configurable
    start_date: Time.now - (86400 * 365),
    end_date: Time.now
  })

  opt_outs = []
  response.each do |page|
    page.suppressed_destination_summaries.each do |record|
      opt_outs << {
        email: record.email_address,
        time: record.last_update_time,
        reason: REASONS_MAP[record.reason]
      }
    end
  end
  opt_outs
end