Class: DelayedSend
- Inherits:
-
Struct
- Object
- Struct
- DelayedSend
- Defined in:
- lib/delayed_send.rb
Instance Attribute Summary collapse
-
#email ⇒ Object
Returns the value of attribute email.
-
#html_view ⇒ Object
Returns the value of attribute html_view.
-
#message_name ⇒ Object
Returns the value of attribute message_name.
-
#order_id ⇒ Object
Returns the value of attribute order_id.
-
#plain_view ⇒ Object
Returns the value of attribute plain_view.
-
#store_code ⇒ Object
Returns the value of attribute store_code.
Instance Method Summary collapse
Instance Attribute Details
#email ⇒ Object
Returns the value of attribute email
1 2 3 |
# File 'lib/delayed_send.rb', line 1 def email @email end |
#html_view ⇒ Object
Returns the value of attribute html_view
1 2 3 |
# File 'lib/delayed_send.rb', line 1 def html_view @html_view end |
#message_name ⇒ Object
Returns the value of attribute message_name
1 2 3 |
# File 'lib/delayed_send.rb', line 1 def @message_name end |
#order_id ⇒ Object
Returns the value of attribute order_id
1 2 3 |
# File 'lib/delayed_send.rb', line 1 def order_id @order_id end |
#plain_view ⇒ Object
Returns the value of attribute plain_view
1 2 3 |
# File 'lib/delayed_send.rb', line 1 def plain_view @plain_view end |
#store_code ⇒ Object
Returns the value of attribute store_code
1 2 3 |
# File 'lib/delayed_send.rb', line 1 def store_code @store_code end |
Instance Method Details
#perform ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/delayed_send.rb', line 2 def perform return if email.blank? #store_code ||= 'default' order = Spree::Order.find(order_id) token= Spree::BrontoConfiguration.account[store_code]['token'] from_email= order.store.mail_from_address from_name= Spree::BrontoConfiguration.account[store_code]['from_name'] reply_email= order.store.mail_from_address ={:fromEmail =>from_email,:fromName => from_name, :replyEmail => reply_email} view = ActionView::Base.new(Rails::Application::Configuration.new(Rails.root).paths["app/mailers/spree"]) view.view_paths<<File.join(File.dirname(__FILE__), '../app/mailers/spree') attributes = {:First_Name => order.bill_address.firstname, :Last_name => order.bill_address.lastname} attributes[:SENDTIME__CONTENT1] = view.render(plain_view, :order => order) unless plain_view.nil? attributes[:SENDTIME__CONTENT2] = (view.render(html_view, :order => order)).gsub(/\n/,'').html_safe unless html_view.nil? begin communication = BrontoIntegration::Communication.new(token) communication.trigger_delivery_by_id(,email,'transactional','html',attributes,) rescue => exception begin #handle the transactional contact in case the message is not approved for transactional. contact = BrontoIntegration::Contact.new(token) contact.update_status(email,'active') communication.trigger_delivery_by_id(,email,'triggered','html',attributes,) rescue => exception raise exception end end end |