class Notifiable::Email::Ses::Sender

Protected Instance Methods

enqueue(device, notification) click to toggle source
# File lib/notifiable/email/ses/sender.rb, line 14
                def enqueue(device, notification)                                  
  raise "access_id missing" if @access_id.nil?
  raise "secret_key missing" if @secret_key.nil?

  sender = 'info@futureworkshops.com'
  recipient = device.token
  htmlbody = "<p>#{notification.message}</p>"
  textbody = notification.message
  encoding = 'UTF-8'

  client.send_email(
    destination: {
      to_addresses: [
        recipient
      ]
    },
    message: {
      body: {
        html: {
          charset: encoding,
          data: htmlbody
        },
        text: {
          charset: encoding,
          data: textbody
        }
      },
      subject: {
        charset: encoding,
        data: notification.title
      }
    },
    source: sender,
  )

  processed(device)
  
rescue Aws::SES::Errors::ServiceError => error
  processed(device, NotificationStatus::REJECTED_STATUS, nil, error.message)
                end

Private Instance Methods

client() click to toggle source
# File lib/notifiable/email/ses/sender.rb, line 56
def client
  @client ||= Aws::SES::Client.new(region: 'us-east-1', access_key_id: @access_id, secret_access_key: @secret_key)
end