Sha256: e54f188a997d96b3c4d3e602a8892a1c6f287733de441d29f9a39ee799f51056

Contents?: true

Size: 1.06 KB

Versions: 11

Compression:

Stored size: 1.06 KB

Contents

# https://docs.aws.amazon.com/sdk-for-ruby/v3/api/Aws/SESV2/Client.html

module Mailkick
  class Service
    class AwsSes < Mailkick::Service
      REASONS_MAP = {
        "BOUNCE" => "bounce",
        "COMPLAINT" => "spam"
      }

      def initialize(options = {})
        @options = options
      end

      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

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

      private

      def client
        @client ||= ::Aws::SESV2::Client.new
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
mailkick-1.3.1 lib/mailkick/service/aws_ses.rb
mailkick-1.3.0 lib/mailkick/service/aws_ses.rb
mailkick-1.2.2 lib/mailkick/service/aws_ses.rb
mailkick-1.2.1 lib/mailkick/service/aws_ses.rb
mailkick-1.2.0 lib/mailkick/service/aws_ses.rb
mailkick-1.1.2 lib/mailkick/service/aws_ses.rb
mailkick-1.1.1 lib/mailkick/service/aws_ses.rb
mailkick-1.1.0 lib/mailkick/service/aws_ses.rb
mailkick-1.0.1 lib/mailkick/service/aws_ses.rb
mailkick-1.0.0 lib/mailkick/service/aws_ses.rb
mailkick-0.4.3 lib/mailkick/service/aws_ses.rb