klaviyo_sdk 1.0.0.20220329

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +6 -0
  3. data/README.md +1121 -0
  4. data/klaviyo_sdk.gemspec +35 -0
  5. data/lib/klaviyo_sdk/api/campaigns_api.rb +717 -0
  6. data/lib/klaviyo_sdk/api/data_privacy_api.rb +86 -0
  7. data/lib/klaviyo_sdk/api/lists_segments_api.rb +1101 -0
  8. data/lib/klaviyo_sdk/api/metrics_api.rb +343 -0
  9. data/lib/klaviyo_sdk/api/profiles_api.rb +381 -0
  10. data/lib/klaviyo_sdk/api/templates_api.rb +555 -0
  11. data/lib/klaviyo_sdk/api/track_identify_api.rb +288 -0
  12. data/lib/klaviyo_sdk/api_client.rb +389 -0
  13. data/lib/klaviyo_sdk/api_error.rb +57 -0
  14. data/lib/klaviyo_sdk/configuration.rb +278 -0
  15. data/lib/klaviyo_sdk/models/campaign.rb +310 -0
  16. data/lib/klaviyo_sdk/models/check_membership_request.rb +244 -0
  17. data/lib/klaviyo_sdk/models/delete_email.rb +218 -0
  18. data/lib/klaviyo_sdk/models/delete_person.rb +218 -0
  19. data/lib/klaviyo_sdk/models/delete_phone.rb +219 -0
  20. data/lib/klaviyo_sdk/models/deprecated_get_list_response.rb +298 -0
  21. data/lib/klaviyo_sdk/models/deprecated_get_list_response_data.rb +263 -0
  22. data/lib/klaviyo_sdk/models/global_exclusion_response_data.rb +274 -0
  23. data/lib/klaviyo_sdk/models/identify_payload.rb +237 -0
  24. data/lib/klaviyo_sdk/models/identify_payload_properties.rb +327 -0
  25. data/lib/klaviyo_sdk/models/inline_object.rb +220 -0
  26. data/lib/klaviyo_sdk/models/inline_object3.rb +226 -0
  27. data/lib/klaviyo_sdk/models/inline_object4.rb +254 -0
  28. data/lib/klaviyo_sdk/models/inline_object5.rb +288 -0
  29. data/lib/klaviyo_sdk/models/metric.rb +265 -0
  30. data/lib/klaviyo_sdk/models/metric_export.rb +285 -0
  31. data/lib/klaviyo_sdk/models/metric_timeline.rb +271 -0
  32. data/lib/klaviyo_sdk/models/metric_timeline_data.rb +294 -0
  33. data/lib/klaviyo_sdk/models/person.rb +389 -0
  34. data/lib/klaviyo_sdk/models/person.rb.bak +389 -0
  35. data/lib/klaviyo_sdk/models/privacy_email.rb +218 -0
  36. data/lib/klaviyo_sdk/models/privacy_id.rb +218 -0
  37. data/lib/klaviyo_sdk/models/privacy_phone.rb +218 -0
  38. data/lib/klaviyo_sdk/models/rendered_template.rb +247 -0
  39. data/lib/klaviyo_sdk/models/template.rb +272 -0
  40. data/lib/klaviyo_sdk/models/track_payload.rb +261 -0
  41. data/lib/klaviyo_sdk/models/track_payload_customer_properties.rb +227 -0
  42. data/lib/klaviyo_sdk/models/track_payload_properties.rb +237 -0
  43. data/lib/klaviyo_sdk/version.rb +15 -0
  44. data/lib/klaviyo_sdk.rb +124 -0
  45. metadata +120 -0
