Class: KlaviyoAPI::CampaignsApi

Inherits:
Object
  • Object
show all
Defined in:
lib/klaviyo-api-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-api-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-api-sdk/api/campaigns_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

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

Create Campaign Creates a campaign given a set of parameters, then returns it.
*Rate limits*:
Burst: ‘10/s`
Steady: `150/m` Scopes: `campaigns:write`

Parameters:

  • campaign_create_query (CampaignCreateQuery)

    Creates a campaign from parameters

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

    the optional parameters

Returns:

  • (Hash<String, Object>)


27
28
29
30
# File 'lib/klaviyo-api-sdk/api/campaigns_api.rb', line 27

def create_campaign(campaign_create_query, opts = {})
  data, _status_code, _headers = create_campaign_with_http_info(campaign_create_query, opts)
  data
end

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

Create Campaign Clone Clones an existing campaign, returning a new campaign based on the original with a new ID and name.
*Rate limits*:
Burst: ‘10/s`
Steady: `150/m` Scopes: `campaigns:write`

Parameters:

  • campaign_clone_query (CampaignCloneQuery)

    Clones a campaign from an existing campaign

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

    the optional parameters

Returns:

  • (Hash<String, Object>)


97
98
99
100
# File 'lib/klaviyo-api-sdk/api/campaigns_api.rb', line 97

def create_campaign_clone(campaign_clone_query, opts = {})
  data, _status_code, _headers = create_campaign_clone_with_http_info(campaign_clone_query, opts)
  data
end

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

Create Campaign Clone Clones an existing campaign, returning a new campaign based on the original with a new ID and name.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;10/s&#x60;&lt;br&gt;Steady: &#x60;150/m&#x60; Scopes: &#x60;campaigns:write&#x60;

Parameters:

  • campaign_clone_query (CampaignCloneQuery)

    Clones a campaign from an existing campaign

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

    the optional parameters

Returns:

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

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



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
# File 'lib/klaviyo-api-sdk/api/campaigns_api.rb', line 107

