Class: Klaviyo::CampaignsApi

Inherits:
Object
  • Object
show all
Defined in:
lib/klaviyo_sdk/api/campaigns_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ CampaignsApi

Returns a new instance of CampaignsApi.



19
20
21
# File 'lib/klaviyo_sdk/api/campaigns_api.rb', line 19

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



17
18
19
# File 'lib/klaviyo_sdk/api/campaigns_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#cancel_campaign(campaign_id, opts = {}) ⇒ Campaign

Cancel a Campaign Cancels a campaign send. Marks a campaign as cancelled regardless of it’s current status.

Parameters:

  • campaign_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



27
28
29
30
# File 'lib/klaviyo_sdk/api/campaigns_api.rb', line 27

def cancel_campaign(campaign_id, opts = {})
  data, _status_code, _headers = cancel_campaign_with_http_info(campaign_id, opts)
  data
end

#cancel_campaign_with_http_info(campaign_id, opts = {}) ⇒ Array<(Campaign, Integer, Hash)>

Cancel a Campaign Cancels a campaign send. Marks a campaign as cancelled regardless of it&#39;s current status.

Parameters:

  • campaign_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Campaign, Integer, Hash)>)

    Campaign data, response status code and response headers



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
# File 'lib/klaviyo_sdk/api/campaigns_api.rb', line 37

