Sha256: 5bb7d32e3fa65bdacf2ff42ac616e9018a5ea0841c4c447787c0257e6e575163

Contents?: true

Size: 1 KB

Versions: 1

Compression:

Stored size: 1 KB

Contents

require 'mongoid'

module SesProxy
  class VerifiedSender
    include Mongoid::Document
    store_in collection: "verified_senders"

    field :ses_identity, type: String
    field :type, type: String
    field :created_at, type: DateTime
    field :updated_at, type: DateTime

    def self.update_identities(client)
      print "Update verified identities... "
      resp = client.list_identities
      identities = resp.data[:identities]
      resp = client.get_identity_verification_attributes :identities => identities
      VerifiedSender.delete_all
      _resp = {:emails => [], :domains => []}.with_indifferent_access
      resp[:verification_attributes].each do |identity, attributes|
        _type = identity.match('@') ? 'email' : 'domain'
        next unless attributes[:verification_status].eql? "Success"
        _resp[_type.pluralize] << VerifiedSender.create({:ses_identity => identity, :type => _type, :created_at => Time.now, :updated_at => Time.now})
      end
      _resp
      puts "OK"
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ses-proxy-0.3.2 lib/ses_proxy/models/verified_sender.rb