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::KL_USER_AGENT, Client::KL_VERSION, Client::METRIC, Client::METRICS, Client::TIMELINE, Client::V1_API, Client::V2_API
Class Method Summary collapse
-
.add_subscribers_to_list(list_id, api_key: nil, profiles: []) ⇒ Object
Subscribe profiles to a list.
-
.add_to_list(list_id, api_key: nil, profiles: []) ⇒ Object
Add profiles to a list.
-
.check_list_memberships(list_id, api_key: nil, emails: [], phone_numbers: [], push_tokens: []) ⇒ Object
Check if profiles are on a list.
-
.check_list_subscriptions(list_id, api_key: nil, emails: [], phone_numbers: [], push_tokens: []) ⇒ Object
Check if profiles are in a list and not supressed.
-
.create_list(list_name, api_key: nil) ⇒ Object
Creates a new list.
-
.delete_list(list_id, api_key: nil) ⇒ Object
Deletes a list.
-
.get_group_members(list_id, api_key: nil, marker: nil) ⇒ List
Get all of the emails, phone numbers, and push tokens for profiles in a given list or segment.
-
.get_list_details(list_id, api_key: nil) ⇒ JSON
Retrieves the details of the list.
-
.get_list_exclusions(list_id, api_key: nil, marker: nil) ⇒ List
Get all emails, phone numbers, along with reasons for list exclusion.
-
.get_lists(api_key: nil) ⇒ List
Retrieves all the lists in the Klaviyo account.
-
.remove_from_list(list_id, api_key: nil, emails: [], phone_numbers: [], push_tokens: []) ⇒ Object
Remove profiles from a list.
-
.unsubscribe_from_list(list_id, api_key: nil, emails: []) ⇒ Object
Unsubscribe and remove profiles from a list.
-
.update_list_details(list_id, list_name, api_key: nil) ⇒ Object
Updates the properties of a list.
Class Method Details
.add_subscribers_to_list(list_id, api_key: nil, profiles: []) ⇒ Object
Subscribe profiles to a list.
85 86 87 88 89 90 91 |
# File 'lib/klaviyo/apis/lists.rb', line 85 def self.add_subscribers_to_list(list_id, api_key: nil, profiles: []) path = "#{LIST}/#{list_id}/#{SUBSCRIBE}" params = { :profiles => profiles } v2_request(HTTP_POST, path, api_key: api_key, **params) end |
.add_to_list(list_id, api_key: nil, profiles: []) ⇒ Object
Add profiles to a list
113 114 115 116 117 118 119 |
# File 'lib/klaviyo/apis/lists.rb', line 113 def self.add_to_list(list_id, api_key: nil, profiles: []) path = "#{LIST}/#{list_id}/#{MEMBERS}" params = { :profiles => profiles } v2_request(HTTP_POST, path, api_key: api_key, **params) end |
.check_list_memberships(list_id, api_key: nil, emails: [], phone_numbers: [], push_tokens: []) ⇒ Object
Check if profiles are on a list
129 130 131 132 133 134 135 136 137 |
# File 'lib/klaviyo/apis/lists.rb', line 129 def self.check_list_memberships(list_id, api_key: nil, 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, api_key: api_key, **params) end |
.check_list_subscriptions(list_id, api_key: nil, emails: [], phone_numbers: [], push_tokens: []) ⇒ Object
Check if profiles are in a list and not supressed
67 68 69 70 71 72 73 74 75 |
# File 'lib/klaviyo/apis/lists.rb', line 67 def self.check_list_subscriptions(list_id, api_key: nil, 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, api_key: api_key, **params) end |
.create_list(list_name, api_key: nil) ⇒ Object
Creates a new list
14 15 16 17 18 19 |
# File 'lib/klaviyo/apis/lists.rb', line 14 def self.create_list(list_name, api_key: nil) body = { :list_name => list_name } v2_request(HTTP_POST, LISTS, api_key: api_key, **body) end |
.delete_list(list_id, api_key: nil) ⇒ Object
Deletes a list
54 55 56 57 |
# File 'lib/klaviyo/apis/lists.rb', line 54 def self.delete_list(list_id, api_key: nil) path = "#{LIST}/#{list_id}" v2_request(HTTP_DELETE, path, api_key: api_key) end |
.get_group_members(list_id, api_key: nil, marker: nil) ⇒ List
Get all of the emails, phone numbers, and push tokens for profiles in a given list or segment
174 175 176 177 178 179 180 |
# File 'lib/klaviyo/apis/lists.rb', line 174 def self.get_group_members(list_id, api_key: nil, marker: nil) path = "#{GROUP}/#{list_id}/#{MEMBERS}/#{ALL}" params = { marker: marker } v2_request(HTTP_GET, path, api_key: api_key, **params) end |
.get_list_details(list_id, api_key: nil) ⇒ JSON
Retrieves the details of the list
32 33 34 35 |
# File 'lib/klaviyo/apis/lists.rb', line 32 def self.get_list_details(list_id, api_key: nil) path = "#{LIST}/#{list_id}" v2_request(HTTP_GET, path, api_key: api_key) end |
.get_list_exclusions(list_id, api_key: nil, marker: nil) ⇒ List
Get all emails, phone numbers, along with reasons for list exclusion
161 162 163 164 165 166 167 |
# File 'lib/klaviyo/apis/lists.rb', line 161 def self.get_list_exclusions(list_id, api_key: nil, marker: nil) path = "#{LIST}/#{list_id}/#{EXCLUSIONS}/#{ALL}" params = { :marker => marker } v2_request(HTTP_GET, path, api_key: api_key, **params) end |
.get_lists(api_key: nil) ⇒ List
Retrieves all the lists in the Klaviyo account
24 25 26 |
# File 'lib/klaviyo/apis/lists.rb', line 24 def self.get_lists(api_key: nil) v2_request(HTTP_GET, LISTS, api_key: api_key) end |
.remove_from_list(list_id, api_key: nil, emails: [], phone_numbers: [], push_tokens: []) ⇒ Object
Remove profiles from a list
146 147 148 149 150 151 152 153 154 |
# File 'lib/klaviyo/apis/lists.rb', line 146 def self.remove_from_list(list_id, api_key: nil, 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, api_key: api_key, **params) end |
.unsubscribe_from_list(list_id, api_key: nil, emails: []) ⇒ Object
Unsubscribe and remove profiles from a list
98 99 100 101 102 103 104 |
# File 'lib/klaviyo/apis/lists.rb', line 98 def self.unsubscribe_from_list(list_id, api_key: nil, emails: []) path = "#{LIST}/#{list_id}/#{SUBSCRIBE}" params = { :emails => emails } v2_request(HTTP_DELETE, path, api_key: api_key, **params) end |
.update_list_details(list_id, list_name, api_key: nil) ⇒ Object
Updates the properties of a list
42 43 44 45 46 47 48 |
# File 'lib/klaviyo/apis/lists.rb', line 42 def self.update_list_details(list_id, list_name, api_key: nil) path = "#{LIST}/#{list_id}" body = { :list_name => list_name } v2_request(HTTP_PUT, path, api_key: api_key, **body) end |