Class: DelayedSubscriberAdd
- Inherits:
-
Struct
- Object
- Struct
- DelayedSubscriberAdd
- Defined in:
- lib/delayed_subscriber_add.rb
Instance Attribute Summary collapse
-
#list ⇒ Object
Returns the value of attribute list.
-
#ops ⇒ Object
Returns the value of attribute ops.
-
#store_code ⇒ Object
Returns the value of attribute store_code.
-
#user ⇒ Object
Returns the value of attribute user.
Instance Method Summary collapse
Instance Attribute Details
#list ⇒ Object
Returns the value of attribute list
2 3 4 |
# File 'lib/delayed_subscriber_add.rb', line 2 def list @list end |
#ops ⇒ Object
Returns the value of attribute ops
2 3 4 |
# File 'lib/delayed_subscriber_add.rb', line 2 def ops @ops end |
#store_code ⇒ Object
Returns the value of attribute store_code
2 3 4 |
# File 'lib/delayed_subscriber_add.rb', line 2 def store_code @store_code end |
#user ⇒ Object
Returns the value of attribute user
2 3 4 |
# File 'lib/delayed_subscriber_add.rb', line 2 def user @user end |
Instance Method Details
#perform ⇒ Object
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 36 37 |
# File 'lib/delayed_subscriber_add.rb', line 3 def perform if list.nil? || !user subscriber_id = -1 else begin token= Spree::BrontoConfiguration.account[store_code]['token'] if user.is_a? String email=user else email=user.email end contact = BrontoIntegration::Contact.new(token) contacts=contact.set_up(email,ops||{}) subscriber_id= contacts[:id] communication = BrontoIntegration::Communication.new(token) communication.add_to_list(list.title,email) rescue => exception subscriber_id = -1 #raise exception end end unless user.is_a? String begin user.bronto_lists << list user.save! rescue end end end |