@@ -0,0 +1,381 @@
1
+ =begin
2
+ #Klaviyo API
3
+
4
+ #Empowering creators to own their destiny
5
+
6
+ The version of the OpenAPI document: 2022.03.29
7
+
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.4.0
10
+
11
+ =end
12
+
13
+ require 'cgi'
14
+
15
+ module Client
16
+ class ProfilesApi
17
+ attr_accessor :api_client
18
+
19
+ def initialize(api_client = ApiClient.default)
20
+ @api_client = api_client
21
+ end
22
+ # Exchange ID for Profile ID
23
+ # Klaviyo's web tracking uses an encrypted identifier. However, there are many use cases that require developers to have access to a given profile's email or phone number. In such cases, developers can use this operation to exchange an encrypted identifier for a profile ID, which they can then use to retrieve the full profile data (by making a subsequent request to the `get-profiles` operation). The `exchange_id` takes the following form: `<IDENTIFIER>.<COMPANY_ID>` The `exchange_id` appears in the url as follows: `?_kx=<IDENTIFIER>.<COMPANY_ID>`
24
+ # @param [Hash] opts the optional parameters
25
+ # @option opts [InlineObject] :inline_object
26
+ # @return [Hash<String, Object>]
27
+ def exchange(opts = {})
28
+ data, _status_code, _headers = exchange_with_http_info(opts)
29
+ data
30
+ end
31
+
32
+ # Exchange ID for Profile ID
33
+ # Klaviyo&#39;s web tracking uses an encrypted identifier. However, there are many use cases that require developers to have access to a given profile&#39;s email or phone number. In such cases, developers can use this operation to exchange an encrypted identifier for a profile ID, which they can then use to retrieve the full profile data (by making a subsequent request to the &#x60;get-profiles&#x60; operation). The &#x60;exchange_id&#x60; takes the following form: &#x60;&lt;IDENTIFIER&gt;.&lt;COMPANY_ID&gt;&#x60; The &#x60;exchange_id&#x60; appears in the url as follows: &#x60;?_kx&#x3D;&lt;IDENTIFIER&gt;.&lt;COMPANY_ID&gt;&#x60;
34
+ # @param [Hash] opts the optional parameters
35
+ # @option opts [InlineObject] :inline_object
36
+ # @return [Array<(Hash<String, Object>, Integer, Hash)>] Hash<String, Object> data, response status code and response headers
37
+ def exchange_with_http_info(opts = {})
38
+ if @api_client.config.debugging
39
+ @api_client.config.logger.debug 'Calling API: ProfilesApi.exchange ...'
40
+ end
41
+ # resource path
42
+ local_var_path = '/v2/people/exchange'
43
+
44
+ # query parameters
45
+ query_params = opts[:query_params] || {}
46
+
47
+ # header parameters
48
+ header_params = opts[:header_params] || {}
49
+ # HTTP header 'Accept' (if needed)
50
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
51
+ # HTTP header 'Content-Type'
52
+ content_type = @api_client.select_header_content_type(['application/json'])
53
+ if !content_type.nil?
54
+ header_params['Content-Type'] = content_type
55
+ end
56
+
57
+ # form parameters
58
+ form_params = opts[:form_params] || {}
59
+
60
+ # http body (model)
61
+ post_body = opts[:body] || @api_client.object_to_http_body(opts[:'inline_object'])
62
+
63
+ # return_type
64
+ return_type = opts[:debug_return_type] || 'Hash<String, Object>'
65
+
66
+ # auth_names
67
+ auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']
68
+
69
+ new_options = opts.merge(
70
+ :operation => :"ProfilesApi.exchange",
71
+ :header_params => header_params,
72
+ :query_params => query_params,
73
+ :form_params => form_params,
74
+ :body => post_body,
75
+ :auth_names => auth_names,
76
+ :return_type => return_type
77
+ )
78
+
79
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
80
+ if @api_client.config.debugging
81
+ @api_client.config.logger.debug "API called: ProfilesApi#exchange\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
82
+ end
83
+ return data, status_code, headers
84
+ end
85
+
86
+ # Get Profile
87
+ # Retrieves all the data attributes for a person, based on the Klaviyo Person ID.
88
+ # @param person_id [String]
89
+ # @param [Hash] opts the optional parameters
90
+ # @return [Person]
91
+ def get_profile(person_id, opts = {})
92
+ data, _status_code, _headers = get_profile_with_http_info(person_id, opts)
93
+ data
94
+ end
95
+
96
+ # Get Profile
97
+ # Retrieves all the data attributes for a person, based on the Klaviyo Person ID.
98
+ # @param person_id [String]
99
+ # @param [Hash] opts the optional parameters
100
+ # @return [Array<(Person, Integer, Hash)>] Person data, response status code and response headers
101
+ def get_profile_with_http_info(person_id, opts = {})
102
+ if @api_client.config.debugging
103
+ @api_client.config.logger.debug 'Calling API: ProfilesApi.get_profile ...'
104
+ end
105
+ # verify the required parameter 'person_id' is set
106
+ if @api_client.config.client_side_validation && person_id.nil?
107
+ fail ArgumentError, "Missing the required parameter 'person_id' when calling ProfilesApi.get_profile"
108
+ end
109
+ # resource path
110
+ local_var_path = '/v1/person/{person_id}'.sub('{' + 'person_id' + '}', CGI.escape(person_id.to_s))
111
+
112
+ # query parameters
113
+ query_params = opts[:query_params] || {}
114
+
115
+ # header parameters
116
+ header_params = opts[:header_params] || {}
117
+ # HTTP header 'Accept' (if needed)
118
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
119
+
120
+ # form parameters
121
+ form_params = opts[:form_params] || {}
122
+
123
+ # http body (model)
124
+ post_body = opts[:body]
125
+
126
+ # return_type
127
+ return_type = opts[:debug_return_type] || 'Person'
128
+
129
+ # auth_names
130
+ auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']
131
+
132
+ new_options = opts.merge(
133
+ :operation => :"ProfilesApi.get_profile",
134
+ :header_params => header_params,
135
+ :query_params => query_params,
136
+ :form_params => form_params,
137
+ :body => post_body,
138
+ :auth_names => auth_names,
139
+ :return_type => return_type
140
+ )
141
+
142
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
143
+ if @api_client.config.debugging
144
+ @api_client.config.logger.debug "API called: ProfilesApi#get_profile\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
145
+ end
146
+ return data, status_code, headers
147
+ end
148
+
149
+ # Get Profile's Events for a Specific Metric
150
+ # Returns a person's batched timeline for one specific event type.
151
+ # @param person_id [String]
152
+ # @param metric_id [String]
153
+ # @param [Hash] opts the optional parameters
154
+ # @option opts [String] :since Either a 10-digit Unix timestamp (UTC) to use as starting datetime, OR a pagination token obtained from the next attribute of a prior API call. For backwards compatibility, UUIDs will continue to be supported for a limited time. Defaults to current time.
155
+ # @option opts [Integer] :count Number of events to return in a batch. (default to 50)
156
+ # @option opts [String] :sort Sort order to apply to timeline, either descending or ascending. Valid values are &#x60;desc&#x60; or &#x60;asc&#x60;. Defaults to &#x60;desc&#x60;. (default to 'desc')
157
+ # @return [MetricTimeline]
158
+ def profile_metric_timeline(person_id, metric_id, opts = {})
159
+ data, _status_code, _headers = profile_metric_timeline_with_http_info(person_id, metric_id, opts)
160
+ data
161
+ end
162
+
163
+ # Get Profile&#39;s Events for a Specific Metric
164
+ # Returns a person&#39;s batched timeline for one specific event type.
165
+ # @param person_id [String]
166
+ # @param metric_id [String]
167
+ # @param [Hash] opts the optional parameters
168
+ # @option opts [String] :since Either a 10-digit Unix timestamp (UTC) to use as starting datetime, OR a pagination token obtained from the next attribute of a prior API call. For backwards compatibility, UUIDs will continue to be supported for a limited time. Defaults to current time.
169
+ # @option opts [Integer] :count Number of events to return in a batch.
170
+ # @option opts [String] :sort Sort order to apply to timeline, either descending or ascending. Valid values are &#x60;desc&#x60; or &#x60;asc&#x60;. Defaults to &#x60;desc&#x60;.
171
+ # @return [Array<(MetricTimeline, Integer, Hash)>] MetricTimeline data, response status code and response headers
172
+ def profile_metric_timeline_with_http_info(person_id, metric_id, opts = {})
173
+ if @api_client.config.debugging
174
+ @api_client.config.logger.debug 'Calling API: ProfilesApi.profile_metric_timeline ...'
175
+ end
176
+ # verify the required parameter 'person_id' is set
177
+ if @api_client.config.client_side_validation && person_id.nil?
178
+ fail ArgumentError, "Missing the required parameter 'person_id' when calling ProfilesApi.profile_metric_timeline"
179
+ end
180
+ # verify the required parameter 'metric_id' is set
181
+ if @api_client.config.client_side_validation && metric_id.nil?
182
+ fail ArgumentError, "Missing the required parameter 'metric_id' when calling ProfilesApi.profile_metric_timeline"
183
+ end
184
+ if @api_client.config.client_side_validation && !opts[:'count'].nil? && opts[:'count'] > 100
185
+ fail ArgumentError, 'invalid value for "opts[:"count"]" when calling ProfilesApi.profile_metric_timeline, must be smaller than or equal to 100.'
186
+ end
187
+
188
+ if @api_client.config.client_side_validation && !opts[:'count'].nil? && opts[:'count'] < 1
189
+ fail ArgumentError, 'invalid value for "opts[:"count"]" when calling ProfilesApi.profile_metric_timeline, must be greater than or equal to 1.'
190
+ end
191
+
192
+ # resource path
193
+ local_var_path = '/v1/person/{person_id}/metric/{metric_id}/timeline'.sub('{' + 'person_id' + '}', CGI.escape(person_id.to_s)).sub('{' + 'metric_id' + '}', CGI.escape(metric_id.to_s))
194
+
195
+ # query parameters
196
+ query_params = opts[:query_params] || {}
197
+ query_params[:'since'] = opts[:'since'] if !opts[:'since'].nil?
198
+ query_params[:'count'] = opts[:'count'] if !opts[:'count'].nil?
199
+ query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?
200
+
201
+ # header parameters
202
+ header_params = opts[:header_params] || {}
203
+ # HTTP header 'Accept' (if needed)
204
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
205
+
206
+ # form parameters
207
+ form_params = opts[:form_params] || {}
208
+
209
+ # http body (model)
210
+ post_body = opts[:body]
211
+
212
+ # return_type
213
+ return_type = opts[:debug_return_type] || 'MetricTimeline'
214
+
215
+ # auth_names
216
+ auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']
217
+
218
+ new_options = opts.merge(
219
+ :operation => :"ProfilesApi.profile_metric_timeline",
220
+ :header_params => header_params,
221
+ :query_params => query_params,
222
+ :form_params => form_params,
223
+ :body => post_body,
224
+ :auth_names => auth_names,
225
+ :return_type => return_type
226
+ )
227
+
228
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
229
+ if @api_client.config.debugging
230
+ @api_client.config.logger.debug "API called: ProfilesApi#profile_metric_timeline\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
231
+ end
232
+ return data, status_code, headers
233
+ end
234
+
235
+ # Get Profile's Events for all Metrics
236
+ # Returns a batched timeline of all events for a person.
237
+ # @param person_id [String]
238
+ # @param [Hash] opts the optional parameters
239
+ # @option opts [String] :since Either a 10-digit Unix timestamp (UTC) to use as starting datetime, OR a pagination token obtained from the next attribute of a prior API call. For backwards compatibility, UUIDs will continue to be supported for a limited time. Defaults to current time.
240
+ # @option opts [Integer] :count Number of events to return in a batch. Default &#x3D; 50, Max &#x3D; 100 (default to 50)
241
+ # @option opts [String] :sort Sort order to apply to timeline, either descending or ascending. Valid values are &#x60;desc&#x60; or &#x60;asc&#x60;. Defaults to &#x60;desc&#x60;. Always descending when &#x60;since&#x60; is not sent, as &#x60;since&#x60; defaults to current time. (default to 'desc')
242
+ # @return [MetricTimeline]
243
+ def profile_metrics_timeline(person_id, opts = {})
244
+ data, _status_code, _headers = profile_metrics_timeline_with_http_info(person_id, opts)
245
+ data
246
+ end
247
+
248
+ # Get Profile&#39;s Events for all Metrics
249
+ # Returns a batched timeline of all events for a person.
250
+ # @param person_id [String]
251
+ # @param [Hash] opts the optional parameters
252
+ # @option opts [String] :since Either a 10-digit Unix timestamp (UTC) to use as starting datetime, OR a pagination token obtained from the next attribute of a prior API call. For backwards compatibility, UUIDs will continue to be supported for a limited time. Defaults to current time.
253
+ # @option opts [Integer] :count Number of events to return in a batch. Default &#x3D; 50, Max &#x3D; 100
254
+ # @option opts [String] :sort Sort order to apply to timeline, either descending or ascending. Valid values are &#x60;desc&#x60; or &#x60;asc&#x60;. Defaults to &#x60;desc&#x60;. Always descending when &#x60;since&#x60; is not sent, as &#x60;since&#x60; defaults to current time.
255
+ # @return [Array<(MetricTimeline, Integer, Hash)>] MetricTimeline data, response status code and response headers
256
+ def profile_metrics_timeline_with_http_info(person_id, opts = {})
257
+ if @api_client.config.debugging
258
+ @api_client.config.logger.debug 'Calling API: ProfilesApi.profile_metrics_timeline ...'
259
+ end
260
+ # verify the required parameter 'person_id' is set
261
+ if @api_client.config.client_side_validation && person_id.nil?
262
+ fail ArgumentError, "Missing the required parameter 'person_id' when calling ProfilesApi.profile_metrics_timeline"
263
+ end
264
+ if @api_client.config.client_side_validation && !opts[:'count'].nil? && opts[:'count'] > 100
265
+ fail ArgumentError, 'invalid value for "opts[:"count"]" when calling ProfilesApi.profile_metrics_timeline, must be smaller than or equal to 100.'
266
+ end
267
+
268
+ if @api_client.config.client_side_validation && !opts[:'count'].nil? && opts[:'count'] < 1
269
+ fail ArgumentError, 'invalid value for "opts[:"count"]" when calling ProfilesApi.profile_metrics_timeline, must be greater than or equal to 1.'
270
+ end
271
+
272
+ # resource path
273
+ local_var_path = '/v1/person/{person_id}/metrics/timeline'.sub('{' + 'person_id' + '}', CGI.escape(person_id.to_s))
274
+
275
+ # query parameters
276
+ query_params = opts[:query_params] || {}
277
+ query_params[:'since'] = opts[:'since'] if !opts[:'since'].nil?
278
+ query_params[:'count'] = opts[:'count'] if !opts[:'count'].nil?
279
+ query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?
280
+
281
+ # header parameters
282
+ header_params = opts[:header_params] || {}
283
+ # HTTP header 'Accept' (if needed)
284
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
285
+
286
+ # form parameters
287
+ form_params = opts[:form_params] || {}
288
+
289
+ # http body (model)
290
+ post_body = opts[:body]
291
+
292
+ # return_type
293
+ return_type = opts[:debug_return_type] || 'MetricTimeline'
294
+
295
+ # auth_names
296
+ auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']
297
+
298
+ new_options = opts.merge(
299
+ :operation => :"ProfilesApi.profile_metrics_timeline",
300
+ :header_params => header_params,
301
+ :query_params => query_params,
302
+ :form_params => form_params,
303
+ :body => post_body,
304
+ :auth_names => auth_names,
305
+ :return_type => return_type
306
+ )
307
+
308
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
309
+ if @api_client.config.debugging
310
+ @api_client.config.logger.debug "API called: ProfilesApi#profile_metrics_timeline\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
311
+ end
312
+ return data, status_code, headers
313
+ end
314
+
315
+ # Update Profile
316
+ # NOTE: If you are interested in creating or updating profiles in Klaviyo, you should be using the Identify API instead. The best use-case for this route is changing a profiles's email address or other primary identifier after a profile already exists in Klaviyo. Add or update one more more attributes for a Person, based on the Klaviyo Person ID. If a property already exists, it will be updated. If a property is not set for that record, it will be created. You can update any attribute, by sending one or more attributes along their new values, as query parameters. Recommended attributes for this endpoint: `$email`, `$phone_number`, `$id`
317
+ # @param person_id [String]
318
+ # @param [Hash] opts the optional parameters
319
+ # @option opts [Hash<String, Object>] :params
320
+ # @return [Person]
321
+ def update_profile(person_id, opts = {})
322
+ data, _status_code, _headers = update_profile_with_http_info(person_id, opts)
323
+ data
324
+ end
325
+
326
+ # Update Profile
327
+ # NOTE: If you are interested in creating or updating profiles in Klaviyo, you should be using the Identify API instead. The best use-case for this route is changing a profiles&#39;s email address or other primary identifier after a profile already exists in Klaviyo. Add or update one more more attributes for a Person, based on the Klaviyo Person ID. If a property already exists, it will be updated. If a property is not set for that record, it will be created. You can update any attribute, by sending one or more attributes along their new values, as query parameters. Recommended attributes for this endpoint: &#x60;$email&#x60;, &#x60;$phone_number&#x60;, &#x60;$id&#x60;
328
+ # @param person_id [String]
329
+ # @param [Hash] opts the optional parameters
330
+ # @option opts [Hash<String, Object>] :params
331
+ # @return [Array<(Person, Integer, Hash)>] Person data, response status code and response headers
332
+ def update_profile_with_http_info(person_id, opts = {})
333
+ if @api_client.config.debugging
334
+ @api_client.config.logger.debug 'Calling API: ProfilesApi.update_profile ...'
335
+ end
336
+ # verify the required parameter 'person_id' is set
337
+ if @api_client.config.client_side_validation && person_id.nil?
338
+ fail ArgumentError, "Missing the required parameter 'person_id' when calling ProfilesApi.update_profile"
339
+ end
340
+ # resource path
341
+ local_var_path = '/v1/person/{person_id}'.sub('{' + 'person_id' + '}', CGI.escape(person_id.to_s))
342
+
343
+ # query parameters
344
+ query_params = opts[:query_params] || {}
345
+ query_params[:'params'] = opts[:'params'] if !opts[:'params'].nil?
346
+
347
+ # header parameters
348
+ header_params = opts[:header_params] || {}
349
+ # HTTP header 'Accept' (if needed)
350
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
351
+
352
+ # form parameters
353
+ form_params = opts[:form_params] || {}
354
+
355
+ # http body (model)
356
+ post_body = opts[:body]
357
+
358
+ # return_type
359
+ return_type = opts[:debug_return_type] || 'Person'
360
+
361
+ # auth_names
362
+ auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']
363
+
364
+ new_options = opts.merge(
365
+ :operation => :"ProfilesApi.update_profile",
366
+ :header_params => header_params,
367
+ :query_params => query_params,
368
+ :form_params => form_params,
369
+ :body => post_body,
370
+ :auth_names => auth_names,
371
+ :return_type => return_type
372
+ )
373
+
374
+ data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)
375
+ if @api_client.config.debugging
376
+ @api_client.config.logger.debug "API called: ProfilesApi#update_profile\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
377
+ end
378
+ return data, status_code, headers
379
+ end
380
+ end
381
+ end