Class: Spree::SendWithUs::Message
- Inherits:
-
Object
- Object
- Spree::SendWithUs::Message
- Defined in:
- lib/spree_sendwithus/message.rb
Instance Attribute Summary collapse
-
#bcc ⇒ Object
readonly
Returns the value of attribute bcc.
-
#cc ⇒ Object
readonly
Returns the value of attribute cc.
-
#email_data ⇒ Object
readonly
Returns the value of attribute email_data.
-
#email_id ⇒ Object
readonly
Returns the value of attribute email_id.
-
#esp_account ⇒ Object
readonly
Returns the value of attribute esp_account.
-
#files ⇒ Object
readonly
Returns the value of attribute files.
-
#from ⇒ Object
readonly
Returns the value of attribute from.
-
#locale ⇒ Object
readonly
Returns the value of attribute locale.
-
#tags ⇒ Object
readonly
Returns the value of attribute tags.
-
#to ⇒ Object
readonly
Returns the value of attribute to.
Instance Method Summary collapse
- #assign(key, value) ⇒ Object
- #deliver ⇒ Object
-
#initialize ⇒ Message
constructor
A new instance of Message.
- #merge!(params = {}) ⇒ Object
Constructor Details
#initialize ⇒ Message
Returns a new instance of Message.
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/spree_sendwithus/message.rb', line 9 def initialize @email_data = {} @to = {} @from = {} @cc = [] @bcc = [] @files = [] @esp_account = Base.esp_account || "" = [] @locale = I18n.default_locale.to_s end |
Instance Attribute Details
#bcc ⇒ Object (readonly)
Returns the value of attribute bcc.
6 7 8 |
# File 'lib/spree_sendwithus/message.rb', line 6 def bcc @bcc end |
#cc ⇒ Object (readonly)
Returns the value of attribute cc.
6 7 8 |
# File 'lib/spree_sendwithus/message.rb', line 6 def cc @cc end |
#email_data ⇒ Object (readonly)
Returns the value of attribute email_data.
6 7 8 |
# File 'lib/spree_sendwithus/message.rb', line 6 def email_data @email_data end |
#email_id ⇒ Object (readonly)
Returns the value of attribute email_id.
6 7 8 |
# File 'lib/spree_sendwithus/message.rb', line 6 def email_id @email_id end |
#esp_account ⇒ Object (readonly)
Returns the value of attribute esp_account.
6 7 8 |
# File 'lib/spree_sendwithus/message.rb', line 6 def esp_account @esp_account end |
#files ⇒ Object (readonly)
Returns the value of attribute files.
6 7 8 |
# File 'lib/spree_sendwithus/message.rb', line 6 def files @files end |
#from ⇒ Object (readonly)
Returns the value of attribute from.
6 7 8 |
# File 'lib/spree_sendwithus/message.rb', line 6 def from @from end |
#locale ⇒ Object (readonly)
Returns the value of attribute locale.
6 7 8 |
# File 'lib/spree_sendwithus/message.rb', line 6 def locale @locale end |
#tags ⇒ Object (readonly)
Returns the value of attribute tags.
6 7 8 |
# File 'lib/spree_sendwithus/message.rb', line 6 def end |
#to ⇒ Object (readonly)
Returns the value of attribute to.
6 7 8 |
# File 'lib/spree_sendwithus/message.rb', line 6 def to @to end |
Instance Method Details
#assign(key, value) ⇒ Object
21 22 23 |
# File 'lib/spree_sendwithus/message.rb', line 21 def assign(key, value) @email_data.merge!(key.to_sym => value) end |
#deliver ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/spree_sendwithus/message.rb', line 56 def deliver ::SendWithUs::Api.new.send_email( @email_id, @to, { data: @email_data, from: @from, cc: @cc, bcc: @bcc, esp_account: @esp_account, files: @files, tags: , locale: @locale } ) end |
#merge!(params = {}) ⇒ Object
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 |
# File 'lib/spree_sendwithus/message.rb', line 25 def merge!(params = {}) 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 :files @files.concat(value) when :esp_account @esp_account = value when :tags = value when :locale @locale = value end end end |