Class: CTT::SES
- Inherits:
-
Object
- Object
- CTT::SES
- Defined in:
- lib/ctt/ses.rb
Instance Method Summary collapse
- #call(template_name) ⇒ Object
- #create_new_template(template_name) ⇒ Object
- #delete_previous_version(template_name) ⇒ Object
-
#initialize ⇒ SES
constructor
A new instance of SES.
Constructor Details
#initialize ⇒ SES
Returns a new instance of SES.
7 8 9 10 11 12 13 |
# File 'lib/ctt/ses.rb', line 7 def initialize() @client = Aws::SES::Client.new( access_key_id: ENV['AWS_ACCESS_KEY_ID'], secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'], region: ENV['AWS_REGION'] ) end |
Instance Method Details
#call(template_name) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/ctt/ses.rb', line 15 def call(template_name) delete_previous_version(template_name) create_new_template(template_name) rescue StandardError => e puts "SES ERROR: #{e}" end |
#create_new_template(template_name) ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/ctt/ses.rb', line 29 def create_new_template(template_name) @res = @client.create_template( template: { template_name: template_name, subject_part: '{{subject}}', html_part: File.read(template_name + '.html') }, ) end |
#delete_previous_version(template_name) ⇒ Object
23 24 25 26 27 |
# File 'lib/ctt/ses.rb', line 23 def delete_previous_version(template_name) @client.delete_template( template_name: template_name ) end |