Module: Convertkit::Client::Tags
- Included in:
- Convertkit::Client
- Defined in:
- lib/convertkit/client/tags.rb
Instance Method Summary collapse
- #add_subscriber_to_tag(tag_id, email, options = {}) ⇒ Object
- #create_tag(tag_name) ⇒ Object
- #create_tags(tag_names) ⇒ Object
- #remove_tag_from_subscriber(tag_id, subscriber_id) ⇒ Object
- #remove_tag_from_subscriber_by_email(tag_id, email) ⇒ Object
- #subscriptions_to_tag(tag_id, options = {}) ⇒ Object
- #tags ⇒ Object
Instance Method Details
#add_subscriber_to_tag(tag_id, email, options = {}) ⇒ Object
8 9 10 11 12 13 14 15 |
# File 'lib/convertkit/client/tags.rb', line 8 def add_subscriber_to_tag(tag_id, email, = {}) connection.post("tags/#{tag_id}/subscribe") do |f| f.params['email'] = email f.params['first_name'] = [:first_name] f.params['fields'] = [:fields] f.params['tags'] = [:tags] end end |
#create_tag(tag_name) ⇒ Object
27 28 29 30 31 32 |
# File 'lib/convertkit/client/tags.rb', line 27 def create_tag(tag_name) response = connection.post("tags") do |request| request.params["tag"] = { name: tag_name } end response.body end |
#create_tags(tag_names) ⇒ Object
34 35 36 37 38 39 |
# File 'lib/convertkit/client/tags.rb', line 34 def (tag_names) response = connection.post("tags") do |request| request.params["tag"] = tag_names.map { |tag_name| { name: tag_name } } end response.body end |
#remove_tag_from_subscriber(tag_id, subscriber_id) ⇒ Object
17 18 19 |
# File 'lib/convertkit/client/tags.rb', line 17 def remove_tag_from_subscriber(tag_id, subscriber_id) connection.delete("subscribers/#{subscriber_id}/tags/#{tag_id}") end |
#remove_tag_from_subscriber_by_email(tag_id, email) ⇒ Object
21 22 23 24 25 |
# File 'lib/convertkit/client/tags.rb', line 21 def remove_tag_from_subscriber_by_email(tag_id, email) connection.post("tags/#{tag_id}/unsubscribe") do |f| f.params['email'] = email end end |
#subscriptions_to_tag(tag_id, options = {}) ⇒ Object
41 42 43 44 45 46 |
# File 'lib/convertkit/client/tags.rb', line 41 def subscriptions_to_tag(tag_id, = {}) connection.get("tags/#{tag_id}/subscriptions", ) do |f| f.params["sort_order"] = [:sort_order] if [:sort_order] f.params["subscriber_state"] = [:subscriber_state] if [:subscriber_state] end end |
#tags ⇒ Object
4 5 6 |
# File 'lib/convertkit/client/tags.rb', line 4 def connection.get("tags") end |