def cancel_campaign_with_http_info(campaign_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CampaignsApi.cancel_campaign ...'
  end
  # verify the required parameter 'campaign_id' is set
  if @api_client.config.client_side_validation && campaign_id.nil?
    fail ArgumentError, "Missing the required parameter 'campaign_id' when calling CampaignsApi.cancel_campaign"
  end
  # resource path
  local_var_path = '/v1/campaign/{campaign_id}/cancel'.sub('{' + 'campaign_id' + '}', CGI.escape(campaign_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # 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[:body]

  # return_type
  return_type = opts[:debug_return_type] || 'Campaign'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']

  new_options = opts.merge(
    :operation => :"CampaignsApi.cancel_campaign",
    :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: CampaignsApi#cancel_campaign\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#clone_campaign(campaign_id, name, list_id, opts = {}) ⇒ Campaign

Clone a Campaign Creates a copy of a campaign. The new campaign starts as a draft.

Parameters:

  • campaign_id (String)
  • 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.

  • list_id (String)

    The list you will send the campaign to.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



92
93
94
95
# File 'lib/klaviyo_sdk/api/campaigns_api.rb', line 92

def clone_campaign(campaign_id, name, list_id, opts = {})
  data, _status_code, _headers = clone_campaign_with_http_info(campaign_id, name, list_id, opts)
  data
end

#clone_campaign_with_http_info(campaign_id, name, list_id, opts = {}) ⇒ Array<(Campaign, Integer, Hash)>

Clone a Campaign Creates a copy of a campaign. The new campaign starts as a draft.

Parameters:

  • campaign_id (String)
  • 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.

  • list_id (String)

    The list you will send the campaign to.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Campaign, Integer, Hash)>)

    Campaign data, response status code and response headers



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
# File 'lib/klaviyo_sdk/api/campaigns_api.rb', line 104

def clone_campaign_with_http_info(campaign_id, name, list_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CampaignsApi.clone_campaign ...'
  end
  # verify the required parameter 'campaign_id' is set
  if @api_client.config.client_side_validation && campaign_id.nil?
    fail ArgumentError, "Missing the required parameter 'campaign_id' when calling CampaignsApi.clone_campaign"
  end
  # verify the required parameter 'name' is set
  if @api_client.config.client_side_validation && name.nil?
    fail ArgumentError, "Missing the required parameter 'name' when calling CampaignsApi.clone_campaign"
  end
  # verify the required parameter 'list_id' is set
  if @api_client.config.client_side_validation && list_id.nil?
    fail ArgumentError, "Missing the required parameter 'list_id' when calling CampaignsApi.clone_campaign"
  end
  # resource path
  local_var_path = '/v1/campaign/{campaign_id}/clone'.sub('{' + 'campaign_id' + '}', CGI.escape(campaign_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # 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/x-www-form-urlencoded'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}
  form_params['name'] = name
  form_params['list_id'] = list_id

  # http body (model)
  post_body = opts[:body]

  # return_type
  return_type = opts[:debug_return_type] || 'Campaign'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']

  new_options = opts.merge(
    :operation => :"CampaignsApi.clone_campaign",
    :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: CampaignsApi#clone_campaign\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#create_campaign(list_id, template_id, from_email, from_name, subject, opts = {}) ⇒ Campaign

Create New Campaign Creates a new campaign. The created campaign is a draft and is not automatically sent.

Parameters:

  • list_id (String)

    The list you will send the campaign to.

  • 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.

  • from_email (String)

    The email address your email will be sent from and will be used in the &#x60;reply-to&#x60; header.

  • from_name (String)

    The name or label associated with the email address you&#39;re sending from.

  • subject (String)

    The email subject of the campaign

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :name (String)

    If not specified, this will default to the subject of the campaign. (default to ‘Campaign Name’)

  • :use_smart_sending (Boolean)

    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)

  • :add_google_analytics (Boolean)

    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)

Returns:



179
180
181
182
# File 'lib/klaviyo_sdk/api/campaigns_api.rb', line 179

def create_campaign(list_id, template_id, from_email, from_name, subject, opts = {})
  data, _status_code, _headers = create_campaign_with_http_info(list_id, template_id, from_email, from_name, subject, opts)
  data
end

#create_campaign_with_http_info(list_id, template_id, from_email, from_name, subject, opts = {}) ⇒ Array<(Campaign, Integer, Hash)>

Create New Campaign Creates a new campaign. The created campaign is a draft and is not automatically sent.

Parameters:

  • list_id (String)

    The list you will send the campaign to.

  • 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.

  • from_email (String)

    The email address your email will be sent from and will be used in the &#x60;reply-to&#x60; header.

  • from_name (String)

    The name or label associated with the email address you&#39;re sending from.

  • subject (String)

    The email subject of the campaign

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :name (String)

    If not specified, this will default to the subject of the campaign.

  • :use_smart_sending (Boolean)

    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;.

  • :add_google_analytics (Boolean)

    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;.

Returns:

  • (Array<(Campaign, Integer, Hash)>)

    Campaign data, response status code and response headers



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
# File 'lib/klaviyo_sdk/api/campaigns_api.rb', line 196

def create_campaign_with_http_info(list_id, template_id, from_email, from_name, subject, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CampaignsApi.create_campaign ...'
  end
  # verify the required parameter 'list_id' is set
  if @api_client.config.client_side_validation && list_id.nil?
    fail ArgumentError, "Missing the required parameter 'list_id' when calling CampaignsApi.create_campaign"
  end
  # verify the required parameter 'template_id' is set
  if @api_client.config.client_side_validation && template_id.nil?
    fail ArgumentError, "Missing the required parameter 'template_id' when calling CampaignsApi.create_campaign"
  end
  # verify the required parameter 'from_email' is set
  if @api_client.config.client_side_validation && from_email.nil?
    fail ArgumentError, "Missing the required parameter 'from_email' when calling CampaignsApi.create_campaign"
  end
  # verify the required parameter 'from_name' is set
  if @api_client.config.client_side_validation && from_name.nil?
    fail ArgumentError, "Missing the required parameter 'from_name' when calling CampaignsApi.create_campaign"
  end
  # verify the required parameter 'subject' is set
  if @api_client.config.client_side_validation && subject.nil?
    fail ArgumentError, "Missing the required parameter 'subject' when calling CampaignsApi.create_campaign"
  end
  # resource path
  local_var_path = '/v1/campaigns'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # 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/x-www-form-urlencoded'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}
  form_params['list_id'] = list_id
  form_params['template_id'] = template_id
  form_params['from_email'] = from_email
  form_params['from_name'] = from_name
  form_params['subject'] = subject
  form_params['name'] = opts[:'name'] if !opts[:'name'].nil?
  form_params['use_smart_sending'] = opts[:'use_smart_sending'] if !opts[:'use_smart_sending'].nil?
  form_params['add_google_analytics'] = opts[:'add_google_analytics'] if !opts[:'add_google_analytics'].nil?

  # http body (model)
  post_body = opts[:body]

  # return_type
  return_type = opts[:debug_return_type] || 'Campaign'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']

  new_options = opts.merge(
    :operation => :"CampaignsApi.create_campaign",
    :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: CampaignsApi#create_campaign\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_campaign_info(campaign_id, opts = {}) ⇒ Campaign

Get Campaign Info Returns summary information for the campaign specified.

Parameters:

  • campaign_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



278
279
280
281
# File 'lib/klaviyo_sdk/api/campaigns_api.rb', line 278

def get_campaign_info(campaign_id, opts = {})
  data, _status_code, _headers = get_campaign_info_with_http_info(campaign_id, opts)
  data
end

#get_campaign_info_with_http_info(campaign_id, opts = {}) ⇒ Array<(Campaign, Integer, Hash)>

Get Campaign Info Returns summary information for the campaign specified.

Parameters:

  • campaign_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Campaign, Integer, Hash)>)

    Campaign data, response status code and response headers



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
# File 'lib/klaviyo_sdk/api/campaigns_api.rb', line 288

def get_campaign_info_with_http_info(campaign_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CampaignsApi.get_campaign_info ...'
  end
  # verify the required parameter 'campaign_id' is set
  if @api_client.config.client_side_validation && campaign_id.nil?
    fail ArgumentError, "Missing the required parameter 'campaign_id' when calling CampaignsApi.get_campaign_info"
  end
  # resource path
  local_var_path = '/v1/campaign/{campaign_id}'.sub('{' + 'campaign_id' + '}', CGI.escape(campaign_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # 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[:body]

  # return_type
  return_type = opts[:debug_return_type] || 'Campaign'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']

  new_options = opts.merge(
    :operation => :"CampaignsApi.get_campaign_info",
    :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: CampaignsApi#get_campaign_info\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_campaign_recipients(campaign_id, opts = {}) ⇒ Hash<String, Object>

Get Campaign Recipients Returns summary information about email recipients for the campaign specified that includes each recipients email, customer ID, and status.

Parameters:

  • campaign_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :count (Integer)

    For pagination, the number of results to return. Max &#x3D; 25,000 (default to 5000)

  • :sort (String)

    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’)

  • :offset (String)

    For pagination, if a response to this endpoint includes a &#x60;next_offset&#x60;, use that value to get the next page of recipients.

Returns:

  • (Hash<String, Object>)


344
345
346
347
# File 'lib/klaviyo_sdk/api/campaigns_api.rb', line 344

def get_campaign_recipients(campaign_id, opts = {})
  data, _status_code, _headers = get_campaign_recipients_with_http_info(campaign_id, opts)
  data
end

#get_campaign_recipients_with_http_info(campaign_id, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)>

Get Campaign Recipients Returns summary information about email recipients for the campaign specified that includes each recipients email, customer ID, and status.

Parameters:

  • campaign_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :count (Integer)

    For pagination, the number of results to return. Max &#x3D; 25,000

  • :sort (String)

    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;.

  • :offset (String)

    For pagination, if a response to this endpoint includes a &#x60;next_offset&#x60;, use that value to get the next page of recipients.

Returns:

  • (Array<(Hash<String, Object>, Integer, Hash)>)

    Hash<String, Object> data, response status code and response headers



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
# File 'lib/klaviyo_sdk/api/campaigns_api.rb', line 357

def get_campaign_recipients_with_http_info(campaign_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CampaignsApi.get_campaign_recipients ...'
  end
  # verify the required parameter 'campaign_id' is set
  if @api_client.config.client_side_validation && campaign_id.nil?
    fail ArgumentError, "Missing the required parameter 'campaign_id' when calling CampaignsApi.get_campaign_recipients"
  end
  if @api_client.config.client_side_validation && !opts[:'count'].nil? && opts[:'count'] > 25000
    fail ArgumentError, 'invalid value for "opts[:"count"]" when calling CampaignsApi.get_campaign_recipients, must be smaller than or equal to 25000.'
  end

  # resource path
  local_var_path = '/v1/campaign/{campaign_id}/recipients'.sub('{' + 'campaign_id' + '}', CGI.escape(campaign_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'count'] = opts[:'count'] if !opts[:'count'].nil?
  query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?
  query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # 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[:body]

  # return_type
  return_type = opts[:debug_return_type] || 'Hash<String, Object>'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']

  new_options = opts.merge(
    :operation => :"CampaignsApi.get_campaign_recipients",
    :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: CampaignsApi#get_campaign_recipients\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_campaigns(opts = {}) ⇒ Hash<String, Object>

Get Campaigns Returns a list of all the campaigns you’ve created. The campaigns are returned in reverse sorted order by the time they were created.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :page (Integer)

    For pagination, which page of results to return. Default &#x3D; 0 (default to 0)

  • :count (Integer)

    For pagination, the number of results to return. Max &#x3D; 100 (default to 50)

Returns:

  • (Hash<String, Object>)


418
419
420
421
# File 'lib/klaviyo_sdk/api/campaigns_api.rb', line 418

def get_campaigns(opts = {})
  data, _status_code, _headers = get_campaigns_with_http_info(opts)
  data
end

#get_campaigns_with_http_info(opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)>

Get Campaigns 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.

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :page (Integer)

    For pagination, which page of results to return. Default &#x3D; 0

  • :count (Integer)

    For pagination, the number of results to return. Max &#x3D; 100

Returns:

  • (Array<(Hash<String, Object>, Integer, Hash)>)

    Hash<String, Object> data, response status code and response headers



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
# File 'lib/klaviyo_sdk/api/campaigns_api.rb', line 429

def get_campaigns_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CampaignsApi.get_campaigns ...'
  end
  if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] < 0
    fail ArgumentError, 'invalid value for "opts[:"page"]" when calling CampaignsApi.get_campaigns, must be greater than or equal to 0.'
  end

  if @api_client.config.client_side_validation && !opts[:'count'].nil? && opts[:'count'] > 100
    fail ArgumentError, 'invalid value for "opts[:"count"]" when calling CampaignsApi.get_campaigns, must be smaller than or equal to 100.'
  end

  if @api_client.config.client_side_validation && !opts[:'count'].nil? && opts[:'count'] < 1
    fail ArgumentError, 'invalid value for "opts[:"count"]" when calling CampaignsApi.get_campaigns, must be greater than or equal to 1.'
  end

  # resource path
  local_var_path = '/v1/campaigns'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
  query_params[:'count'] = opts[:'count'] if !opts[:'count'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # 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[:body]

  # return_type
  return_type = opts[:debug_return_type] || 'Hash<String, Object>'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']

  new_options = opts.merge(
    :operation => :"CampaignsApi.get_campaigns",
    :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: CampaignsApi#get_campaigns\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#schedule_campaign(campaign_id, send_time, opts = {}) ⇒ Hash<String, Object>

Schedule a Campaign Schedules a campaign for a time in the future

Parameters:

  • campaign_id (String)
  • 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;

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Hash<String, Object>)


493
494
495
496
# File 'lib/klaviyo_sdk/api/campaigns_api.rb', line 493

def schedule_campaign(campaign_id, send_time, opts = {})
  data, _status_code, _headers = schedule_campaign_with_http_info(campaign_id, send_time, opts)
  data
end

#schedule_campaign_with_http_info(campaign_id, send_time, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)>

Schedule a Campaign Schedules a campaign for a time in the future

Parameters:

  • campaign_id (String)
  • 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;

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Hash<String, Object>, Integer, Hash)>)

    Hash<String, Object> data, response status code and response headers



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
# File 'lib/klaviyo_sdk/api/campaigns_api.rb', line 504

def schedule_campaign_with_http_info(campaign_id, send_time, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CampaignsApi.schedule_campaign ...'
  end
  # verify the required parameter 'campaign_id' is set
  if @api_client.config.client_side_validation && campaign_id.nil?
    fail ArgumentError, "Missing the required parameter 'campaign_id' when calling CampaignsApi.schedule_campaign"
  end
  # verify the required parameter 'send_time' is set
  if @api_client.config.client_side_validation && send_time.nil?
    fail ArgumentError, "Missing the required parameter 'send_time' when calling CampaignsApi.schedule_campaign"
  end
  # resource path
  local_var_path = '/v1/campaign/{campaign_id}/schedule'.sub('{' + 'campaign_id' + '}', CGI.escape(campaign_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # 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/x-www-form-urlencoded'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}
  form_params['send_time'] = send_time

  # http body (model)
  post_body = opts[:body]

  # return_type
  return_type = opts[:debug_return_type] || 'Hash<String, Object>'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']

  new_options = opts.merge(
    :operation => :"CampaignsApi.schedule_campaign",
    :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: CampaignsApi#schedule_campaign\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#send_campaign(campaign_id, opts = {}) ⇒ Hash<String, Object>

Send a Campaign Immediately Queues a campaign for immediate delivery

Parameters:

  • campaign_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Hash<String, Object>)


567
568
569
570
# File 'lib/klaviyo_sdk/api/campaigns_api.rb', line 567

def send_campaign(campaign_id, opts = {})
  data, _status_code, _headers = send_campaign_with_http_info(campaign_id, opts)
  data
end

#send_campaign_with_http_info(campaign_id, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)>

Send a Campaign Immediately Queues a campaign for immediate delivery

Parameters:

  • campaign_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(Hash<String, Object>, Integer, Hash)>)

    Hash<String, Object> data, response status code and response headers



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
# File 'lib/klaviyo_sdk/api/campaigns_api.rb', line 577

def send_campaign_with_http_info(campaign_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CampaignsApi.send_campaign ...'
  end
  # verify the required parameter 'campaign_id' is set
  if @api_client.config.client_side_validation && campaign_id.nil?
    fail ArgumentError, "Missing the required parameter 'campaign_id' when calling CampaignsApi.send_campaign"
  end
  # resource path
  local_var_path = '/v1/campaign/{campaign_id}/send'.sub('{' + 'campaign_id' + '}', CGI.escape(campaign_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # 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[:body]

  # return_type
  return_type = opts[:debug_return_type] || 'Hash<String, Object>'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']

  new_options = opts.merge(
    :operation => :"CampaignsApi.send_campaign",
    :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: CampaignsApi#send_campaign\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#update_campaign(campaign_id, opts = {}) ⇒ Campaign

Update Campaign Updates details of a campaign. You can update a campaign’s name, subject, from email address, from name, template or list.

Parameters:

  • campaign_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :list_id (String)

    The list you will send the campaign to.

  • :template_id (String)

    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.

  • :from_email (String)

    The email address your email will be sent from and will be used in the reply-to header.

  • :from_name (String)

    The name or label associated with the email address you&#39;re sending from.

  • :subject (String)

    The email subject of the campaign

  • :name (String)

    A name for this campaign. If not specified, this will default to the subject of the campaign.

  • :use_smart_sending (Boolean)

    If set, limits the number of emails sent to an individual within a short period. Campaigns initially default to &#x60;true&#x60;.

  • :add_google_analytics (Boolean)

    If specified, adds Google Analytics tracking tags to links. Campaigns initially default to &#x60;false&#x60;.

Returns:



638
639
640
641
# File 'lib/klaviyo_sdk/api/campaigns_api.rb', line 638

def update_campaign(campaign_id, opts = {})
  data, _status_code, _headers = update_campaign_with_http_info(campaign_id, opts)
  data
end

#update_campaign_with_http_info(campaign_id, opts = {}) ⇒ Array<(Campaign, Integer, Hash)>

Update Campaign Updates details of a campaign. You can update a campaign&#39;s name, subject, from email address, from name, template or list.

Parameters:

  • campaign_id (String)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :list_id (String)

    The list you will send the campaign to.

  • :template_id (String)

    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.

  • :from_email (String)

    The email address your email will be sent from and will be used in the reply-to header.

  • :from_name (String)

    The name or label associated with the email address you&#39;re sending from.

  • :subject (String)

    The email subject of the campaign

  • :name (String)

    A name for this campaign. If not specified, this will default to the subject of the campaign.

  • :use_smart_sending (Boolean)

    If set, limits the number of emails sent to an individual within a short period. Campaigns initially default to &#x60;true&#x60;.

  • :add_google_analytics (Boolean)

    If specified, adds Google Analytics tracking tags to links. Campaigns initially default to &#x60;false&#x60;.

Returns:

  • (Array<(Campaign, Integer, Hash)>)

    Campaign data, response status code and response headers



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
# File 'lib/klaviyo_sdk/api/campaigns_api.rb', line 656

def update_campaign_with_http_info(campaign_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CampaignsApi.update_campaign ...'
  end
  # verify the required parameter 'campaign_id' is set
  if @api_client.config.client_side_validation && campaign_id.nil?
    fail ArgumentError, "Missing the required parameter 'campaign_id' when calling CampaignsApi.update_campaign"
  end
  # resource path
  local_var_path = '/v1/campaign/{campaign_id}'.sub('{' + 'campaign_id' + '}', CGI.escape(campaign_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # 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/x-www-form-urlencoded'])
  if !content_type.nil?
      header_params['Content-Type'] = content_type
  end

  # form parameters
  form_params = opts[:form_params] || {}
  form_params['list_id'] = opts[:'list_id'] if !opts[:'list_id'].nil?
  form_params['template_id'] = opts[:'template_id'] if !opts[:'template_id'].nil?
  form_params['from_email'] = opts[:'from_email'] if !opts[:'from_email'].nil?
  form_params['from_name'] = opts[:'from_name'] if !opts[:'from_name'].nil?
  form_params['subject'] = opts[:'subject'] if !opts[:'subject'].nil?
  form_params['name'] = opts[:'name'] if !opts[:'name'].nil?
  form_params['use_smart_sending'] = opts[:'use_smart_sending'] if !opts[:'use_smart_sending'].nil?
  form_params['add_google_analytics'] = opts[:'add_google_analytics'] if !opts[:'add_google_analytics'].nil?

  # http body (model)
  post_body = opts[:body]

  # return_type
  return_type = opts[:debug_return_type] || 'Campaign'

  # auth_names
  auth_names = opts[:debug_auth_names] || ['ApiKeyAuth']

  new_options = opts.merge(
    :operation => :"CampaignsApi.update_campaign",
    :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(:PUT, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: CampaignsApi#update_campaign\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end