def create_campaign_clone_with_http_info(campaign_clone_query, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CampaignsApi.create_campaign_clone ...'
  end
  # verify the required parameter 'campaign_clone_query' is set
  if @api_client.config.client_side_validation && campaign_clone_query.nil?
    fail ArgumentError, "Missing the required parameter 'campaign_clone_query' when calling CampaignsApi.create_campaign_clone"
  end
  # resource path
  local_var_path = '/api/campaign-clone/'

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

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['API_REVISION'] || "2023-08-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(campaign_clone_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 => :"CampaignsApi.create_campaign_clone",
    :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_clone\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

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

Assign Campaign Message Template Creates a non-reusable version of the template and assigns it to the message.
*Rate limits*:
Burst: ‘10/s`
Steady: `150/m` Scopes: `campaigns:write`

Parameters:

  • campaign_message_assign_template_query (CampaignMessageAssignTemplateQuery)

    Takes a reusable template, clones it, and assigns the non-reusable clone to the message.

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

    the optional parameters

Returns:

  • (Hash<String, Object>)


167
168
169
170
# File 'lib/klaviyo-api-sdk/api/campaigns_api.rb', line 167

def create_campaign_message_assign_template(campaign_message_assign_template_query, opts = {})
  data, _status_code, _headers = create_campaign_message_assign_template_with_http_info(campaign_message_assign_template_query, opts)
  data
end

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

Assign Campaign Message Template Creates a non-reusable version of the template and assigns it to the message.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;10/s&#x60;&lt;br&gt;Steady: &#x60;150/m&#x60; Scopes: &#x60;campaigns:write&#x60;

Parameters:

  • campaign_message_assign_template_query (CampaignMessageAssignTemplateQuery)

    Takes a reusable template, clones it, and assigns the non-reusable clone to the message.

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

    the optional parameters

Returns:

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

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



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
# File 'lib/klaviyo-api-sdk/api/campaigns_api.rb', line 177

def create_campaign_message_assign_template_with_http_info(campaign_message_assign_template_query, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CampaignsApi.create_campaign_message_assign_template ...'
  end
  # verify the required parameter 'campaign_message_assign_template_query' is set
  if @api_client.config.client_side_validation && campaign_message_assign_template_query.nil?
    fail ArgumentError, "Missing the required parameter 'campaign_message_assign_template_query' when calling CampaignsApi.create_campaign_message_assign_template"
  end
  # resource path
  local_var_path = '/api/campaign-message-assign-template/'

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

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['API_REVISION'] || "2023-08-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(campaign_message_assign_template_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 => :"CampaignsApi.create_campaign_message_assign_template",
    :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_message_assign_template\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

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

Create Campaign Recipient Estimation Job Trigger an asynchronous job to update the estimated number of recipients for the given campaign ID. Use the ‘Get Campaign Recipient Estimation Job` endpoint to retrieve the status of this estimation job. Use the `Get Campaign Recipient Estimation` endpoint to retrieve the estimated recipient count for a given campaign.
*Rate limits*:
Burst: `10/s`
Steady: `150/m` Scopes: `campaigns:write`

Parameters:

  • campaign_recipient_estimation_job_create_query (CampaignRecipientEstimationJobCreateQuery)

    Trigger an asynchronous job to update the estimated number of recipients for the given campaign ID. Use the &#x60;Get Campaign Recipient Estimation Job&#x60; endpoint to retrieve the status of this estimation job. Use the &#x60;Get Campaign Recipient Estimation&#x60; endpoint to retrieve the estimated recipient count for a given campaign.

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

    the optional parameters

Returns:

  • (Hash<String, Object>)


237
238
239
240
# File 'lib/klaviyo-api-sdk/api/campaigns_api.rb', line 237

def create_campaign_recipient_estimation_job(campaign_recipient_estimation_job_create_query, opts = {})
  data, _status_code, _headers = create_campaign_recipient_estimation_job_with_http_info(campaign_recipient_estimation_job_create_query, opts)
  data
end

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

Create Campaign Recipient Estimation Job Trigger an asynchronous job to update the estimated number of recipients for the given campaign ID. Use the &#x60;Get Campaign Recipient Estimation Job&#x60; endpoint to retrieve the status of this estimation job. Use the &#x60;Get Campaign Recipient Estimation&#x60; endpoint to retrieve the estimated recipient count for a given campaign.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;10/s&#x60;&lt;br&gt;Steady: &#x60;150/m&#x60; Scopes: &#x60;campaigns:write&#x60;

Parameters:

  • campaign_recipient_estimation_job_create_query (CampaignRecipientEstimationJobCreateQuery)

    Trigger an asynchronous job to update the estimated number of recipients for the given campaign ID. Use the &#x60;Get Campaign Recipient Estimation Job&#x60; endpoint to retrieve the status of this estimation job. Use the &#x60;Get Campaign Recipient Estimation&#x60; endpoint to retrieve the estimated recipient count for a given campaign.

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

    the optional parameters

Returns:

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

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



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
# File 'lib/klaviyo-api-sdk/api/campaigns_api.rb', line 247

def create_campaign_recipient_estimation_job_with_http_info(campaign_recipient_estimation_job_create_query, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CampaignsApi.create_campaign_recipient_estimation_job ...'
  end
  # verify the required parameter 'campaign_recipient_estimation_job_create_query' is set
  if @api_client.config.client_side_validation && campaign_recipient_estimation_job_create_query.nil?
    fail ArgumentError, "Missing the required parameter 'campaign_recipient_estimation_job_create_query' when calling CampaignsApi.create_campaign_recipient_estimation_job"
  end
  # resource path
  local_var_path = '/api/campaign-recipient-estimation-jobs/'

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

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['API_REVISION'] || "2023-08-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(campaign_recipient_estimation_job_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 => :"CampaignsApi.create_campaign_recipient_estimation_job",
    :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_recipient_estimation_job\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

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

Create Campaign Send Job Trigger a campaign to send asynchronously
*Rate limits*:
Burst: ‘10/s`
Steady: `150/m` Scopes: `campaigns:write`

Parameters:

  • campaign_send_job_create_query (CampaignSendJobCreateQuery)

    Trigger the campaign to send asynchronously

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

    the optional parameters

Returns:

  • (Hash<String, Object>)


307
308
309
310
# File 'lib/klaviyo-api-sdk/api/campaigns_api.rb', line 307

def create_campaign_send_job(campaign_send_job_create_query, opts = {})
  data, _status_code, _headers = create_campaign_send_job_with_http_info(campaign_send_job_create_query, opts)
  data
end

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

Create Campaign Send Job Trigger a campaign to send asynchronously&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;10/s&#x60;&lt;br&gt;Steady: &#x60;150/m&#x60; Scopes: &#x60;campaigns:write&#x60;

Parameters:

  • campaign_send_job_create_query (CampaignSendJobCreateQuery)

    Trigger the campaign to send asynchronously

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

    the optional parameters

Returns:

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

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



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
# File 'lib/klaviyo-api-sdk/api/campaigns_api.rb', line 317

def create_campaign_send_job_with_http_info(campaign_send_job_create_query, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CampaignsApi.create_campaign_send_job ...'
  end
  # verify the required parameter 'campaign_send_job_create_query' is set
  if @api_client.config.client_side_validation && campaign_send_job_create_query.nil?
    fail ArgumentError, "Missing the required parameter 'campaign_send_job_create_query' when calling CampaignsApi.create_campaign_send_job"
  end
  # resource path
  local_var_path = '/api/campaign-send-jobs/'

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

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['API_REVISION'] || "2023-08-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(campaign_send_job_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 => :"CampaignsApi.create_campaign_send_job",
    :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_send_job\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

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

Create Campaign Creates a campaign given a set of parameters, then returns it.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;10/s&#x60;&lt;br&gt;Steady: &#x60;150/m&#x60; Scopes: &#x60;campaigns:write&#x60;

Parameters:

  • campaign_create_query (CampaignCreateQuery)

    Creates a campaign from parameters

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

    the optional parameters

Returns:

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

    Hash<String, Object> 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
84
85
86
87
88
89
90
# File 'lib/klaviyo-api-sdk/api/campaigns_api.rb', line 37

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

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

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['API_REVISION'] || "2023-08-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(campaign_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 => :"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

#delete_campaign(id, opts = {}) ⇒ nil

Delete Campaign Delete a campaign with the given campaign ID.
*Rate limits*:
Burst: ‘10/s`
Steady: `150/m` Scopes: `campaigns:write`

Parameters:

  • id (String)

    The campaign ID to be deleted

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

    the optional parameters

Returns:

  • (nil)


377
378
379
380
# File 'lib/klaviyo-api-sdk/api/campaigns_api.rb', line 377

def delete_campaign(id, opts = {})
  delete_campaign_with_http_info(id, opts)
  nil
end

#delete_campaign_with_http_info(id, opts = {}) ⇒ Array<(nil, Integer, Hash)>

Delete Campaign Delete a campaign with the given campaign ID.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;10/s&#x60;&lt;br&gt;Steady: &#x60;150/m&#x60; Scopes: &#x60;campaigns:write&#x60;

Parameters:

  • id (String)

    The campaign ID to be deleted

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

    the optional parameters

Returns:

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

    nil, response status code and response headers



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
# File 'lib/klaviyo-api-sdk/api/campaigns_api.rb', line 387

def delete_campaign_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CampaignsApi.delete_campaign ...'
  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 CampaignsApi.delete_campaign"
  end
  # resource path
  local_var_path = '/api/campaigns/{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-08-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 => :"CampaignsApi.delete_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(:DELETE, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: CampaignsApi#delete_campaign\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

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

Get Campaign Returns a specific campaign based on a required id.
*Rate limits*:
Burst: ‘10/s`
Steady: `150/m` Scopes: `campaigns:read`

Parameters:

  • id (String)

    The campaign ID to be retrieved

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

    the optional parameters

Options Hash (opts):

Returns:

  • (Hash<String, Object>)


446
447
448
449
# File 'lib/klaviyo-api-sdk/api/campaigns_api.rb', line 446

def get_campaign(id, opts = {})
  data, _status_code, _headers = get_campaign_with_http_info(id, opts)
  data
end

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

Get Campaign Campaign Messages Return all messages that belong to the given campaign.
*Rate limits*:
Burst: ‘10/s`
Steady: `150/m` Scopes: `campaigns:read`

Parameters:

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

    the optional parameters

Options Hash (opts):

Returns:

  • (Hash<String, Object>)


539
540
541
542
# File 'lib/klaviyo-api-sdk/api/campaigns_api.rb', line 539

def get_campaign_campaign_messages(id, opts = {})
  data, _status_code, _headers = get_campaign_campaign_messages_with_http_info(id, opts)
  data
end

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

Get Campaign Campaign Messages Return all messages that belong to the given campaign.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;10/s&#x60;&lt;br&gt;Steady: &#x60;150/m&#x60; Scopes: &#x60;campaigns:read&#x60;

Parameters:

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

    the optional parameters

Options Hash (opts):

Returns:

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

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



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
# File 'lib/klaviyo-api-sdk/api/campaigns_api.rb', line 553

def get_campaign_campaign_messages_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CampaignsApi.get_campaign_campaign_messages ...'
  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 CampaignsApi.get_campaign_campaign_messages"
  end
  allowable_values = ["label", "channel", "content", "send_times", "render_options", "render_options.shorten_links", "render_options.add_org_prefix", "render_options.add_info_link", "render_options.add_opt_out_language", "created_at", "updated_at"]
  if @api_client.config.client_side_validation && opts[:'fields_campaign_message'] && !opts[:'fields_campaign_message'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"fields_campaign_message\", must include one of #{allowable_values}"
  end
  allowable_values = ["name", "status", "archived", "audiences", "audiences.included", "audiences.excluded", "send_options", "tracking_options", "send_strategy", "send_strategy.method", "send_strategy.options_static", "send_strategy.options_static.datetime", "send_strategy.options_static.is_local", "send_strategy.options_static.send_past_recipients_immediately", "send_strategy.options_throttled", "send_strategy.options_throttled.datetime", "send_strategy.options_throttled.throttle_percentage", "send_strategy.options_sto", "send_strategy.options_sto.date", "created_at", "scheduled_at", "updated_at", "send_time"]
  if @api_client.config.client_side_validation && opts[:'fields_campaign'] && !opts[:'fields_campaign'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"fields_campaign\", must include one of #{allowable_values}"
  end
  allowable_values = ["name", "editor_type", "html", "text", "created", "updated"]
  if @api_client.config.client_side_validation && opts[:'fields_template'] && !opts[:'fields_template'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"fields_template\", must include one of #{allowable_values}"
  end
  allowable_values = ["campaign", "template"]
  if @api_client.config.client_side_validation && opts[:'include'] && !opts[:'include'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"include\", must include one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/api/campaigns/{id}/campaign-messages/'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'fields[campaign-message]'] = @api_client.build_collection_param(opts[:'fields_campaign_message'], :csv) if !opts[:'fields_campaign_message'].nil?
  query_params[:'fields[campaign]'] = @api_client.build_collection_param(opts[:'fields_campaign'], :csv) if !opts[:'fields_campaign'].nil?
  query_params[:'fields[template]'] = @api_client.build_collection_param(opts[:'fields_template'], :csv) if !opts[:'fields_template'].nil?
  query_params[:'include'] = @api_client.build_collection_param(opts[:'include'], :csv) if !opts[:'include'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['API_REVISION'] || "2023-08-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 => :"CampaignsApi.get_campaign_campaign_messages",
    :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_campaign_messages\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

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

Get Campaign Message Returns a specific message based on a required id.
*Rate limits*:
Burst: ‘10/s`
Steady: `150/m` Scopes: `campaigns:read`

Parameters:

  • id (String)

    The message ID to be retrieved

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

    the optional parameters

Options Hash (opts):

Returns:

  • (Hash<String, Object>)


632
633
634
635
# File 'lib/klaviyo-api-sdk/api/campaigns_api.rb', line 632

def get_campaign_message(id, opts = {})
  data, _status_code, _headers = get_campaign_message_with_http_info(id, opts)
  data
end

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

Get Campaign Message Campaign Return the related campaign
*Rate limits*:
Burst: ‘10/s`
Steady: `150/m` Scopes: `campaigns:read`

Parameters:

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

    the optional parameters

Options Hash (opts):

Returns:

  • (Hash<String, Object>)


722
723
724
725
# File 'lib/klaviyo-api-sdk/api/campaigns_api.rb', line 722

def get_campaign_message_campaign(id, opts = {})
  data, _status_code, _headers = get_campaign_message_campaign_with_http_info(id, opts)
  data
end

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

Get Campaign Message Campaign Return the related campaign&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;10/s&#x60;&lt;br&gt;Steady: &#x60;150/m&#x60; Scopes: &#x60;campaigns:read&#x60;

Parameters:

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

    the optional parameters

Options Hash (opts):

Returns:

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

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



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
# File 'lib/klaviyo-api-sdk/api/campaigns_api.rb', line 733

def get_campaign_message_campaign_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CampaignsApi.get_campaign_message_campaign ...'
  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 CampaignsApi.get_campaign_message_campaign"
  end
  allowable_values = ["label", "channel", "content", "send_times", "render_options", "render_options.shorten_links", "render_options.add_org_prefix", "render_options.add_info_link", "render_options.add_opt_out_language", "created_at", "updated_at"]
  if @api_client.config.client_side_validation && opts[:'fields_campaign_message'] && !opts[:'fields_campaign_message'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"fields_campaign_message\", must include one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/api/campaign-messages/{id}/campaign/'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'fields[campaign-message]'] = @api_client.build_collection_param(opts[:'fields_campaign_message'], :csv) if !opts[:'fields_campaign_message'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['API_REVISION'] || "2023-08-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 => :"CampaignsApi.get_campaign_message_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(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: CampaignsApi#get_campaign_message_campaign\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

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

Get Campaign Message Relationships Campaign Returns the ID of the related campaign
*Rate limits*:
Burst: ‘10/s`
Steady: `150/m` Scopes: `campaigns:read`

Parameters:

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

    the optional parameters

Returns:

  • (Hash<String, Object>)


793
794
795
796
# File 'lib/klaviyo-api-sdk/api/campaigns_api.rb', line 793

def get_campaign_message_relationships_campaign(id, opts = {})
  data, _status_code, _headers = get_campaign_message_relationships_campaign_with_http_info(id, opts)
  data
end

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

Get Campaign Message Relationships Campaign Returns the ID of the related campaign&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;10/s&#x60;&lt;br&gt;Steady: &#x60;150/m&#x60; Scopes: &#x60;campaigns:read&#x60;

Parameters:

  • 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



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
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
# File 'lib/klaviyo-api-sdk/api/campaigns_api.rb', line 803

def get_campaign_message_relationships_campaign_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CampaignsApi.get_campaign_message_relationships_campaign ...'
  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 CampaignsApi.get_campaign_message_relationships_campaign"
  end
  # resource path
  local_var_path = '/api/campaign-messages/{id}/relationships/campaign/'.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-08-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 => :"CampaignsApi.get_campaign_message_relationships_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(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: CampaignsApi#get_campaign_message_relationships_campaign\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

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

Get Campaign Message Relationships Template Returns the ID of the related template
*Rate limits*:
Burst: ‘10/s`
Steady: `150/m` Scopes: `campaigns:read` `templates:read`

Parameters:

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

    the optional parameters

Returns:

  • (Hash<String, Object>)


858
859
860
861
# File 'lib/klaviyo-api-sdk/api/campaigns_api.rb', line 858

def get_campaign_message_relationships_template(id, opts = {})
  data, _status_code, _headers = get_campaign_message_relationships_template_with_http_info(id, opts)
  data
end

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

Get Campaign Message Relationships Template Returns the ID of the related template&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;10/s&#x60;&lt;br&gt;Steady: &#x60;150/m&#x60; Scopes: &#x60;campaigns:read&#x60; &#x60;templates:read&#x60;

Parameters:

  • 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



868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
# File 'lib/klaviyo-api-sdk/api/campaigns_api.rb', line 868

def get_campaign_message_relationships_template_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CampaignsApi.get_campaign_message_relationships_template ...'
  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 CampaignsApi.get_campaign_message_relationships_template"
  end
  # resource path
  local_var_path = '/api/campaign-messages/{id}/relationships/template/'.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-08-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 => :"CampaignsApi.get_campaign_message_relationships_template",
    :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_message_relationships_template\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

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

Get Campaign Message Template Return the related template
*Rate limits*:
Burst: ‘10/s`
Steady: `150/m` Scopes: `campaigns:read` `templates:read`

Parameters:

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

    the optional parameters

Options Hash (opts):

Returns:

  • (Hash<String, Object>)


924
925
926
927
# File 'lib/klaviyo-api-sdk/api/campaigns_api.rb', line 924

def get_campaign_message_template(id, opts = {})
  data, _status_code, _headers = get_campaign_message_template_with_http_info(id, opts)
  data
end

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

Get Campaign Message Template Return the related template&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;10/s&#x60;&lt;br&gt;Steady: &#x60;150/m&#x60; Scopes: &#x60;campaigns:read&#x60; &#x60;templates:read&#x60;

Parameters:

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

    the optional parameters

Options Hash (opts):

Returns:

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

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



935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
# File 'lib/klaviyo-api-sdk/api/campaigns_api.rb', line 935

def get_campaign_message_template_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CampaignsApi.get_campaign_message_template ...'
  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 CampaignsApi.get_campaign_message_template"
  end
  allowable_values = ["name", "editor_type", "html", "text", "created", "updated"]
  if @api_client.config.client_side_validation && opts[:'fields_template'] && !opts[:'fields_template'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"fields_template\", must include one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/api/campaign-messages/{id}/template/'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'fields[template]'] = @api_client.build_collection_param(opts[:'fields_template'], :csv) if !opts[:'fields_template'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['API_REVISION'] || "2023-08-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 => :"CampaignsApi.get_campaign_message_template",
    :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_message_template\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

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

Get Campaign Message Returns a specific message based on a required id.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;10/s&#x60;&lt;br&gt;Steady: &#x60;150/m&#x60; Scopes: &#x60;campaigns:read&#x60;

Parameters:

  • id (String)

    The message ID to be retrieved

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

    the optional parameters

Options Hash (opts):

Returns:

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

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



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
# File 'lib/klaviyo-api-sdk/api/campaigns_api.rb', line 646

def get_campaign_message_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CampaignsApi.get_campaign_message ...'
  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 CampaignsApi.get_campaign_message"
  end
  allowable_values = ["label", "channel", "content", "send_times", "render_options", "render_options.shorten_links", "render_options.add_org_prefix", "render_options.add_info_link", "render_options.add_opt_out_language", "created_at", "updated_at"]
  if @api_client.config.client_side_validation && opts[:'fields_campaign_message'] && !opts[:'fields_campaign_message'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"fields_campaign_message\", must include one of #{allowable_values}"
  end
  allowable_values = ["name", "status", "archived", "audiences", "audiences.included", "audiences.excluded", "send_options", "tracking_options", "send_strategy", "send_strategy.method", "send_strategy.options_static", "send_strategy.options_static.datetime", "send_strategy.options_static.is_local", "send_strategy.options_static.send_past_recipients_immediately", "send_strategy.options_throttled", "send_strategy.options_throttled.datetime", "send_strategy.options_throttled.throttle_percentage", "send_strategy.options_sto", "send_strategy.options_sto.date", "created_at", "scheduled_at", "updated_at", "send_time"]
  if @api_client.config.client_side_validation && opts[:'fields_campaign'] && !opts[:'fields_campaign'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"fields_campaign\", must include one of #{allowable_values}"
  end
  allowable_values = ["name", "editor_type", "html", "text", "created", "updated"]
  if @api_client.config.client_side_validation && opts[:'fields_template'] && !opts[:'fields_template'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"fields_template\", must include one of #{allowable_values}"
  end
  allowable_values = ["campaign", "template"]
  if @api_client.config.client_side_validation && opts[:'include'] && !opts[:'include'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"include\", must include one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/api/campaign-messages/{id}/'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'fields[campaign-message]'] = @api_client.build_collection_param(opts[:'fields_campaign_message'], :csv) if !opts[:'fields_campaign_message'].nil?
  query_params[:'fields[campaign]'] = @api_client.build_collection_param(opts[:'fields_campaign'], :csv) if !opts[:'fields_campaign'].nil?
  query_params[:'fields[template]'] = @api_client.build_collection_param(opts[:'fields_template'], :csv) if !opts[:'fields_template'].nil?
  query_params[:'include'] = @api_client.build_collection_param(opts[:'include'], :csv) if !opts[:'include'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['API_REVISION'] || "2023-08-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 => :"CampaignsApi.get_campaign_message",
    :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_message\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

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

Get Campaign Recipient Estimation Get the estimated recipient count for a campaign with the provided campaign ID. You can refresh this count by using the ‘Create Campaign Recipient Estimation Job` endpoint.
*Rate limits*:
Burst: `10/s`
Steady: `150/m` Scopes: `campaigns:read`

Parameters:

  • id (String)

    The ID of the campaign for which to get the estimated number of recipients

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

    the optional parameters

Options Hash (opts):

Returns:

  • (Hash<String, Object>)


996
997
998
999
# File 'lib/klaviyo-api-sdk/api/campaigns_api.rb', line 996

def get_campaign_recipient_estimation(id, opts = {})
  data, _status_code, _headers = get_campaign_recipient_estimation_with_http_info(id, opts)
  data
end

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

Get Campaign Recipient Estimation Job Retrieve the status of a recipient estimation job triggered with the ‘Create Campaign Recipient Estimation Job` endpoint.
*Rate limits*:
Burst: `10/s`
Steady: `150/m` Scopes: `campaigns:read`

Parameters:

  • id (String)

    The ID of the campaign to get recipient estimation status

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

    the optional parameters

Options Hash (opts):

Returns:

  • (Hash<String, Object>)


1068
1069
1070
1071
# File 'lib/klaviyo-api-sdk/api/campaigns_api.rb', line 1068

def get_campaign_recipient_estimation_job(id, opts = {})
  data, _status_code, _headers = get_campaign_recipient_estimation_job_with_http_info(id, opts)
  data
end

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

Get Campaign Recipient Estimation Job Retrieve the status of a recipient estimation job triggered with the &#x60;Create Campaign Recipient Estimation Job&#x60; endpoint.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;10/s&#x60;&lt;br&gt;Steady: &#x60;150/m&#x60; Scopes: &#x60;campaigns:read&#x60;

Parameters:

  • id (String)

    The ID of the campaign to get recipient estimation status

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

    the optional parameters

Options Hash (opts):

Returns:

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

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



1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
# File 'lib/klaviyo-api-sdk/api/campaigns_api.rb', line 1079

def get_campaign_recipient_estimation_job_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CampaignsApi.get_campaign_recipient_estimation_job ...'
  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 CampaignsApi.get_campaign_recipient_estimation_job"
  end
  allowable_values = ["status"]
  if @api_client.config.client_side_validation && opts[:'fields_campaign_recipient_estimation_job'] && !opts[:'fields_campaign_recipient_estimation_job'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"fields_campaign_recipient_estimation_job\", must include one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/api/campaign-recipient-estimation-jobs/{id}/'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'fields[campaign-recipient-estimation-job]'] = @api_client.build_collection_param(opts[:'fields_campaign_recipient_estimation_job'], :csv) if !opts[:'fields_campaign_recipient_estimation_job'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['API_REVISION'] || "2023-08-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 => :"CampaignsApi.get_campaign_recipient_estimation_job",
    :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_recipient_estimation_job\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

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

Get Campaign Recipient Estimation Get the estimated recipient count for a campaign with the provided campaign ID. You can refresh this count by using the &#x60;Create Campaign Recipient Estimation Job&#x60; endpoint.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;10/s&#x60;&lt;br&gt;Steady: &#x60;150/m&#x60; Scopes: &#x60;campaigns:read&#x60;

Parameters:

  • id (String)

    The ID of the campaign for which to get the estimated number of recipients

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

    the optional parameters

Options Hash (opts):

Returns:

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

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



1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
# File 'lib/klaviyo-api-sdk/api/campaigns_api.rb', line 1007

def get_campaign_recipient_estimation_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CampaignsApi.get_campaign_recipient_estimation ...'
  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 CampaignsApi.get_campaign_recipient_estimation"
  end
  allowable_values = ["estimated_recipient_count"]
  if @api_client.config.client_side_validation && opts[:'fields_campaign_recipient_estimation'] && !opts[:'fields_campaign_recipient_estimation'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"fields_campaign_recipient_estimation\", must include one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/api/campaign-recipient-estimations/{id}/'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'fields[campaign-recipient-estimation]'] = @api_client.build_collection_param(opts[:'fields_campaign_recipient_estimation'], :csv) if !opts[:'fields_campaign_recipient_estimation'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['API_REVISION'] || "2023-08-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 => :"CampaignsApi.get_campaign_recipient_estimation",
    :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_recipient_estimation\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

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

Get Campaign Relationships Campaign Messages Returns the IDs of all messages associated with the given campaign.
*Rate limits*:
Burst: ‘10/s`
Steady: `150/m` Scopes: `campaigns:read`

Parameters:

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

    the optional parameters

Returns:

  • (Hash<String, Object>)


1139
1140
1141
1142
# File 'lib/klaviyo-api-sdk/api/campaigns_api.rb', line 1139

def get_campaign_relationships_campaign_messages(id, opts = {})
  data, _status_code, _headers = get_campaign_relationships_campaign_messages_with_http_info(id, opts)
  data
end

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

Get Campaign Relationships Campaign Messages Returns the IDs of all messages associated with the given campaign.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;10/s&#x60;&lt;br&gt;Steady: &#x60;150/m&#x60; Scopes: &#x60;campaigns:read&#x60;

Parameters:

  • 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



1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
# File 'lib/klaviyo-api-sdk/api/campaigns_api.rb', line 1149

def get_campaign_relationships_campaign_messages_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CampaignsApi.get_campaign_relationships_campaign_messages ...'
  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 CampaignsApi.get_campaign_relationships_campaign_messages"
  end
  # resource path
  local_var_path = '/api/campaigns/{id}/relationships/campaign-messages/'.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-08-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 => :"CampaignsApi.get_campaign_relationships_campaign_messages",
    :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_relationships_campaign_messages\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

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

Get Campaign Relationships Tags Returns the IDs of all tags associated with the given campaign.
*Rate limits*:
Burst: ‘3/s`
Steady: `60/m` Scopes: `campaigns:read` `tags:read`

Parameters:

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

    the optional parameters

Returns:

  • (Hash<String, Object>)


1204
1205
1206
1207
# File 'lib/klaviyo-api-sdk/api/campaigns_api.rb', line 1204

def get_campaign_relationships_tags(id, opts = {})
  data, _status_code, _headers = get_campaign_relationships_tags_with_http_info(id, opts)
  data
end

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

Get Campaign Relationships Tags Returns the IDs of all tags associated with the given campaign.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;3/s&#x60;&lt;br&gt;Steady: &#x60;60/m&#x60; Scopes: &#x60;campaigns:read&#x60; &#x60;tags:read&#x60;

Parameters:

  • 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



1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
# File 'lib/klaviyo-api-sdk/api/campaigns_api.rb', line 1214

def get_campaign_relationships_tags_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CampaignsApi.get_campaign_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 CampaignsApi.get_campaign_relationships_tags"
  end
  # resource path
  local_var_path = '/api/campaigns/{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-08-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 => :"CampaignsApi.get_campaign_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: CampaignsApi#get_campaign_relationships_tags\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

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

Get Campaign Send Job Get a campaign send job
*Rate limits*:
Burst: ‘10/s`
Steady: `150/m` Scopes: `campaigns:read`

Parameters:

  • id (String)

    The ID of the campaign to send

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

    the optional parameters

Options Hash (opts):

Returns:

  • (Hash<String, Object>)


1270
1271
1272
1273
# File 'lib/klaviyo-api-sdk/api/campaigns_api.rb', line 1270

def get_campaign_send_job(id, opts = {})
  data, _status_code, _headers = get_campaign_send_job_with_http_info(id, opts)
  data
end

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

Get Campaign Send Job Get a campaign send job&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;10/s&#x60;&lt;br&gt;Steady: &#x60;150/m&#x60; Scopes: &#x60;campaigns:read&#x60;

Parameters:

  • id (String)

    The ID of the campaign to send

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

    the optional parameters

Options Hash (opts):

Returns:

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

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



1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
# File 'lib/klaviyo-api-sdk/api/campaigns_api.rb', line 1281

def get_campaign_send_job_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CampaignsApi.get_campaign_send_job ...'
  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 CampaignsApi.get_campaign_send_job"
  end
  allowable_values = ["status"]
  if @api_client.config.client_side_validation && opts[:'fields_campaign_send_job'] && !opts[:'fields_campaign_send_job'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"fields_campaign_send_job\", must include one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/api/campaign-send-jobs/{id}/'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'fields[campaign-send-job]'] = @api_client.build_collection_param(opts[:'fields_campaign_send_job'], :csv) if !opts[:'fields_campaign_send_job'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['API_REVISION'] || "2023-08-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 => :"CampaignsApi.get_campaign_send_job",
    :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_send_job\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

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

Get Campaign Tags Return all tags that belong to the given campaign.
*Rate limits*:
Burst: ‘3/s`
Steady: `60/m` Scopes: `campaigns:read` `tags:read`

Parameters:

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

    the optional parameters

Options Hash (opts):

Returns:

  • (Hash<String, Object>)


1342
1343
1344
1345
# File 'lib/klaviyo-api-sdk/api/campaigns_api.rb', line 1342

def get_campaign_tags(id, opts = {})
  data, _status_code, _headers = get_campaign_tags_with_http_info(id, opts)
  data
end

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

Get Campaign Tags Return all tags that belong to the given campaign.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;3/s&#x60;&lt;br&gt;Steady: &#x60;60/m&#x60; Scopes: &#x60;campaigns:read&#x60; &#x60;tags:read&#x60;

Parameters:

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

    the optional parameters

Options Hash (opts):

Returns:

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

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



1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
# File 'lib/klaviyo-api-sdk/api/campaigns_api.rb', line 1353

def get_campaign_tags_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CampaignsApi.get_campaign_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 CampaignsApi.get_campaign_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/campaigns/{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-08-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 => :"CampaignsApi.get_campaign_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: CampaignsApi#get_campaign_tags\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

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

Get Campaign Returns a specific campaign based on a required id.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;10/s&#x60;&lt;br&gt;Steady: &#x60;150/m&#x60; Scopes: &#x60;campaigns:read&#x60;

Parameters:

  • id (String)

    The campaign ID to be retrieved

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

    the optional parameters

Options Hash (opts):

Returns:

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

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



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
# File 'lib/klaviyo-api-sdk/api/campaigns_api.rb', line 460

def get_campaign_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CampaignsApi.get_campaign ...'
  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 CampaignsApi.get_campaign"
  end
  allowable_values = ["label", "channel", "content", "send_times", "render_options", "render_options.shorten_links", "render_options.add_org_prefix", "render_options.add_info_link", "render_options.add_opt_out_language", "created_at", "updated_at"]
  if @api_client.config.client_side_validation && opts[:'fields_campaign_message'] && !opts[:'fields_campaign_message'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"fields_campaign_message\", must include one of #{allowable_values}"
  end
  allowable_values = ["name", "status", "archived", "audiences", "audiences.included", "audiences.excluded", "send_options", "tracking_options", "send_strategy", "send_strategy.method", "send_strategy.options_static", "send_strategy.options_static.datetime", "send_strategy.options_static.is_local", "send_strategy.options_static.send_past_recipients_immediately", "send_strategy.options_throttled", "send_strategy.options_throttled.datetime", "send_strategy.options_throttled.throttle_percentage", "send_strategy.options_sto", "send_strategy.options_sto.date", "created_at", "scheduled_at", "updated_at", "send_time"]
  if @api_client.config.client_side_validation && opts[:'fields_campaign'] && !opts[:'fields_campaign'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"fields_campaign\", must include one of #{allowable_values}"
  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
  allowable_values = ["campaign-messages", "tags"]
  if @api_client.config.client_side_validation && opts[:'include'] && !opts[:'include'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"include\", must include one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/api/campaigns/{id}/'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'fields[campaign-message]'] = @api_client.build_collection_param(opts[:'fields_campaign_message'], :csv) if !opts[:'fields_campaign_message'].nil?
  query_params[:'fields[campaign]'] = @api_client.build_collection_param(opts[:'fields_campaign'], :csv) if !opts[:'fields_campaign'].nil?
  query_params[:'fields[tag]'] = @api_client.build_collection_param(opts[:'fields_tag'], :csv) if !opts[:'fields_tag'].nil?
  query_params[:'include'] = @api_client.build_collection_param(opts[:'include'], :csv) if !opts[:'include'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['API_REVISION'] || "2023-08-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 => :"CampaignsApi.get_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(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: CampaignsApi#get_campaign\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

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

Get Campaigns Returns some or all campaigns based on filters. A channel filter is required to list campaigns. Please provide either: ‘?filter=equals(messages.channel,’email’)‘ to list email campaigns, or `?filter=equals(messages.channel,’sms’)‘ to list SMS campaigns.
*Rate limits*:
Burst: `10/s`
Steady: `150/m` Scopes: `campaigns:read`

Parameters:

  • filter (String)

    For more information please visit developers.klaviyo.com/en/v2023-08-15/reference/api-overview#filtering&lt;br&gt;Allowed field(s)/operator(s):&lt;br&gt;&#x60;messages.channel&#x60;: &#x60;equals&#x60;&lt;br&gt;&#x60;name&#x60;: &#x60;contains&#x60;&lt;br&gt;&#x60;status&#x60;: &#x60;any&#x60;, &#x60;equals&#x60;&lt;br&gt;&#x60;archived&#x60;: &#x60;equals&#x60;&lt;br&gt;&#x60;created_at&#x60;: &#x60;greater-or-equal&#x60;, &#x60;greater-than&#x60;, &#x60;less-or-equal&#x60;, &#x60;less-than&#x60;&lt;br&gt;&#x60;scheduled_at&#x60;: &#x60;greater-or-equal&#x60;, &#x60;greater-than&#x60;, &#x60;less-or-equal&#x60;, &#x60;less-than&#x60;&lt;br&gt;&#x60;updated_at&#x60;: &#x60;greater-or-equal&#x60;, &#x60;greater-than&#x60;, &#x60;less-or-equal&#x60;, &#x60;less-than&#x60;

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

    the optional parameters

Options Hash (opts):

Returns:

  • (Hash<String, Object>)


1419
1420
1421
1422
# File 'lib/klaviyo-api-sdk/api/campaigns_api.rb', line 1419

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

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

Get Campaigns Returns some or all campaigns based on filters. A channel filter is required to list campaigns. Please provide either: &#x60;?filter&#x3D;equals(messages.channel,&#39;email&#39;)&#x60; to list email campaigns, or &#x60;?filter&#x3D;equals(messages.channel,&#39;sms&#39;)&#x60; to list SMS campaigns.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;10/s&#x60;&lt;br&gt;Steady: &#x60;150/m&#x60; Scopes: &#x60;campaigns:read&#x60;

Parameters:

  • filter (String)

    For more information please visit developers.klaviyo.com/en/v2023-08-15/reference/api-overview#filtering&lt;br&gt;Allowed field(s)/operator(s):&lt;br&gt;&#x60;messages.channel&#x60;: &#x60;equals&#x60;&lt;br&gt;&#x60;name&#x60;: &#x60;contains&#x60;&lt;br&gt;&#x60;status&#x60;: &#x60;any&#x60;, &#x60;equals&#x60;&lt;br&gt;&#x60;archived&#x60;: &#x60;equals&#x60;&lt;br&gt;&#x60;created_at&#x60;: &#x60;greater-or-equal&#x60;, &#x60;greater-than&#x60;, &#x60;less-or-equal&#x60;, &#x60;less-than&#x60;&lt;br&gt;&#x60;scheduled_at&#x60;: &#x60;greater-or-equal&#x60;, &#x60;greater-than&#x60;, &#x60;less-or-equal&#x60;, &#x60;less-than&#x60;&lt;br&gt;&#x60;updated_at&#x60;: &#x60;greater-or-equal&#x60;, &#x60;greater-than&#x60;, &#x60;less-or-equal&#x60;, &#x60;less-than&#x60;

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

    the optional parameters

Options Hash (opts):

Returns:

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

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



1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
# File 'lib/klaviyo-api-sdk/api/campaigns_api.rb', line 1435

def get_campaigns_with_http_info(filter, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CampaignsApi.get_campaigns ...'
  end
  # verify the required parameter 'filter' is set
  if @api_client.config.client_side_validation && filter.nil?
    fail ArgumentError, "Missing the required parameter 'filter' when calling CampaignsApi.get_campaigns"
  end
  allowable_values = ["label", "channel", "content", "send_times", "render_options", "render_options.shorten_links", "render_options.add_org_prefix", "render_options.add_info_link", "render_options.add_opt_out_language", "created_at", "updated_at"]
  if @api_client.config.client_side_validation && opts[:'fields_campaign_message'] && !opts[:'fields_campaign_message'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"fields_campaign_message\", must include one of #{allowable_values}"
  end
  allowable_values = ["name", "status", "archived", "audiences", "audiences.included", "audiences.excluded", "send_options", "tracking_options", "send_strategy", "send_strategy.method", "send_strategy.options_static", "send_strategy.options_static.datetime", "send_strategy.options_static.is_local", "send_strategy.options_static.send_past_recipients_immediately", "send_strategy.options_throttled", "send_strategy.options_throttled.datetime", "send_strategy.options_throttled.throttle_percentage", "send_strategy.options_sto", "send_strategy.options_sto.date", "created_at", "scheduled_at", "updated_at", "send_time"]
  if @api_client.config.client_side_validation && opts[:'fields_campaign'] && !opts[:'fields_campaign'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"fields_campaign\", must include one of #{allowable_values}"
  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
  allowable_values = ["campaign-messages", "tags"]
  if @api_client.config.client_side_validation && opts[:'include'] && !opts[:'include'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"include\", must include one of #{allowable_values}"
  end
  allowable_values = ["created_at", "-created_at", "id", "-id", "name", "-name", "scheduled_at", "-scheduled_at", "updated_at", "-updated_at"]
  if @api_client.config.client_side_validation && opts[:'sort'] && !allowable_values.include?(opts[:'sort'])
    fail ArgumentError, "invalid value for \"sort\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/api/campaigns/'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'filter'] = filter
  query_params[:'fields[campaign-message]'] = @api_client.build_collection_param(opts[:'fields_campaign_message'], :csv) if !opts[:'fields_campaign_message'].nil?
  query_params[:'fields[campaign]'] = @api_client.build_collection_param(opts[:'fields_campaign'], :csv) if !opts[:'fields_campaign'].nil?
  query_params[:'fields[tag]'] = @api_client.build_collection_param(opts[:'fields_tag'], :csv) if !opts[:'fields_tag'].nil?
  query_params[:'include'] = @api_client.build_collection_param(opts[:'include'], :csv) if !opts[:'include'].nil?
  query_params[:'page[cursor]'] = opts[:'page_cursor'] if !opts[:'page_cursor'].nil?
  query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['API_REVISION'] || "2023-08-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 => :"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

#update_campaign(id, campaign_partial_update_query, opts = {}) ⇒ Hash<String, Object>

Update Campaign Update a campaign with the given campaign ID.
*Rate limits*:
Burst: ‘10/s`
Steady: `150/m` Scopes: `campaigns:write`

Parameters:

  • id (String)

    The campaign ID to be retrieved

  • campaign_partial_update_query (CampaignPartialUpdateQuery)

    Update a campaign and return it

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

    the optional parameters

Returns:

  • (Hash<String, Object>)


1518
1519
1520
1521
# File 'lib/klaviyo-api-sdk/api/campaigns_api.rb', line 1518

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

#update_campaign_message(id, campaign_message_partial_update_query, opts = {}) ⇒ Hash<String, Object>

Update Campaign Message Update a campaign message
*Rate limits*:
Burst: ‘10/s`
Steady: `150/m` Scopes: `campaigns:write`

Parameters:

  • id (String)

    The message ID to be retrieved

  • campaign_message_partial_update_query (CampaignMessagePartialUpdateQuery)

    Update a message and return it

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

    the optional parameters

Returns:

  • (Hash<String, Object>)


1594
1595
1596
1597
# File 'lib/klaviyo-api-sdk/api/campaigns_api.rb', line 1594

def update_campaign_message(id, campaign_message_partial_update_query, opts = {})
  data, _status_code, _headers = update_campaign_message_with_http_info(id, campaign_message_partial_update_query, opts)
  data
end

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

Update Campaign Message Update a campaign message&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;10/s&#x60;&lt;br&gt;Steady: &#x60;150/m&#x60; Scopes: &#x60;campaigns:write&#x60;

Parameters:

  • id (String)

    The message ID to be retrieved

  • campaign_message_partial_update_query (CampaignMessagePartialUpdateQuery)

    Update a message and return it

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

    the optional parameters

Returns:

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

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



1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
# File 'lib/klaviyo-api-sdk/api/campaigns_api.rb', line 1605

def update_campaign_message_with_http_info(id, campaign_message_partial_update_query, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CampaignsApi.update_campaign_message ...'
  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 CampaignsApi.update_campaign_message"
  end
  # verify the required parameter 'campaign_message_partial_update_query' is set
  if @api_client.config.client_side_validation && campaign_message_partial_update_query.nil?
    fail ArgumentError, "Missing the required parameter 'campaign_message_partial_update_query' when calling CampaignsApi.update_campaign_message"
  end
  # resource path
  local_var_path = '/api/campaign-messages/{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-08-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(campaign_message_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 => :"CampaignsApi.update_campaign_message",
    :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: CampaignsApi#update_campaign_message\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#update_campaign_send_job(id, campaign_send_job_partial_update_query, opts = {}) ⇒ nil

Update Campaign Send Job Permanently cancel the campaign, setting the status to CANCELED or revert the campaign, setting the status back to DRAFT
*Rate limits*:
Burst: ‘10/s`
Steady: `150/m` Scopes: `campaigns:write`

Parameters:

  • id (String)

    The ID of the currently sending campaign to cancel or revert

  • campaign_send_job_partial_update_query (CampaignSendJobPartialUpdateQuery)

    Permanently cancel the campaign, setting the status to CANCELED or revert the campaign, setting the status back to DRAFT

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

    the optional parameters

Returns:

  • (nil)


1670
1671
1672
1673
# File 'lib/klaviyo-api-sdk/api/campaigns_api.rb', line 1670

def update_campaign_send_job(id, campaign_send_job_partial_update_query, opts = {})
  update_campaign_send_job_with_http_info(id, campaign_send_job_partial_update_query, opts)
  nil
end

#update_campaign_send_job_with_http_info(id, campaign_send_job_partial_update_query, opts = {}) ⇒ Array<(nil, Integer, Hash)>

Update Campaign Send Job Permanently cancel the campaign, setting the status to CANCELED or revert the campaign, setting the status back to DRAFT&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;10/s&#x60;&lt;br&gt;Steady: &#x60;150/m&#x60; Scopes: &#x60;campaigns:write&#x60;

Parameters:

  • id (String)

    The ID of the currently sending campaign to cancel or revert

  • campaign_send_job_partial_update_query (CampaignSendJobPartialUpdateQuery)

    Permanently cancel the campaign, setting the status to CANCELED or revert the campaign, setting the status back to DRAFT

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

    the optional parameters

Returns:

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

    nil, response status code and response headers



1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
# File 'lib/klaviyo-api-sdk/api/campaigns_api.rb', line 1681

def update_campaign_send_job_with_http_info(id, campaign_send_job_partial_update_query, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CampaignsApi.update_campaign_send_job ...'
  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 CampaignsApi.update_campaign_send_job"
  end
  # verify the required parameter 'campaign_send_job_partial_update_query' is set
  if @api_client.config.client_side_validation && campaign_send_job_partial_update_query.nil?
    fail ArgumentError, "Missing the required parameter 'campaign_send_job_partial_update_query' when calling CampaignsApi.update_campaign_send_job"
  end
  # resource path
  local_var_path = '/api/campaign-send-jobs/{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-08-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(campaign_send_job_partial_update_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 => :"CampaignsApi.update_campaign_send_job",
    :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: CampaignsApi#update_campaign_send_job\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

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

Update Campaign Update a campaign with the given campaign ID.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;10/s&#x60;&lt;br&gt;Steady: &#x60;150/m&#x60; Scopes: &#x60;campaigns:write&#x60;

Parameters:

  • id (String)

    The campaign ID to be retrieved

  • campaign_partial_update_query (CampaignPartialUpdateQuery)

    Update a campaign and return it

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

    the optional parameters

Returns:

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

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



1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
# File 'lib/klaviyo-api-sdk/api/campaigns_api.rb', line 1529

def update_campaign_with_http_info(id, campaign_partial_update_query, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CampaignsApi.update_campaign ...'
  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 CampaignsApi.update_campaign"
  end
  # verify the required parameter 'campaign_partial_update_query' is set
  if @api_client.config.client_side_validation && campaign_partial_update_query.nil?
    fail ArgumentError, "Missing the required parameter 'campaign_partial_update_query' when calling CampaignsApi.update_campaign"
  end
  # resource path
  local_var_path = '/api/campaigns/{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-08-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(campaign_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 => :"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(:PATCH, 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