Class: SendWithUsMailer::MailParams
- Inherits:
-
Object
- Object
- SendWithUsMailer::MailParams
- Defined in:
- lib/sendwithus_ruby_action_mailer/mail_params.rb
Instance Attribute Summary collapse
-
#email_data ⇒ Object
readonly
Returns the value of attribute email_data.
-
#email_id ⇒ Object
readonly
Returns the value of attribute email_id.
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
Instance Method Summary collapse
-
#assign(key, value) ⇒ Object
:nodoc:.
-
#deliver ⇒ Object
(also: #deliver_now)
Invoke
SendWithUs::Api
to deliver the message. -
#deliver_later ⇒ Object
Invoke
SendWithUs::Api
to deliver the message later via ActiveJob. -
#initialize ⇒ MailParams
constructor
:nodoc:.
-
#merge!(params = {}) ⇒ Object
:nodoc:.
Constructor Details
#initialize ⇒ MailParams
:nodoc:
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/sendwithus_ruby_action_mailer/mail_params.rb', line 7 def initialize #:nodoc: @email_data = {} @to = {} @from = {} @cc = [] @bcc = [] @version_name = "" @locale = "" @files = [] @headers = {} = [] @esp_account = "" end |
Instance Attribute Details
#email_data ⇒ Object (readonly)
Returns the value of attribute email_data.
5 6 7 |
# File 'lib/sendwithus_ruby_action_mailer/mail_params.rb', line 5 def email_data @email_data end |
#email_id ⇒ Object (readonly)
Returns the value of attribute email_id.
5 6 7 |
# File 'lib/sendwithus_ruby_action_mailer/mail_params.rb', line 5 def email_id @email_id end |
#from ⇒ Object (readonly)
Returns the value of attribute from.
5 6 7 |
# File 'lib/sendwithus_ruby_action_mailer/mail_params.rb', line 5 def from @from end |
#to ⇒ Object (readonly)
Returns the value of attribute to.
5 6 7 |
# File 'lib/sendwithus_ruby_action_mailer/mail_params.rb', line 5 def to @to end |
Instance Method Details
#assign(key, value) ⇒ Object
:nodoc:
21 22 23 |
# File 'lib/sendwithus_ruby_action_mailer/mail_params.rb', line 21 def assign(key, value) #:nodoc: @email_data.merge!( key.to_sym => value ) end |
#deliver ⇒ Object Also known as: deliver_now
Invoke SendWithUs::Api
to deliver the message. The SendWithUs
module is implemented in the send_with_us
gem.
IMPORTANT NOTE: SendWithUs
must be configured prior to calling this method. In particular, the api_key
must be set (following the guidelines in the send_with_us
documentation).
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/sendwithus_ruby_action_mailer/mail_params.rb', line 66 def deliver SendWithUs::Api.new.send_email( @email_id, @to, data: @email_data, from: @from, cc: @cc, bcc: @bcc, esp_account: @esp_account, version_name: @version_name, locale: @locale, files: @files, headers: @headers, tags: ) if @email_id.present? end |
#deliver_later ⇒ Object
Invoke SendWithUs::Api
to deliver the message later via ActiveJob. The SendWithUs
module is implemented in the send_with_us
gem.
IMPORTANT NOTE: SendWithUs
must be configured prior to calling this method. In particular, the api_key
must be set (following the guidelines in the send_with_us
documentation).
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/sendwithus_ruby_action_mailer/mail_params.rb', line 91 def deliver_later Jobs::MailJob.perform_later( @email_id, @to, data: @email_data, from: @from, cc: @cc, bcc: @bcc, esp_account: @esp_account, version_name: @version_name, locale: @locale, files: @files, headers: @headers, tags: ) if @email_id.present? end |
#merge!(params = {}) ⇒ Object
:nodoc:
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/sendwithus_ruby_action_mailer/mail_params.rb', line 25 def merge!(params={}) #:nodoc: params.each_pair do |key, value| case key when :email_id @email_id = value when :recipient_name @to.merge!(name: value) when :recipient_address @to.merge!(address: value) when :from_name @from.merge!(name: value) when :from_address @from.merge!(address: value) when :reply_to @from.merge!(reply_to: value) when :cc @cc.concat(value) when :bcc @bcc.concat(value) when :version_name @version_name = value when :locale @locale = value when :files @files.concat(value) when :headers @headers.merge!(value) when :tags .concat(value) when :esp_account @esp_account = value end end end |