Class: Klaviyo::Lists
Constant Summary collapse
- EXCLUSIONS =
'exclusions'
- GROUP =
'group'
- LIST =
'list'
- LISTS =
'lists'
- MEMBERS =
'members'
- SUBSCRIBE =
'subscribe'
Constants inherited from Client
Client::ALL, Client::BASE_API_URL, Client::CONTENT_JSON, Client::CONTENT_URL_FORM, Client::DEFAULT_COUNT, Client::DEFAULT_PAGE, Client::DEFAULT_SORT_DESC, Client::HTTP_DELETE, Client::HTTP_GET, Client::HTTP_POST, Client::HTTP_PUT, Client::METRIC, Client::METRICS, Client::TIMELINE, Client::V1_API, Client::V2_API
Class Method Summary collapse
-
.add_subscribers_to_list(list_id, profiles: []) ⇒ Object
Subscribe profiles to a list.
-
.add_to_list(list_id, profiles: []) ⇒ Object
Add profiles to a list.
-
.check_list_memberships(list_id, emails: [], phone_numbers: [], push_tokens: []) ⇒ Object
Check if profiles are on a list.
-
.check_list_subscriptions(list_id, emails: [], phone_numbers: [], push_tokens: []) ⇒ Object
Check if profiles are in a list and not supressed.
-
.create_list(list_name) ⇒ Object
Creates a new list.
-
.delete_list(list_id) ⇒ Object
Deletes a list.
-
.get_group_members(list_id) ⇒ List
Get all of the emails, phone numbers, and push tokens for profiles in a given list or segment.
-
.get_list_details(list_id) ⇒ JSON
Retrieves the details of the list.
-
.get_list_exclusions(list_id, marker: nil) ⇒ List
Get all emails, phone numbers, along with reasons for list exclusion.
-
.get_lists ⇒ List
Retrieves all the lists in the Klaviyo account.
-
.remove_from_list(list_id, emails: [], phone_numbers: [], push_tokens: []) ⇒ Object
Remove profiles from a list.
-
.unsubscribe_from_list(list_id, emails: []) ⇒ Object
Unsubscribe and remove profiles from a list.
-
.update_list_details(list_id, list_name) ⇒ Object
Updates the properties of a list.
Class Method Details
.add_subscribers_to_list(list_id, profiles: []) ⇒ Object
Subscribe profiles to a list.
78 79 80 81 82 83 84 |
# File 'lib/klaviyo/apis/lists.rb', line 78 def self.add_subscribers_to_list(list_id, profiles: []) path = "#{LIST}/#{list_id}/#{SUBSCRIBE}" params = { :profiles => profiles } v2_request(HTTP_POST, path, params) end |
.add_to_list(list_id, profiles: []) ⇒ Object
Add profiles to a list
104 105 106 107 108 109 110 |
# File 'lib/klaviyo/apis/lists.rb', line 104 def self.add_to_list(list_id, profiles: []) path = "#{LIST}/#{list_id}/#{MEMBERS}" params = { :profiles => profiles } v2_request(HTTP_POST, path, params) end |
.check_list_memberships(list_id, emails: [], phone_numbers: [], push_tokens: []) ⇒ Object
Check if profiles are on a list
119 120 121 122 123 124 125 126 127 |
# File 'lib/klaviyo/apis/lists.rb', line 119 def self.check_list_memberships(list_id, emails: [], phone_numbers: [], push_tokens: []) path = "#{LIST}/#{list_id}/#{MEMBERS}" params = { :emails => emails, :phone_numbers => phone_numbers, :push_tokens => push_tokens } v2_request(HTTP_GET, path, params) end |
.check_list_subscriptions(list_id, emails: [], phone_numbers: [], push_tokens: []) ⇒ Object
Check if profiles are in a list and not supressed
61 62 63 64 65 66 67 68 69 |
# File 'lib/klaviyo/apis/lists.rb', line 61 def self.check_list_subscriptions(list_id, emails: [], phone_numbers: [], push_tokens: []) path = "#{LIST}/#{list_id}/#{SUBSCRIBE}" params = { :emails => emails, :phone_numbers => phone_numbers, :push_tokens => push_tokens } v2_request(HTTP_GET, path, params) end |
.create_list(list_name) ⇒ Object
Creates a new list
13 14 15 16 17 18 |
# File 'lib/klaviyo/apis/lists.rb', line 13 def self.create_list(list_name) body = { :list_name => list_name } v2_request(HTTP_POST, LISTS, body) end |
.delete_list(list_id) ⇒ Object
Deletes a list
49 50 51 52 |
# File 'lib/klaviyo/apis/lists.rb', line 49 def self.delete_list(list_id) path = "#{LIST}/#{list_id}" v2_request(HTTP_DELETE, path) end |
.get_group_members(list_id) ⇒ List
Get all of the emails, phone numbers, and push tokens for profiles in a given list or segment
161 162 163 164 |
# File 'lib/klaviyo/apis/lists.rb', line 161 def self.get_group_members(list_id) path = "#{GROUP}/#{list_id}/#{MEMBERS}/#{ALL}" v2_request(HTTP_GET, path) end |
.get_list_details(list_id) ⇒ JSON
Retrieves the details of the list
29 30 31 32 |
# File 'lib/klaviyo/apis/lists.rb', line 29 def self.get_list_details(list_id) path = "#{LIST}/#{list_id}" v2_request(HTTP_GET, path) end |
.get_list_exclusions(list_id, marker: nil) ⇒ List
Get all emails, phone numbers, along with reasons for list exclusion
149 150 151 152 153 154 155 |
# File 'lib/klaviyo/apis/lists.rb', line 149 def self.get_list_exclusions(list_id, marker: nil) path = "#{LIST}/#{list_id}/#{EXCLUSIONS}/#{ALL}" params = { :marker => marker } v2_request(HTTP_GET, path, params) end |
.get_lists ⇒ List
Retrieves all the lists in the Klaviyo account
22 23 24 |
# File 'lib/klaviyo/apis/lists.rb', line 22 def self.get_lists() v2_request(HTTP_GET, LISTS) end |
.remove_from_list(list_id, emails: [], phone_numbers: [], push_tokens: []) ⇒ Object
Remove profiles from a list
135 136 137 138 139 140 141 142 143 |
# File 'lib/klaviyo/apis/lists.rb', line 135 def self.remove_from_list(list_id, emails: [], phone_numbers: [], push_tokens: []) path = "#{LIST}/#{list_id}/#{MEMBERS}" params = { :emails => emails, :phone_numbers => phone_numbers, :push_tokens => push_tokens } v2_request(HTTP_DELETE, path, params) end |
.unsubscribe_from_list(list_id, emails: []) ⇒ Object
Unsubscribe and remove profiles from a list
90 91 92 93 94 95 96 |
# File 'lib/klaviyo/apis/lists.rb', line 90 def self.unsubscribe_from_list(list_id, emails: []) path = "#{LIST}/#{list_id}/#{SUBSCRIBE}" params = { :emails => emails } v2_request(HTTP_DELETE, path, params) end |