Sha256: 2afa32abc2421f5387872352f8ac00c89ea123ef241d9130faa9dc725062994b
Contents?: true
Size: 1.07 KB
Versions: 7
Compression:
Stored size: 1.07 KB
Contents
# https://github.com/freerobby/sendgrid_toolkit module Mailkick class Service class Sendgrid < Mailkick::Service def initialize(options = {}) @api_user = options[:api_user] || ENV["SENDGRID_USERNAME"] @api_key = options[:api_key] || ENV["SENDGRID_PASSWORD"] end # TODO paginate def opt_outs unsubscribes + spam_reports + bounces end def unsubscribes fetch(::SendgridToolkit::Unsubscribes, "unsubscribe") end def spam_reports fetch(::SendgridToolkit::SpamReports, "spam") end def bounces fetch(::SendgridToolkit::Bounces, "bounce") end def self.discoverable? !!(defined?(::SendgridToolkit) && ENV["SENDGRID_USERNAME"] && ENV["SENDGRID_PASSWORD"]) end protected def fetch(klass, reason) klass.new(@api_user, @api_key).retrieve_with_timestamps.map do |record| { email: record["email"], time: record["created"], reason: reason } end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems