Module: SesConfiguration

Extended by:
ActiveSupport::Concern
Defined in:
lib/app/models/concerns/ses_configuration.rb

Overview

AWS SES SSO Configuration

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



9
10
11
12
13
14
15
16
17
18
# File 'lib/app/models/concerns/ses_configuration.rb', line 9

def self.included(base)
  base.class_eval do
    #
    # Fields
    #
    field :ses_source_arn_prefix, type: String
    field :ses_bounce_queue_name, type: String
    field :ses_region, type: String
  end
end

Instance Method Details

#aws_ses_clientObject

SES Client



36
37
38
39
40
41
42
# File 'lib/app/models/concerns/ses_configuration.rb', line 36

def aws_ses_client
  return nil unless ses_configured?

  # We want this to remake itself each time because it is possible that the
  # => user would change the access keys in between actions. Huh?
  @aws_ses_client ||= Aws::SES::Client.new(region: ses_region.presence || aws_region, credentials: aws_credentials)
end

#ses_configured?Boolean

Determine if AWS is configured

Returns:

  • (Boolean)


23
24
25
26
27
# File 'lib/app/models/concerns/ses_configuration.rb', line 23

def ses_configured?
  aws_configured? &&
    ses_source_arn_prefix.present? &&
    (ses_region.present? || aws_region.present?)
end

#ses_source_arn(source = default_email) ⇒ Object



29
30
31
# File 'lib/app/models/concerns/ses_configuration.rb', line 29

def ses_source_arn(source = default_email)
  [ses_source_arn_prefix, source].compact.join('/')
end