Module: Convertkit::Client::Subscribers

Included in:
Convertkit::Client
Defined in:
lib/convertkit/client/subscribers.rb

Instance Method Summary collapse

Instance Method Details

#remove_tag_from_subscriber(subscriber_id, tag_id) ⇒ Object



31
32
33
# File 'lib/convertkit/client/subscribers.rb', line 31

def remove_tag_from_subscriber(subscriber_id, tag_id)
  connection.delete("subscribers/#{subscriber_id}/tags/#{tag_id}")
end

#subscriber(subscriber_id) ⇒ Object



8
9
10
# File 'lib/convertkit/client/subscribers.rb', line 8

def subscriber(subscriber_id)
  connection.get("subscribers/#{subscriber_id}")
end

#subscriber_tags(subscriber_id) ⇒ Object



12
13
14
# File 'lib/convertkit/client/subscribers.rb', line 12

def subscriber_tags(subscriber_id)
  connection.get("subscribers/#{subscriber_id}/tags")
end

#subscribers(options = {}) ⇒ Object



4
5
6
# File 'lib/convertkit/client/subscribers.rb', line 4

def subscribers(options = {})
  connection.get("subscribers", options)
end

#unsubscribe(email) ⇒ Object



25
26
27
28
29
# File 'lib/convertkit/client/subscribers.rb', line 25

def unsubscribe(email)
  connection.put("unsubscribe") do |f|
    f.params['email'] = email
  end
end

#update_subscriber(subscriber_id, options = {}) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/convertkit/client/subscribers.rb', line 16

def update_subscriber(subscriber_id, options = {})
  response = connection.put("subscribers/#{subscriber_id}") do |f|
    f.params["email_address"] = options[:email_address] if options[:email_address]
    f.params["fields"] = options[:fields] if options[:fields]
    f.params["first_name"] = options[:first_name] if options[:first_name]
  end
  response.body
end