-
Notifications
You must be signed in to change notification settings - Fork 7
/
lists_api.rb
830 lines (713 loc) · 43.4 KB
/
lists_api.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
=begin
#Klaviyo API
#The Klaviyo REST API. Please visit https://developers.klaviyo.com for more details.
The version of the OpenAPI document: 2023-06-15
Contact: developers@klaviyo.com
Generated by: https://openapi-generator.tech
OpenAPI Generator version: 6.2.1
=end
require 'cgi'
module KlaviyoAPI
class ListsApi
attr_accessor :api_client
def initialize(api_client = ApiClient.default)
@api_client = api_client
end
# Create List
# Create a new list.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` **Scopes:** `list:write`
# @param list_create_query [ListCreateQuery]
# @param [Hash] opts the optional parameters
# @return [Hash<String, Object>]
def create_list(list_create_query, opts = {})
data, _status_code, _headers = create_list_with_http_info(list_create_query, opts)
data
end
# Create List
# Create a new list.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` **Scopes:** `list:write`
# @param list_create_query [ListCreateQuery]
# @param [Hash] opts the optional parameters
# @return [Array<(Hash<String, Object>, Integer, Hash)>] Hash<String, Object> data, response status code and response headers
def create_list_with_http_info(list_create_query, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: ListsApi.create_list ...'
end
# verify the required parameter 'list_create_query' is set
if @api_client.config.client_side_validation && list_create_query.nil?
fail ArgumentError, "Missing the required parameter 'list_create_query' when calling ListsApi.create_list"
end
# resource path
local_var_path = '/api/lists/'
# query parameters
query_params = opts[:query_params] || {}
# header parameters
header_params = opts[:header_params] || {}
# klaviyo api revision
header_params['revision'] = ENV['API_REVISION'] || "2023-06-15"
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
# HTTP header 'Content-Type'
content_type = @api_client.select_header_content_type(['application/json'])
if !content_type.nil?
header_params['Content-Type'] = content_type
end
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body] || @api_client.object_to_http_body(list_create_query)
# return_type
return_type = opts[:debug_return_type] || 'Hash<String, Object>'
# auth_names
auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key']
new_options = opts.merge(
:operation => :"ListsApi.create_list",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: ListsApi#create_list\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Add Profile To List
# Add a profile to a list with the given list ID. It is recommended that you use the [Subscribe Profiles endpoint](https://developers.klaviyo.com/en/reference/subscribe_profiles) if you're trying to give a profile consent to receive email marketing. This endpoint accepts a maximum of 1000 profiles per call.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` **Scopes:** `list:write` `profiles:write`
# @param id [String]
# @param list_members_add_query [ListMembersAddQuery]
# @param [Hash] opts the optional parameters
# @return [nil]
def create_list_relationships(id, list_members_add_query, opts = {})
create_list_relationships_with_http_info(id, list_members_add_query, opts)
nil
end
# Add Profile To List
# Add a profile to a list with the given list ID. It is recommended that you use the [Subscribe Profiles endpoint](https://developers.klaviyo.com/en/reference/subscribe_profiles) if you're trying to give a profile consent to receive email marketing. This endpoint accepts a maximum of 1000 profiles per call.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` **Scopes:** `list:write` `profiles:write`
# @param id [String]
# @param list_members_add_query [ListMembersAddQuery]
# @param [Hash] opts the optional parameters
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
def create_list_relationships_with_http_info(id, list_members_add_query, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: ListsApi.create_list_relationships ...'
end
# verify the required parameter 'id' is set
if @api_client.config.client_side_validation && id.nil?
fail ArgumentError, "Missing the required parameter 'id' when calling ListsApi.create_list_relationships"
end
# verify the required parameter 'list_members_add_query' is set
if @api_client.config.client_side_validation && list_members_add_query.nil?
fail ArgumentError, "Missing the required parameter 'list_members_add_query' when calling ListsApi.create_list_relationships"
end
# resource path
local_var_path = '/api/lists/{id}/relationships/profiles/'.sub('{' + 'id' + '}', CGI.escape(id.to_s))
# query parameters
query_params = opts[:query_params] || {}
# header parameters
header_params = opts[:header_params] || {}
# klaviyo api revision
header_params['revision'] = ENV['API_REVISION'] || "2023-06-15"
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
# HTTP header 'Content-Type'
content_type = @api_client.select_header_content_type(['application/json'])
if !content_type.nil?
header_params['Content-Type'] = content_type
end
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body] || @api_client.object_to_http_body(list_members_add_query)
# return_type
return_type = opts[:debug_return_type]
# auth_names
auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key']
new_options = opts.merge(
:operation => :"ListsApi.create_list_relationships",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: ListsApi#create_list_relationships\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Delete List
# Delete a list with the given list ID.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` **Scopes:** `list:write`
# @param id [String] Primary key that uniquely identifies this list. Generated by Klaviyo.
# @param [Hash] opts the optional parameters
# @return [nil]
def delete_list(id, opts = {})
delete_list_with_http_info(id, opts)
nil
end
# Delete List
# Delete a list with the given list ID.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` **Scopes:** `list:write`
# @param id [String] Primary key that uniquely identifies this list. Generated by Klaviyo.
# @param [Hash] opts the optional parameters
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
def delete_list_with_http_info(id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: ListsApi.delete_list ...'
end
# verify the required parameter 'id' is set
if @api_client.config.client_side_validation && id.nil?
fail ArgumentError, "Missing the required parameter 'id' when calling ListsApi.delete_list"
end
# resource path
local_var_path = '/api/lists/{id}/'.sub('{' + 'id' + '}', CGI.escape(id.to_s))
# query parameters
query_params = opts[:query_params] || {}
# header parameters
header_params = opts[:header_params] || {}
# klaviyo api revision
header_params['revision'] = ENV['API_REVISION'] || "2023-06-15"
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body]
# return_type
return_type = opts[:debug_return_type]
# auth_names
auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key']
new_options = opts.merge(
:operation => :"ListsApi.delete_list",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: ListsApi#delete_list\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Remove Profile From List
# Remove a profile from a list with the given list ID. The provided profile will no longer receive marketing from this particular list once removed. Removing a profile from a list will not impact the profile's consent status or subscription status in general. To update a profile's subscription status, please use the [Unsubscribe Profiles endpoint](https://developers.klaviyo.com/en/reference/unsubscribe_profiles). This endpoint accepts a maximum of 1000 profiles per call.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` **Scopes:** `list:write` `profiles:write`
# @param id [String]
# @param list_members_delete_query [ListMembersDeleteQuery]
# @param [Hash] opts the optional parameters
# @return [nil]
def delete_list_relationships(id, list_members_delete_query, opts = {})
delete_list_relationships_with_http_info(id, list_members_delete_query, opts)
nil
end
# Remove Profile From List
# Remove a profile from a list with the given list ID. The provided profile will no longer receive marketing from this particular list once removed. Removing a profile from a list will not impact the profile's consent status or subscription status in general. To update a profile's subscription status, please use the [Unsubscribe Profiles endpoint](https://developers.klaviyo.com/en/reference/unsubscribe_profiles). This endpoint accepts a maximum of 1000 profiles per call.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` **Scopes:** `list:write` `profiles:write`
# @param id [String]
# @param list_members_delete_query [ListMembersDeleteQuery]
# @param [Hash] opts the optional parameters
# @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
def delete_list_relationships_with_http_info(id, list_members_delete_query, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: ListsApi.delete_list_relationships ...'
end
# verify the required parameter 'id' is set
if @api_client.config.client_side_validation && id.nil?
fail ArgumentError, "Missing the required parameter 'id' when calling ListsApi.delete_list_relationships"
end
# verify the required parameter 'list_members_delete_query' is set
if @api_client.config.client_side_validation && list_members_delete_query.nil?
fail ArgumentError, "Missing the required parameter 'list_members_delete_query' when calling ListsApi.delete_list_relationships"
end
# resource path
local_var_path = '/api/lists/{id}/relationships/profiles/'.sub('{' + 'id' + '}', CGI.escape(id.to_s))
# query parameters
query_params = opts[:query_params] || {}
# header parameters
header_params = opts[:header_params] || {}
# klaviyo api revision
header_params['revision'] = ENV['API_REVISION'] || "2023-06-15"
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
# HTTP header 'Content-Type'
content_type = @api_client.select_header_content_type(['application/json'])
if !content_type.nil?
header_params['Content-Type'] = content_type
end
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body] || @api_client.object_to_http_body(list_members_delete_query)
# return_type
return_type = opts[:debug_return_type]
# auth_names
auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key']
new_options = opts.merge(
:operation => :"ListsApi.delete_list_relationships",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: ListsApi#delete_list_relationships\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Get List
# Get a list with the given list ID.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` **Scopes:** `list:write`
# @param id [String] Primary key that uniquely identifies this list. Generated by Klaviyo.
# @param [Hash] opts the optional parameters
# @option opts [Array<String>] :fields_list For more information please visit https://developers.klaviyo.com/en/v2023-06-15/reference/api-overview#sparse-fieldsets
# @return [Hash<String, Object>]
def get_list(id, opts = {})
data, _status_code, _headers = get_list_with_http_info(id, opts)
data
end
# Get List
# Get a list with the given list ID.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` **Scopes:** `list:write`
# @param id [String] Primary key that uniquely identifies this list. Generated by Klaviyo.
# @param [Hash] opts the optional parameters
# @option opts [Array<String>] :fields_list For more information please visit https://developers.klaviyo.com/en/v2023-06-15/reference/api-overview#sparse-fieldsets
# @return [Array<(Hash<String, Object>, Integer, Hash)>] Hash<String, Object> data, response status code and response headers
def get_list_with_http_info(id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: ListsApi.get_list ...'
end
# verify the required parameter 'id' is set
if @api_client.config.client_side_validation && id.nil?
fail ArgumentError, "Missing the required parameter 'id' when calling ListsApi.get_list"
end
allowable_values = ["name", "created", "updated"]
if @api_client.config.client_side_validation && opts[:'fields_list'] && !opts[:'fields_list'].all? { |item| allowable_values.include?(item) }
fail ArgumentError, "invalid value for \"fields_list\", must include one of #{allowable_values}"
end
# resource path
local_var_path = '/api/lists/{id}/'.sub('{' + 'id' + '}', CGI.escape(id.to_s))
# query parameters
query_params = opts[:query_params] || {}
query_params[:'fields[list]'] = @api_client.build_collection_param(opts[:'fields_list'], :csv) if !opts[:'fields_list'].nil?
# header parameters
header_params = opts[:header_params] || {}
# klaviyo api revision
header_params['revision'] = ENV['API_REVISION'] || "2023-06-15"
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body]
# return_type
return_type = opts[:debug_return_type] || 'Hash<String, Object>'
# auth_names
auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key']
new_options = opts.merge(
:operation => :"ListsApi.get_list",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: ListsApi#get_list\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Get List Profiles
# Get all profiles within a list with the given list ID. Filter to request a subset of all profiles. Profiles can be filtered by `email`, `phone_number`, and `push_token` fields.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` **Scopes:** `list:read` `profiles:read`
# @param id [String]
# @param [Hash] opts the optional parameters
# @option opts [Array<String>] :additional_fields_profile Request additional fields not included by default in the response. Supported values: 'predictive_analytics'
# @option opts [Array<String>] :fields_profile For more information please visit https://developers.klaviyo.com/en/v2023-06-15/reference/api-overview#sparse-fieldsets
# @option opts [String] :filter For more information please visit https://developers.klaviyo.com/en/v2023-06-15/reference/api-overview#filtering<br>Allowed field(s)/operator(s):<br>`email`: `any`<br>`phone_number`: `any`<br>`push_token`: `any`<br>`_kx`: `equals`
# @option opts [String] :page_cursor For more information please visit https://developers.klaviyo.com/en/v2023-06-15/reference/api-overview#pagination
# @option opts [Integer] :page_size Default: 20. Min: 1. Max: 100. (default to 20)
# @return [Hash<String, Object>]
def get_list_profiles(id, opts = {})
data, _status_code, _headers = get_list_profiles_with_http_info(id, opts)
data
end
# Get List Profiles
# Get all profiles within a list with the given list ID. Filter to request a subset of all profiles. Profiles can be filtered by `email`, `phone_number`, and `push_token` fields.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` **Scopes:** `list:read` `profiles:read`
# @param id [String]
# @param [Hash] opts the optional parameters
# @option opts [Array<String>] :additional_fields_profile Request additional fields not included by default in the response. Supported values: 'predictive_analytics'
# @option opts [Array<String>] :fields_profile For more information please visit https://developers.klaviyo.com/en/v2023-06-15/reference/api-overview#sparse-fieldsets
# @option opts [String] :filter For more information please visit https://developers.klaviyo.com/en/v2023-06-15/reference/api-overview#filtering<br>Allowed field(s)/operator(s):<br>`email`: `any`<br>`phone_number`: `any`<br>`push_token`: `any`<br>`_kx`: `equals`
# @option opts [String] :page_cursor For more information please visit https://developers.klaviyo.com/en/v2023-06-15/reference/api-overview#pagination
# @option opts [Integer] :page_size Default: 20. Min: 1. Max: 100. (default to 20)
# @return [Array<(Hash<String, Object>, Integer, Hash)>] Hash<String, Object> data, response status code and response headers
def get_list_profiles_with_http_info(id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: ListsApi.get_list_profiles ...'
end
# verify the required parameter 'id' is set
if @api_client.config.client_side_validation && id.nil?
fail ArgumentError, "Missing the required parameter 'id' when calling ListsApi.get_list_profiles"
end
allowable_values = ["predictive_analytics"]
if @api_client.config.client_side_validation && opts[:'additional_fields_profile'] && !opts[:'additional_fields_profile'].all? { |item| allowable_values.include?(item) }
fail ArgumentError, "invalid value for \"additional_fields_profile\", must include one of #{allowable_values}"
end
allowable_values = ["email", "phone_number", "external_id", "first_name", "last_name", "organization", "title", "image", "created", "updated", "last_event_date", "location", "location.address1", "location.address2", "location.city", "location.country", "location.latitude", "location.longitude", "location.region", "location.zip", "location.timezone", "properties", "subscriptions", "subscriptions.email", "subscriptions.email.marketing", "subscriptions.email.marketing.consent", "subscriptions.email.marketing.timestamp", "subscriptions.email.marketing.method", "subscriptions.email.marketing.method_detail", "subscriptions.email.marketing.custom_method_detail", "subscriptions.email.marketing.double_optin", "subscriptions.email.marketing.suppressions", "subscriptions.email.marketing.suppressions.reason", "subscriptions.email.marketing.suppressions.timestamp", "subscriptions.email.marketing.list_suppressions", "subscriptions.email.marketing.list_suppressions.list_id", "subscriptions.email.marketing.list_suppressions.reason", "subscriptions.email.marketing.list_suppressions.timestamp", "subscriptions.sms", "subscriptions.sms.marketing", "subscriptions.sms.marketing.consent", "subscriptions.sms.marketing.timestamp", "subscriptions.sms.marketing.method", "subscriptions.sms.marketing.method_detail", "predictive_analytics", "predictive_analytics.historic_clv", "predictive_analytics.predicted_clv", "predictive_analytics.total_clv", "predictive_analytics.historic_number_of_orders", "predictive_analytics.predicted_number_of_orders", "predictive_analytics.average_days_between_orders", "predictive_analytics.average_order_value", "predictive_analytics.churn_probability", "predictive_analytics.expected_date_of_next_order"]
if @api_client.config.client_side_validation && opts[:'fields_profile'] && !opts[:'fields_profile'].all? { |item| allowable_values.include?(item) }
fail ArgumentError, "invalid value for \"fields_profile\", must include one of #{allowable_values}"
end
if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] > 100
fail ArgumentError, 'invalid value for "opts[:"page_size"]" when calling ListsApi.get_list_profiles, must be smaller than or equal to 100.'
end
if @api_client.config.client_side_validation && !opts[:'page_size'].nil? && opts[:'page_size'] < 1
fail ArgumentError, 'invalid value for "opts[:"page_size"]" when calling ListsApi.get_list_profiles, must be greater than or equal to 1.'
end
# resource path
local_var_path = '/api/lists/{id}/profiles/'.sub('{' + 'id' + '}', CGI.escape(id.to_s))
# query parameters
query_params = opts[:query_params] || {}
query_params[:'additional-fields[profile]'] = @api_client.build_collection_param(opts[:'additional_fields_profile'], :csv) if !opts[:'additional_fields_profile'].nil?
query_params[:'fields[profile]'] = @api_client.build_collection_param(opts[:'fields_profile'], :csv) if !opts[:'fields_profile'].nil?
query_params[:'filter'] = opts[:'filter'] if !opts[:'filter'].nil?
query_params[:'page[cursor]'] = opts[:'page_cursor'] if !opts[:'page_cursor'].nil?
query_params[:'page[size]'] = opts[:'page_size'] if !opts[:'page_size'].nil?
# header parameters
header_params = opts[:header_params] || {}
# klaviyo api revision
header_params['revision'] = ENV['API_REVISION'] || "2023-06-15"
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body]
# return_type
return_type = opts[:debug_return_type] || 'Hash<String, Object>'
# auth_names
auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key']
new_options = opts.merge(
:operation => :"ListsApi.get_list_profiles",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: ListsApi#get_list_profiles\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Get List Relationships Profiles
# Get profile membership [relationships](https://developers.klaviyo.com/en/reference/api_overview#relationships) for a list with the given list ID.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` **Scopes:** `list:read` `profiles:read`
# @param id [String]
# @param [Hash] opts the optional parameters
# @option opts [String] :page_cursor For more information please visit https://developers.klaviyo.com/en/v2023-06-15/reference/api-overview#pagination
# @return [Hash<String, Object>]
def get_list_relationships_profiles(id, opts = {})
data, _status_code, _headers = get_list_relationships_profiles_with_http_info(id, opts)
data
end
# Get List Relationships Profiles
# Get profile membership [relationships](https://developers.klaviyo.com/en/reference/api_overview#relationships) for a list with the given list ID.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` **Scopes:** `list:read` `profiles:read`
# @param id [String]
# @param [Hash] opts the optional parameters
# @option opts [String] :page_cursor For more information please visit https://developers.klaviyo.com/en/v2023-06-15/reference/api-overview#pagination
# @return [Array<(Hash<String, Object>, Integer, Hash)>] Hash<String, Object> data, response status code and response headers
def get_list_relationships_profiles_with_http_info(id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: ListsApi.get_list_relationships_profiles ...'
end
# verify the required parameter 'id' is set
if @api_client.config.client_side_validation && id.nil?
fail ArgumentError, "Missing the required parameter 'id' when calling ListsApi.get_list_relationships_profiles"
end
# resource path
local_var_path = '/api/lists/{id}/relationships/profiles/'.sub('{' + 'id' + '}', CGI.escape(id.to_s))
# query parameters
query_params = opts[:query_params] || {}
query_params[:'page[cursor]'] = opts[:'page_cursor'] if !opts[:'page_cursor'].nil?
# header parameters
header_params = opts[:header_params] || {}
# klaviyo api revision
header_params['revision'] = ENV['API_REVISION'] || "2023-06-15"
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body]
# return_type
return_type = opts[:debug_return_type] || 'Hash<String, Object>'
# auth_names
auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key']
new_options = opts.merge(
:operation => :"ListsApi.get_list_relationships_profiles",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: ListsApi#get_list_relationships_profiles\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Get List Relationships Tags
# Returns the tag IDs of all tags associated with the given list.<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m` **Scopes:** `list:read` `tags:read`
# @param id [String]
# @param [Hash] opts the optional parameters
# @return [Hash<String, Object>]
def get_list_relationships_tags(id, opts = {})
data, _status_code, _headers = get_list_relationships_tags_with_http_info(id, opts)
data
end
# Get List Relationships Tags
# Returns the tag IDs of all tags associated with the given list.<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m` **Scopes:** `list:read` `tags:read`
# @param id [String]
# @param [Hash] opts the optional parameters
# @return [Array<(Hash<String, Object>, Integer, Hash)>] Hash<String, Object> data, response status code and response headers
def get_list_relationships_tags_with_http_info(id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: ListsApi.get_list_relationships_tags ...'
end
# verify the required parameter 'id' is set
if @api_client.config.client_side_validation && id.nil?
fail ArgumentError, "Missing the required parameter 'id' when calling ListsApi.get_list_relationships_tags"
end
# resource path
local_var_path = '/api/lists/{id}/relationships/tags/'.sub('{' + 'id' + '}', CGI.escape(id.to_s))
# query parameters
query_params = opts[:query_params] || {}
# header parameters
header_params = opts[:header_params] || {}
# klaviyo api revision
header_params['revision'] = ENV['API_REVISION'] || "2023-06-15"
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body]
# return_type
return_type = opts[:debug_return_type] || 'Hash<String, Object>'
# auth_names
auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key']
new_options = opts.merge(
:operation => :"ListsApi.get_list_relationships_tags",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: ListsApi#get_list_relationships_tags\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Get List Tags
# Return all tags associated with the given list ID.<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m` **Scopes:** `list:read` `tags:read`
# @param id [String]
# @param [Hash] opts the optional parameters
# @option opts [Array<String>] :fields_tag For more information please visit https://developers.klaviyo.com/en/v2023-06-15/reference/api-overview#sparse-fieldsets
# @return [Hash<String, Object>]
def get_list_tags(id, opts = {})
data, _status_code, _headers = get_list_tags_with_http_info(id, opts)
data
end
# Get List Tags
# Return all tags associated with the given list ID.<br><br>*Rate limits*:<br>Burst: `3/s`<br>Steady: `60/m` **Scopes:** `list:read` `tags:read`
# @param id [String]
# @param [Hash] opts the optional parameters
# @option opts [Array<String>] :fields_tag For more information please visit https://developers.klaviyo.com/en/v2023-06-15/reference/api-overview#sparse-fieldsets
# @return [Array<(Hash<String, Object>, Integer, Hash)>] Hash<String, Object> data, response status code and response headers
def get_list_tags_with_http_info(id, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: ListsApi.get_list_tags ...'
end
# verify the required parameter 'id' is set
if @api_client.config.client_side_validation && id.nil?
fail ArgumentError, "Missing the required parameter 'id' when calling ListsApi.get_list_tags"
end
allowable_values = ["name"]
if @api_client.config.client_side_validation && opts[:'fields_tag'] && !opts[:'fields_tag'].all? { |item| allowable_values.include?(item) }
fail ArgumentError, "invalid value for \"fields_tag\", must include one of #{allowable_values}"
end
# resource path
local_var_path = '/api/lists/{id}/tags/'.sub('{' + 'id' + '}', CGI.escape(id.to_s))
# query parameters
query_params = opts[:query_params] || {}
query_params[:'fields[tag]'] = @api_client.build_collection_param(opts[:'fields_tag'], :csv) if !opts[:'fields_tag'].nil?
# header parameters
header_params = opts[:header_params] || {}
# klaviyo api revision
header_params['revision'] = ENV['API_REVISION'] || "2023-06-15"
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body]
# return_type
return_type = opts[:debug_return_type] || 'Hash<String, Object>'
# auth_names
auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key']
new_options = opts.merge(
:operation => :"ListsApi.get_list_tags",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: ListsApi#get_list_tags\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Get Lists
# Get all lists in an account. Filter to request a subset of all lists. Lists can be filtered by `id`, `name`, `created`, and `updated` fields. Returns a maximum of 10 results per page.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` **Scopes:** `list:read`
# @param [Hash] opts the optional parameters
# @option opts [Array<String>] :fields_list For more information please visit https://developers.klaviyo.com/en/v2023-06-15/reference/api-overview#sparse-fieldsets
# @option opts [String] :filter For more information please visit https://developers.klaviyo.com/en/v2023-06-15/reference/api-overview#filtering<br>Allowed field(s)/operator(s):<br>`name`: `any`, `equals`<br>`id`: `any`, `equals`<br>`created`: `greater-than`<br>`updated`: `greater-than`
# @option opts [String] :page_cursor For more information please visit https://developers.klaviyo.com/en/v2023-06-15/reference/api-overview#pagination
# @return [Hash<String, Object>]
def get_lists(opts = {})
data, _status_code, _headers = get_lists_with_http_info(opts)
data
end
# Get Lists
# Get all lists in an account. Filter to request a subset of all lists. Lists can be filtered by `id`, `name`, `created`, and `updated` fields. Returns a maximum of 10 results per page.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` **Scopes:** `list:read`
# @param [Hash] opts the optional parameters
# @option opts [Array<String>] :fields_list For more information please visit https://developers.klaviyo.com/en/v2023-06-15/reference/api-overview#sparse-fieldsets
# @option opts [String] :filter For more information please visit https://developers.klaviyo.com/en/v2023-06-15/reference/api-overview#filtering<br>Allowed field(s)/operator(s):<br>`name`: `any`, `equals`<br>`id`: `any`, `equals`<br>`created`: `greater-than`<br>`updated`: `greater-than`
# @option opts [String] :page_cursor For more information please visit https://developers.klaviyo.com/en/v2023-06-15/reference/api-overview#pagination
# @return [Array<(Hash<String, Object>, Integer, Hash)>] Hash<String, Object> data, response status code and response headers
def get_lists_with_http_info(opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: ListsApi.get_lists ...'
end
allowable_values = ["name", "created", "updated"]
if @api_client.config.client_side_validation && opts[:'fields_list'] && !opts[:'fields_list'].all? { |item| allowable_values.include?(item) }
fail ArgumentError, "invalid value for \"fields_list\", must include one of #{allowable_values}"
end
# resource path
local_var_path = '/api/lists/'
# query parameters
query_params = opts[:query_params] || {}
query_params[:'fields[list]'] = @api_client.build_collection_param(opts[:'fields_list'], :csv) if !opts[:'fields_list'].nil?
query_params[:'filter'] = opts[:'filter'] if !opts[:'filter'].nil?
query_params[:'page[cursor]'] = opts[:'page_cursor'] if !opts[:'page_cursor'].nil?
# header parameters
header_params = opts[:header_params] || {}
# klaviyo api revision
header_params['revision'] = ENV['API_REVISION'] || "2023-06-15"
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body]
# return_type
return_type = opts[:debug_return_type] || 'Hash<String, Object>'
# auth_names
auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key']
new_options = opts.merge(
:operation => :"ListsApi.get_lists",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: ListsApi#get_lists\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
# Update List
# Update the name of a list with the given list ID.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` **Scopes:** `list:write`
# @param id [String] Primary key that uniquely identifies this list. Generated by Klaviyo.
# @param list_partial_update_query [ListPartialUpdateQuery]
# @param [Hash] opts the optional parameters
# @return [Hash<String, Object>]
def update_list(id, list_partial_update_query, opts = {})
data, _status_code, _headers = update_list_with_http_info(id, list_partial_update_query, opts)
data
end
# Update List
# Update the name of a list with the given list ID.<br><br>*Rate limits*:<br>Burst: `10/s`<br>Steady: `150/m` **Scopes:** `list:write`
# @param id [String] Primary key that uniquely identifies this list. Generated by Klaviyo.
# @param list_partial_update_query [ListPartialUpdateQuery]
# @param [Hash] opts the optional parameters
# @return [Array<(Hash<String, Object>, Integer, Hash)>] Hash<String, Object> data, response status code and response headers
def update_list_with_http_info(id, list_partial_update_query, opts = {})
if @api_client.config.debugging
@api_client.config.logger.debug 'Calling API: ListsApi.update_list ...'
end
# verify the required parameter 'id' is set
if @api_client.config.client_side_validation && id.nil?
fail ArgumentError, "Missing the required parameter 'id' when calling ListsApi.update_list"
end
# verify the required parameter 'list_partial_update_query' is set
if @api_client.config.client_side_validation && list_partial_update_query.nil?
fail ArgumentError, "Missing the required parameter 'list_partial_update_query' when calling ListsApi.update_list"
end
# resource path
local_var_path = '/api/lists/{id}/'.sub('{' + 'id' + '}', CGI.escape(id.to_s))
# query parameters
query_params = opts[:query_params] || {}
# header parameters
header_params = opts[:header_params] || {}
# klaviyo api revision
header_params['revision'] = ENV['API_REVISION'] || "2023-06-15"
# HTTP header 'Accept' (if needed)
header_params['Accept'] = @api_client.select_header_accept(['application/json'])
# HTTP header 'Content-Type'
content_type = @api_client.select_header_content_type(['application/json'])
if !content_type.nil?
header_params['Content-Type'] = content_type
end
# form parameters
form_params = opts[:form_params] || {}
# http body (model)
post_body = opts[:debug_body] || @api_client.object_to_http_body(list_partial_update_query)
# return_type
return_type = opts[:debug_return_type] || 'Hash<String, Object>'
# auth_names
auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key']
new_options = opts.merge(
:operation => :"ListsApi.update_list",
:header_params => header_params,
:query_params => query_params,
:form_params => form_params,
:body => post_body,
:auth_names => auth_names,
:return_type => return_type
)
data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options)
if @api_client.config.debugging
@api_client.config.logger.debug "API called: ListsApi#update_list\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
end
return data, status_code, headers
end
end
end