Class: LaunchrockSync::SyncClient::MailChimpClient
- Inherits:
-
Object
- Object
- LaunchrockSync::SyncClient::MailChimpClient
- Defined in:
- lib/launchrock-sync/models/sync_client.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
Returns the value of attribute attributes.
Instance Method Summary collapse
- #add(email) ⇒ Object
- #api ⇒ Object
-
#initialize(attributes) ⇒ MailChimpClient
constructor
A new instance of MailChimpClient.
- #list ⇒ Object
Constructor Details
#initialize(attributes) ⇒ MailChimpClient
Returns a new instance of MailChimpClient.
64 65 66 |
# File 'lib/launchrock-sync/models/sync_client.rb', line 64 def initialize(attributes) self.attributes = attributes end |
Instance Attribute Details
#attributes ⇒ Object
Returns the value of attribute attributes.
62 63 64 |
# File 'lib/launchrock-sync/models/sync_client.rb', line 62 def attributes @attributes end |
Instance Method Details
#add(email) ⇒ Object
68 69 70 71 72 73 74 75 76 |
# File 'lib/launchrock-sync/models/sync_client.rb', line 68 def add(email) api.listSubscribe( { :id => list['id'], :email_address => email, :merge_vars => Hash.new, :double_optin => false, :send_welcome => false } ) end |
#api ⇒ Object
82 83 84 |
# File 'lib/launchrock-sync/models/sync_client.rb', line 82 def api @api ||= Mailchimp::API.new(attributes[:api_key]) end |
#list ⇒ Object
78 79 80 |
# File 'lib/launchrock-sync/models/sync_client.rb', line 78 def list @list ||= api.lists['data'].find {|a| a['name'] == attributes[:list] } end |