Sha256: 48bf46ec963fedfad34e1c61e26781ecb88dd16f167103e16dfb2b45554ab1b1

Contents?: true

Size: 1.03 KB

Versions: 4

Compression:

Stored size: 1.03 KB

Contents

require "aws-sdk-core"
require "aws-sdk-core/ses"

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

4 entries across 4 versions & 1 rubygems

Version Path
eye-patch-0.4.1 lib/eye/notify/awssdk.rb
eye-patch-0.4.0 lib/eye/notify/awssdk.rb
eye-patch-0.3.1 lib/eye/notify/awssdk.rb
eye-patch-0.3.0 lib/eye/notify/awssdk.rb