Sha256: 7560c4d935aad52c4c8fe186aa4219062692a6312d6a312aae42f923c128e12f

Contents?: true

Size: 1.22 KB

Versions: 1

Compression:

Stored size: 1.22 KB

Contents

require "aws-sdk-core"

begin
  # aws-sdk gem version 2.x includes the SES code as a sub-module
  require "aws-sdk-core/ses"
rescue LoadError
  # aws-sdk gem version 3.x includes the SES code as a separate aws-sdk-ses gem
  require "aws-sdk-ses"
end

module Eye
  class Notify
    class AWSSDK < Eye::Notify
      param :region, String
      param :access_key_id, String
      param :secret_access_key, String
      param :from, String, true

      def execute
        options = { region: "us-east-1" } # default to us-east-1
        options[:region] = region if region
        if access_key_id && secret_access_key
          options[:credentials] = Aws::Credentials.new(access_key_id, secret_access_key)
        end
        client = Aws::SES::Client.new(options)
        client.send_email(message)
      end

      def message
        { source: from,
          destination: {
            to_addresses: [contact]
          },
          message: {
            subject: {
              data: message_subject
            },
            body: {
              text: {
                data: message_body
              },
              html: {
                data: message_body
              }
            }
          }
        }
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
eye-patch-0.4.2 lib/eye/notify/awssdk.rb