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,717 @@
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 CampaignsApi
17
+ attr_accessor :api_client
18
+
19
+ def initialize(api_client = ApiClient.default)
20
+ @api_client = api_client
21
+ end
22
+ # Cancel a Campaign
23
+ # Cancels a campaign send. Marks a campaign as cancelled regardless of it's current status.
24
+ # @param campaign_id [String]
25
+ # @param [Hash] opts the optional parameters
26
+ # @return [Campaign]
27
+ def cancel_campaign(campaign_id, opts = {})
28
+ data, _status_code, _headers = cancel_campaign_with_http_info(campaign_id, opts)
29
+ data
30
+ end
31
+
32
+ # Cancel a Campaign
33
+ # Cancels a campaign send. Marks a campaign as cancelled regardless of it's current status.
34
+ # @param campaign_id [String]
35
+ # @param [Hash] opts the optional parameters
36
+ # @return [Array<(Campaign, Integer, Hash)>] Campaign data, response status code and response headers
37
+ def cancel_campaign_with_http_info(campaign_id, opts = {})
38
+ if @api_client.config.debugging
39
+ @api_client.config.logger.debug 'Calling API: CampaignsApi.cancel_campaign ...'
40
+ end
41
+ # verify the required parameter 'campaign_id' is set
42
+ if @api_client.config.client_side_validation && campaign_id.nil?
43
+ fail ArgumentError, "Missing the required parameter 'campaign_id' when calling CampaignsApi.cancel_campaign"
44
+ end
45
+ # resource path
46
+ local_var_path = '/v1/campaign/{campaign_id}/cancel'.sub('{' + 'campaign_id' + '}', CGI.escape(campaign_id.to_s))
47
+
48
+ # query parameters
49
+ query_params = opts[:query_params] || {}
50
+
51
+ # header parameters
52
+ header_params = opts[:header_params] || {}
53
+ # HTTP header 'Accept' (if needed)
54
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
55
+
56
+ # form parameters
57
+ form_params = opts[:form_params] || {}
58
+
59
+ # http body (model)
60
+ post_body = opts[:body]
61
+
62
+ # return_type
63
+ return_type = opts[:debug_return_type] || 'Campaign'
64
+
65
+ # auth_names
66
+ auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']
67
+
68
+ new_options = opts.merge(
69
+ :operation => :"CampaignsApi.cancel_campaign",
70
+ :header_params => header_params,
71
+ :query_params => query_params,
72
+ :form_params => form_params,
73
+ :body => post_body,
74
+ :auth_names => auth_names,
75
+ :return_type => return_type
76
+ )
77
+
78
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
79
+ if @api_client.config.debugging
80
+ @api_client.config.logger.debug "API called: CampaignsApi#cancel_campaign\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
81
+ end
82
+ return data, status_code, headers
83
+ end
84
+
85
+ # Clone a Campaign
86
+ # Creates a copy of a campaign. The new campaign starts as a draft.
87
+ # @param campaign_id [String]
88
+ # @param name [String] The name for the new campaign. All other properties of the campaign will remain the same. Note, the template for the new campaign will be cloned from the existing template so changes to the existing campaign&#39;s content will not alter the content of the new campaign.
89
+ # @param list_id [String] The list you will send the campaign to.
90
+ # @param [Hash] opts the optional parameters
91
+ # @return [Campaign]
92
+ def clone_campaign(campaign_id, name, list_id, opts = {})
93
+ data, _status_code, _headers = clone_campaign_with_http_info(campaign_id, name, list_id, opts)
94
+ data
95
+ end
96
+
97
+ # Clone a Campaign
98
+ # Creates a copy of a campaign. The new campaign starts as a draft.
99
+ # @param campaign_id [String]
100
+ # @param name [String] The name for the new campaign. All other properties of the campaign will remain the same. Note, the template for the new campaign will be cloned from the existing template so changes to the existing campaign&#39;s content will not alter the content of the new campaign.
101
+ # @param list_id [String] The list you will send the campaign to.
102
+ # @param [Hash] opts the optional parameters
103
+ # @return [Array<(Campaign, Integer, Hash)>] Campaign data, response status code and response headers
104
+ def clone_campaign_with_http_info(campaign_id, name, list_id, opts = {})
105
+ if @api_client.config.debugging
106
+ @api_client.config.logger.debug 'Calling API: CampaignsApi.clone_campaign ...'
107
+ end
108
+ # verify the required parameter 'campaign_id' is set
109
+ if @api_client.config.client_side_validation && campaign_id.nil?
110
+ fail ArgumentError, "Missing the required parameter 'campaign_id' when calling CampaignsApi.clone_campaign"
111
+ end
112
+ # verify the required parameter 'name' is set
113
+ if @api_client.config.client_side_validation && name.nil?
114
+ fail ArgumentError, "Missing the required parameter 'name' when calling CampaignsApi.clone_campaign"
115
+ end
116
+ # verify the required parameter 'list_id' is set
117
+ if @api_client.config.client_side_validation && list_id.nil?
118
+ fail ArgumentError, "Missing the required parameter 'list_id' when calling CampaignsApi.clone_campaign"
119
+ end
120
+ # resource path
121
+ local_var_path = '/v1/campaign/{campaign_id}/clone'.sub('{' + 'campaign_id' + '}', CGI.escape(campaign_id.to_s))
122
+
123
+ # query parameters
124
+ query_params = opts[:query_params] || {}
125
+
126
+ # header parameters
127
+ header_params = opts[:header_params] || {}
128
+ # HTTP header 'Accept' (if needed)
129
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
130
+ # HTTP header 'Content-Type'
131
+ content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded'])
132
+ if !content_type.nil?
133
+ header_params['Content-Type'] = content_type
134
+ end
135
+
136
+ # form parameters
137
+ form_params = opts[:form_params] || {}
138
+ form_params['name'] = name
139
+ form_params['list_id'] = list_id
140
+
141
+ # http body (model)
142
+ post_body = opts[:body]
143
+
144
+ # return_type
145
+ return_type = opts[:debug_return_type] || 'Campaign'
146
+
147
+ # auth_names
148
+ auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']
149
+
150
+ new_options = opts.merge(
151
+ :operation => :"CampaignsApi.clone_campaign",
152
+ :header_params => header_params,
153
+ :query_params => query_params,
154
+ :form_params => form_params,
155
+ :body => post_body,
156
+ :auth_names => auth_names,
157
+ :return_type => return_type
158
+ )
159
+
160
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
161
+ if @api_client.config.debugging
162
+ @api_client.config.logger.debug "API called: CampaignsApi#clone_campaign\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
163
+ end
164
+ return data, status_code, headers
165
+ end
166
+
167
+ # Create New Campaign
168
+ # Creates a new campaign. The created campaign is a draft and is not automatically sent.
169
+ # @param list_id [String] The list you will send the campaign to.
170
+ # @param template_id [String] The template that will define the content of the page. Note: the Email Template is copied when creating this campaign, so future changes to that Email Template will not alter the content of this campaign.
171
+ # @param from_email [String] The email address your email will be sent from and will be used in the &#x60;reply-to&#x60; header.
172
+ # @param from_name [String] The name or label associated with the email address you&#39;re sending from.
173
+ # @param subject [String] The email subject of the campaign
174
+ # @param [Hash] opts the optional parameters
175
+ # @option opts [String] :name If not specified, this will default to the subject of the campaign. (default to 'Campaign Name')
176
+ # @option opts [Boolean] :use_smart_sending If set, limits the number of emails sent to an individual within a short period. Valid values are &#x60;true&#x60; and &#x60;false&#x60;. If not specified, defaults to &#x60;true&#x60;. (default to true)
177
+ # @option opts [Boolean] :add_google_analytics If specified, adds Google Analytics tracking tags to links. Valid values are &#x60;true&#x60; and &#x60;false&#x60;. If not specified, defaults to &#x60;false&#x60;. (default to false)
178
+ # @return [Campaign]
179
+ def create_campaign(list_id, template_id, from_email, from_name, subject, opts = {})
180
+ data, _status_code, _headers = create_campaign_with_http_info(list_id, template_id, from_email, from_name, subject, opts)
181
+ data
182
+ end
183
+
184
+ # Create New Campaign
185
+ # Creates a new campaign. The created campaign is a draft and is not automatically sent.
186
+ # @param list_id [String] The list you will send the campaign to.
187
+ # @param template_id [String] The template that will define the content of the page. Note: the Email Template is copied when creating this campaign, so future changes to that Email Template will not alter the content of this campaign.
188
+ # @param from_email [String] The email address your email will be sent from and will be used in the &#x60;reply-to&#x60; header.
189
+ # @param from_name [String] The name or label associated with the email address you&#39;re sending from.
190
+ # @param subject [String] The email subject of the campaign
191
+ # @param [Hash] opts the optional parameters
192
+ # @option opts [String] :name If not specified, this will default to the subject of the campaign.
193
+ # @option opts [Boolean] :use_smart_sending If set, limits the number of emails sent to an individual within a short period. Valid values are &#x60;true&#x60; and &#x60;false&#x60;. If not specified, defaults to &#x60;true&#x60;.
194
+ # @option opts [Boolean] :add_google_analytics If specified, adds Google Analytics tracking tags to links. Valid values are &#x60;true&#x60; and &#x60;false&#x60;. If not specified, defaults to &#x60;false&#x60;.
195
+ # @return [Array<(Campaign, Integer, Hash)>] Campaign data, response status code and response headers
196
+ def create_campaign_with_http_info(list_id, template_id, from_email, from_name, subject, opts = {})
197
+ if @api_client.config.debugging
198
+ @api_client.config.logger.debug 'Calling API: CampaignsApi.create_campaign ...'
199
+ end
200
+ # verify the required parameter 'list_id' is set
201
+ if @api_client.config.client_side_validation && list_id.nil?
202
+ fail ArgumentError, "Missing the required parameter 'list_id' when calling CampaignsApi.create_campaign"
203
+ end
204
+ # verify the required parameter 'template_id' is set
205
+ if @api_client.config.client_side_validation && template_id.nil?
206
+ fail ArgumentError, "Missing the required parameter 'template_id' when calling CampaignsApi.create_campaign"
207
+ end
208
+ # verify the required parameter 'from_email' is set
209
+ if @api_client.config.client_side_validation && from_email.nil?
210
+ fail ArgumentError, "Missing the required parameter 'from_email' when calling CampaignsApi.create_campaign"
211
+ end
212
+ # verify the required parameter 'from_name' is set
213
+ if @api_client.config.client_side_validation && from_name.nil?
214
+ fail ArgumentError, "Missing the required parameter 'from_name' when calling CampaignsApi.create_campaign"
215
+ end
216
+ # verify the required parameter 'subject' is set
217
+ if @api_client.config.client_side_validation && subject.nil?
218
+ fail ArgumentError, "Missing the required parameter 'subject' when calling CampaignsApi.create_campaign"
219
+ end
220
+ # resource path
221
+ local_var_path = '/v1/campaigns'
222
+
223
+ # query parameters
224
+ query_params = opts[:query_params] || {}
225
+
226
+ # header parameters
227
+ header_params = opts[:header_params] || {}
228
+ # HTTP header 'Accept' (if needed)
229
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
230
+ # HTTP header 'Content-Type'
231
+ content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded'])
232
+ if !content_type.nil?
233
+ header_params['Content-Type'] = content_type
234
+ end
235
+
236
+ # form parameters
237
+ form_params = opts[:form_params] || {}
238
+ form_params['list_id'] = list_id
239
+ form_params['template_id'] = template_id
240
+ form_params['from_email'] = from_email
241
+ form_params['from_name'] = from_name
242
+ form_params['subject'] = subject
243
+ form_params['name'] = opts[:'name'] if !opts[:'name'].nil?
244
+ form_params['use_smart_sending'] = opts[:'use_smart_sending'] if !opts[:'use_smart_sending'].nil?
245
+ form_params['add_google_analytics'] = opts[:'add_google_analytics'] if !opts[:'add_google_analytics'].nil?
246
+
247
+ # http body (model)
248
+ post_body = opts[:body]
249
+
250
+ # return_type
251
+ return_type = opts[:debug_return_type] || 'Campaign'
252
+
253
+ # auth_names
254
+ auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']
255
+
256
+ new_options = opts.merge(
257
+ :operation => :"CampaignsApi.create_campaign",
258
+ :header_params => header_params,
259
+ :query_params => query_params,
260
+ :form_params => form_params,
261
+ :body => post_body,
262
+ :auth_names => auth_names,
263
+ :return_type => return_type
264
+ )
265
+
266
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
267
+ if @api_client.config.debugging
268
+ @api_client.config.logger.debug "API called: CampaignsApi#create_campaign\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
269
+ end
270
+ return data, status_code, headers
271
+ end
272
+
273
+ # Get Campaign Info
274
+ # Returns summary information for the campaign specified.
275
+ # @param campaign_id [String]
276
+ # @param [Hash] opts the optional parameters
277
+ # @return [Campaign]
278
+ def get_campaign_info(campaign_id, opts = {})
279
+ data, _status_code, _headers = get_campaign_info_with_http_info(campaign_id, opts)
280
+ data
281
+ end
282
+
283
+ # Get Campaign Info
284
+ # Returns summary information for the campaign specified.
285
+ # @param campaign_id [String]
286
+ # @param [Hash] opts the optional parameters
287
+ # @return [Array<(Campaign, Integer, Hash)>] Campaign data, response status code and response headers
288
+ def get_campaign_info_with_http_info(campaign_id, opts = {})
289
+ if @api_client.config.debugging
290
+ @api_client.config.logger.debug 'Calling API: CampaignsApi.get_campaign_info ...'
291
+ end
292
+ # verify the required parameter 'campaign_id' is set
293
+ if @api_client.config.client_side_validation && campaign_id.nil?
294
+ fail ArgumentError, "Missing the required parameter 'campaign_id' when calling CampaignsApi.get_campaign_info"
295
+ end
296
+ # resource path
297
+ local_var_path = '/v1/campaign/{campaign_id}'.sub('{' + 'campaign_id' + '}', CGI.escape(campaign_id.to_s))
298
+
299
+ # query parameters
300
+ query_params = opts[:query_params] || {}
301
+
302
+ # header parameters
303
+ header_params = opts[:header_params] || {}
304
+ # HTTP header 'Accept' (if needed)
305
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
306
+
307
+ # form parameters
308
+ form_params = opts[:form_params] || {}
309
+
310
+ # http body (model)
311
+ post_body = opts[:body]
312
+
313
+ # return_type
314
+ return_type = opts[:debug_return_type] || 'Campaign'
315
+
316
+ # auth_names
317
+ auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']
318
+
319
+ new_options = opts.merge(
320
+ :operation => :"CampaignsApi.get_campaign_info",
321
+ :header_params => header_params,
322
+ :query_params => query_params,
323
+ :form_params => form_params,
324
+ :body => post_body,
325
+ :auth_names => auth_names,
326
+ :return_type => return_type
327
+ )
328
+
329
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
330
+ if @api_client.config.debugging
331
+ @api_client.config.logger.debug "API called: CampaignsApi#get_campaign_info\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
332
+ end
333
+ return data, status_code, headers
334
+ end
335
+
336
+ # Get Campaign Recipients
337
+ # Returns summary information about email recipients for the campaign specified that includes each recipients email, customer ID, and status.
338
+ # @param campaign_id [String]
339
+ # @param [Hash] opts the optional parameters
340
+ # @option opts [Integer] :count For pagination, the number of results to return. Max &#x3D; 25,000 (default to 5000)
341
+ # @option opts [String] :sort Sort order to apply to results, either ascending or descending. Valid values are &#x60;asc&#x60; or &#x60;desc&#x60;. Defaults to &#x60;asc&#x60;. (default to 'asc')
342
+ # @option opts [String] :offset For pagination, if a response to this endpoint includes a &#x60;next_offset&#x60;, use that value to get the next page of recipients.
343
+ # @return [Hash<String, Object>]
344
+ def get_campaign_recipients(campaign_id, opts = {})
345
+ data, _status_code, _headers = get_campaign_recipients_with_http_info(campaign_id, opts)
346
+ data
347
+ end
348
+
349
+ # Get Campaign Recipients
350
+ # Returns summary information about email recipients for the campaign specified that includes each recipients email, customer ID, and status.
351
+ # @param campaign_id [String]
352
+ # @param [Hash] opts the optional parameters
353
+ # @option opts [Integer] :count For pagination, the number of results to return. Max &#x3D; 25,000
354
+ # @option opts [String] :sort Sort order to apply to results, either ascending or descending. Valid values are &#x60;asc&#x60; or &#x60;desc&#x60;. Defaults to &#x60;asc&#x60;.
355
+ # @option opts [String] :offset For pagination, if a response to this endpoint includes a &#x60;next_offset&#x60;, use that value to get the next page of recipients.
356
+ # @return [Array<(Hash<String, Object>, Integer, Hash)>] Hash<String, Object> data, response status code and response headers
357
+ def get_campaign_recipients_with_http_info(campaign_id, opts = {})
358
+ if @api_client.config.debugging
359
+ @api_client.config.logger.debug 'Calling API: CampaignsApi.get_campaign_recipients ...'
360
+ end
361
+ # verify the required parameter 'campaign_id' is set
362
+ if @api_client.config.client_side_validation && campaign_id.nil?
363
+ fail ArgumentError, "Missing the required parameter 'campaign_id' when calling CampaignsApi.get_campaign_recipients"
364
+ end
365
+ if @api_client.config.client_side_validation && !opts[:'count'].nil? && opts[:'count'] > 25000
366
+ fail ArgumentError, 'invalid value for "opts[:"count"]" when calling CampaignsApi.get_campaign_recipients, must be smaller than or equal to 25000.'
367
+ end
368
+
369
+ # resource path
370
+ local_var_path = '/v1/campaign/{campaign_id}/recipients'.sub('{' + 'campaign_id' + '}', CGI.escape(campaign_id.to_s))
371
+
372
+ # query parameters
373
+ query_params = opts[:query_params] || {}
374
+ query_params[:'count'] = opts[:'count'] if !opts[:'count'].nil?
375
+ query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?
376
+ query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?
377
+
378
+ # header parameters
379
+ header_params = opts[:header_params] || {}
380
+ # HTTP header 'Accept' (if needed)
381
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
382
+
383
+ # form parameters
384
+ form_params = opts[:form_params] || {}
385
+
386
+ # http body (model)
387
+ post_body = opts[:body]
388
+
389
+ # return_type
390
+ return_type = opts[:debug_return_type] || 'Hash<String, Object>'
391
+
392
+ # auth_names
393
+ auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']
394
+
395
+ new_options = opts.merge(
396
+ :operation => :"CampaignsApi.get_campaign_recipients",
397
+ :header_params => header_params,
398
+ :query_params => query_params,
399
+ :form_params => form_params,
400
+ :body => post_body,
401
+ :auth_names => auth_names,
402
+ :return_type => return_type
403
+ )
404
+
405
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
406
+ if @api_client.config.debugging
407
+ @api_client.config.logger.debug "API called: CampaignsApi#get_campaign_recipients\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
408
+ end
409
+ return data, status_code, headers
410
+ end
411
+
412
+ # Get Campaigns
413
+ # Returns a list of all the campaigns you've created. The campaigns are returned in reverse sorted order by the time they were created.
414
+ # @param [Hash] opts the optional parameters
415
+ # @option opts [Integer] :page For pagination, which page of results to return. Default &#x3D; 0 (default to 0)
416
+ # @option opts [Integer] :count For pagination, the number of results to return. Max &#x3D; 100 (default to 50)
417
+ # @return [Hash<String, Object>]
418
+ def get_campaigns(opts = {})
419
+ data, _status_code, _headers = get_campaigns_with_http_info(opts)
420
+ data
421
+ end
422
+
423
+ # Get Campaigns
424
+ # Returns a list of all the campaigns you&#39;ve created. The campaigns are returned in reverse sorted order by the time they were created.
425
+ # @param [Hash] opts the optional parameters
426
+ # @option opts [Integer] :page For pagination, which page of results to return. Default &#x3D; 0
427
+ # @option opts [Integer] :count For pagination, the number of results to return. Max &#x3D; 100
428
+ # @return [Array<(Hash<String, Object>, Integer, Hash)>] Hash<String, Object> data, response status code and response headers
429
+ def get_campaigns_with_http_info(opts = {})
430
+ if @api_client.config.debugging
431
+ @api_client.config.logger.debug 'Calling API: CampaignsApi.get_campaigns ...'
432
+ end
433
+ if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] < 0
434
+ fail ArgumentError, 'invalid value for "opts[:"page"]" when calling CampaignsApi.get_campaigns, must be greater than or equal to 0.'
435
+ end
436
+
437
+ if @api_client.config.client_side_validation && !opts[:'count'].nil? && opts[:'count'] > 100
438
+ fail ArgumentError, 'invalid value for "opts[:"count"]" when calling CampaignsApi.get_campaigns, must be smaller than or equal to 100.'
439
+ end
440
+
441
+ if @api_client.config.client_side_validation && !opts[:'count'].nil? && opts[:'count'] < 1
442
+ fail ArgumentError, 'invalid value for "opts[:"count"]" when calling CampaignsApi.get_campaigns, must be greater than or equal to 1.'
443
+ end
444
+
445
+ # resource path
446
+ local_var_path = '/v1/campaigns'
447
+
448
+ # query parameters
449
+ query_params = opts[:query_params] || {}
450
+ query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
451
+ query_params[:'count'] = opts[:'count'] if !opts[:'count'].nil?
452
+
453
+ # header parameters
454
+ header_params = opts[:header_params] || {}
455
+ # HTTP header 'Accept' (if needed)
456
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
457
+
458
+ # form parameters
459
+ form_params = opts[:form_params] || {}
460
+
461
+ # http body (model)
462
+ post_body = opts[:body]
463
+
464
+ # return_type
465
+ return_type = opts[:debug_return_type] || 'Hash<String, Object>'
466
+
467
+ # auth_names
468
+ auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']
469
+
470
+ new_options = opts.merge(
471
+ :operation => :"CampaignsApi.get_campaigns",
472
+ :header_params => header_params,
473
+ :query_params => query_params,
474
+ :form_params => form_params,
475
+ :body => post_body,
476
+ :auth_names => auth_names,
477
+ :return_type => return_type
478
+ )
479
+
480
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
481
+ if @api_client.config.debugging
482
+ @api_client.config.logger.debug "API called: CampaignsApi#get_campaigns\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
483
+ end
484
+ return data, status_code, headers
485
+ end
486
+
487
+ # Schedule a Campaign
488
+ # Schedules a campaign for a time in the future
489
+ # @param campaign_id [String]
490
+ # @param send_time [String] A timestamp of the format &#x60;%Y-%m-%d %H:%M:%S&#x60; in the UTC timezone. Ex: &#x60;2022-01-13 00:00:00&#x60;
491
+ # @param [Hash] opts the optional parameters
492
+ # @return [Hash<String, Object>]
493
+ def schedule_campaign(campaign_id, send_time, opts = {})
494
+ data, _status_code, _headers = schedule_campaign_with_http_info(campaign_id, send_time, opts)
495
+ data
496
+ end
497
+
498
+ # Schedule a Campaign
499
+ # Schedules a campaign for a time in the future
500
+ # @param campaign_id [String]
501
+ # @param send_time [String] A timestamp of the format &#x60;%Y-%m-%d %H:%M:%S&#x60; in the UTC timezone. Ex: &#x60;2022-01-13 00:00:00&#x60;
502
+ # @param [Hash] opts the optional parameters
503
+ # @return [Array<(Hash<String, Object>, Integer, Hash)>] Hash<String, Object> data, response status code and response headers
504
+ def schedule_campaign_with_http_info(campaign_id, send_time, opts = {})
505
+ if @api_client.config.debugging
506
+ @api_client.config.logger.debug 'Calling API: CampaignsApi.schedule_campaign ...'
507
+ end
508
+ # verify the required parameter 'campaign_id' is set
509
+ if @api_client.config.client_side_validation && campaign_id.nil?
510
+ fail ArgumentError, "Missing the required parameter 'campaign_id' when calling CampaignsApi.schedule_campaign"
511
+ end
512
+ # verify the required parameter 'send_time' is set
513
+ if @api_client.config.client_side_validation && send_time.nil?
514
+ fail ArgumentError, "Missing the required parameter 'send_time' when calling CampaignsApi.schedule_campaign"
515
+ end
516
+ # resource path
517
+ local_var_path = '/v1/campaign/{campaign_id}/schedule'.sub('{' + 'campaign_id' + '}', CGI.escape(campaign_id.to_s))
518
+
519
+ # query parameters
520
+ query_params = opts[:query_params] || {}
521
+
522
+ # header parameters
523
+ header_params = opts[:header_params] || {}
524
+ # HTTP header 'Accept' (if needed)
525
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
526
+ # HTTP header 'Content-Type'
527
+ content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded'])
528
+ if !content_type.nil?
529
+ header_params['Content-Type'] = content_type
530
+ end
531
+
532
+ # form parameters
533
+ form_params = opts[:form_params] || {}
534
+ form_params['send_time'] = send_time
535
+
536
+ # http body (model)
537
+ post_body = opts[:body]
538
+
539
+ # return_type
540
+ return_type = opts[:debug_return_type] || 'Hash<String, Object>'
541
+
542
+ # auth_names
543
+ auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']
544
+
545
+ new_options = opts.merge(
546
+ :operation => :"CampaignsApi.schedule_campaign",
547
+ :header_params => header_params,
548
+ :query_params => query_params,
549
+ :form_params => form_params,
550
+ :body => post_body,
551
+ :auth_names => auth_names,
552
+ :return_type => return_type
553
+ )
554
+
555
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
556
+ if @api_client.config.debugging
557
+ @api_client.config.logger.debug "API called: CampaignsApi#schedule_campaign\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
558
+ end
559
+ return data, status_code, headers
560
+ end
561
+
562
+ # Send a Campaign Immediately
563
+ # Queues a campaign for immediate delivery
564
+ # @param campaign_id [String]
565
+ # @param [Hash] opts the optional parameters
566
+ # @return [Hash<String, Object>]
567
+ def send_campaign(campaign_id, opts = {})
568
+ data, _status_code, _headers = send_campaign_with_http_info(campaign_id, opts)
569
+ data
570
+ end
571
+
572
+ # Send a Campaign Immediately
573
+ # Queues a campaign for immediate delivery
574
+ # @param campaign_id [String]
575
+ # @param [Hash] opts the optional parameters
576
+ # @return [Array<(Hash<String, Object>, Integer, Hash)>] Hash<String, Object> data, response status code and response headers
577
+ def send_campaign_with_http_info(campaign_id, opts = {})
578
+ if @api_client.config.debugging
579
+ @api_client.config.logger.debug 'Calling API: CampaignsApi.send_campaign ...'
580
+ end
581
+ # verify the required parameter 'campaign_id' is set
582
+ if @api_client.config.client_side_validation && campaign_id.nil?
583
+ fail ArgumentError, "Missing the required parameter 'campaign_id' when calling CampaignsApi.send_campaign"
584
+ end
585
+ # resource path
586
+ local_var_path = '/v1/campaign/{campaign_id}/send'.sub('{' + 'campaign_id' + '}', CGI.escape(campaign_id.to_s))
587
+
588
+ # query parameters
589
+ query_params = opts[:query_params] || {}
590
+
591
+ # header parameters
592
+ header_params = opts[:header_params] || {}
593
+ # HTTP header 'Accept' (if needed)
594
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
595
+
596
+ # form parameters
597
+ form_params = opts[:form_params] || {}
598
+
599
+ # http body (model)
600
+ post_body = opts[:body]
601
+
602
+ # return_type
603
+ return_type = opts[:debug_return_type] || 'Hash<String, Object>'
604
+
605
+ # auth_names
606
+ auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']
607
+
608
+ new_options = opts.merge(
609
+ :operation => :"CampaignsApi.send_campaign",
610
+ :header_params => header_params,
611
+ :query_params => query_params,
612
+ :form_params => form_params,
613
+ :body => post_body,
614
+ :auth_names => auth_names,
615
+ :return_type => return_type
616
+ )
617
+
618
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
619
+ if @api_client.config.debugging
620
+ @api_client.config.logger.debug "API called: CampaignsApi#send_campaign\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
621
+ end
622
+ return data, status_code, headers
623
+ end
624
+
625
+ # Update Campaign
626
+ # Updates details of a campaign. You can update a campaign's name, subject, from email address, from name, template or list.
627
+ # @param campaign_id [String]
628
+ # @param [Hash] opts the optional parameters
629
+ # @option opts [String] :list_id The list you will send the campaign to.
630
+ # @option opts [String] :template_id The ID of the Email Template object that will be the content of this campaign. Note the Email Template is copied when creating this campaign, so future changes to that Email Template will not alter the content of this campaign.
631
+ # @option opts [String] :from_email The email address your email will be sent from and will be used in the reply-to header.
632
+ # @option opts [String] :from_name The name or label associated with the email address you&#39;re sending from.
633
+ # @option opts [String] :subject The email subject of the campaign
634
+ # @option opts [String] :name A name for this campaign. If not specified, this will default to the subject of the campaign.
635
+ # @option opts [Boolean] :use_smart_sending If set, limits the number of emails sent to an individual within a short period. Campaigns initially default to &#x60;true&#x60;.
636
+ # @option opts [Boolean] :add_google_analytics If specified, adds Google Analytics tracking tags to links. Campaigns initially default to &#x60;false&#x60;.
637
+ # @return [Campaign]
638
+ def update_campaign(campaign_id, opts = {})
639
+ data, _status_code, _headers = update_campaign_with_http_info(campaign_id, opts)
640
+ data
641
+ end
642
+
643
+ # Update Campaign
644
+ # Updates details of a campaign. You can update a campaign&#39;s name, subject, from email address, from name, template or list.
645
+ # @param campaign_id [String]
646
+ # @param [Hash] opts the optional parameters
647
+ # @option opts [String] :list_id The list you will send the campaign to.
648
+ # @option opts [String] :template_id The ID of the Email Template object that will be the content of this campaign. Note the Email Template is copied when creating this campaign, so future changes to that Email Template will not alter the content of this campaign.
649
+ # @option opts [String] :from_email The email address your email will be sent from and will be used in the reply-to header.
650
+ # @option opts [String] :from_name The name or label associated with the email address you&#39;re sending from.
651
+ # @option opts [String] :subject The email subject of the campaign
652
+ # @option opts [String] :name A name for this campaign. If not specified, this will default to the subject of the campaign.
653
+ # @option opts [Boolean] :use_smart_sending If set, limits the number of emails sent to an individual within a short period. Campaigns initially default to &#x60;true&#x60;.
654
+ # @option opts [Boolean] :add_google_analytics If specified, adds Google Analytics tracking tags to links. Campaigns initially default to &#x60;false&#x60;.
655
+ # @return [Array<(Campaign, Integer, Hash)>] Campaign data, response status code and response headers
656
+ def update_campaign_with_http_info(campaign_id, opts = {})
657
+ if @api_client.config.debugging
658
+ @api_client.config.logger.debug 'Calling API: CampaignsApi.update_campaign ...'
659
+ end
660
+ # verify the required parameter 'campaign_id' is set
661
+ if @api_client.config.client_side_validation && campaign_id.nil?
662
+ fail ArgumentError, "Missing the required parameter 'campaign_id' when calling CampaignsApi.update_campaign"
663
+ end
664
+ # resource path
665
+ local_var_path = '/v1/campaign/{campaign_id}'.sub('{' + 'campaign_id' + '}', CGI.escape(campaign_id.to_s))
666
+
667
+ # query parameters
668
+ query_params = opts[:query_params] || {}
669
+
670
+ # header parameters
671
+ header_params = opts[:header_params] || {}
672
+ # HTTP header 'Accept' (if needed)
673
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
674
+ # HTTP header 'Content-Type'
675
+ content_type = @api_client.select_header_content_type(['application/x-www-form-urlencoded'])
676
+ if !content_type.nil?
677
+ header_params['Content-Type'] = content_type
678
+ end
679
+
680
+ # form parameters
681
+ form_params = opts[:form_params] || {}
682
+ form_params['list_id'] = opts[:'list_id'] if !opts[:'list_id'].nil?
683
+ form_params['template_id'] = opts[:'template_id'] if !opts[:'template_id'].nil?
684
+ form_params['from_email'] = opts[:'from_email'] if !opts[:'from_email'].nil?
685
+ form_params['from_name'] = opts[:'from_name'] if !opts[:'from_name'].nil?
686
+ form_params['subject'] = opts[:'subject'] if !opts[:'subject'].nil?
687
+ form_params['name'] = opts[:'name'] if !opts[:'name'].nil?
688
+ form_params['use_smart_sending'] = opts[:'use_smart_sending'] if !opts[:'use_smart_sending'].nil?
689
+ form_params['add_google_analytics'] = opts[:'add_google_analytics'] if !opts[:'add_google_analytics'].nil?
690
+
691
+ # http body (model)
692
+ post_body = opts[:body]
693
+
694
+ # return_type
695
+ return_type = opts[:debug_return_type] || 'Campaign'
696
+
697
+ # auth_names
698
+ auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']
699
+
700
+ new_options = opts.merge(
701
+ :operation => :"CampaignsApi.update_campaign",
702
+ :header_params => header_params,
703
+ :query_params => query_params,
704
+ :form_params => form_params,
705
+ :body => post_body,
706
+ :auth_names => auth_names,
707
+ :return_type => return_type
708
+ )
709
+
710
+ data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)
711
+ if @api_client.config.debugging
712
+ @api_client.config.logger.debug "API called: CampaignsApi#update_campaign\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
713
+ end
714
+ return data, status_code, headers
715
+ end
716
+ end
717
+ end