Class: ChimpSync::Update

Inherits:
Object
  • Object
show all
Defined in:
lib/chimp_sync/update.rb

Class Method Summary collapse

Class Method Details

.email(label, old_email, new_email) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/chimp_sync/update.rb', line 14

def self.email(label, old_email, new_email)
  raise 'Not yet implemented.'
  list   = ChimpSync.lists[label]
  gibbon = Gibbon::API.new list.api_key

  gibbon.lists.update_member id: list.id, email: {email: new_email}
end

.subscribed(label, email, subscribed) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
# File 'lib/chimp_sync/update.rb', line 2

def self.subscribed(label, email, subscribed)
  list   = ChimpSync.lists[label]
  gibbon = Gibbon::API.new list.api_key

  if subscribed
    gibbon.lists.subscribe id: list.id, email: {email: email},
      double_optin: false, send_welcome: true
  else
    gibbon.lists.unsubscribe id: list.id, email: {email: email}
  end
end