Class: KlaviyoAPI::CouponsApi

Inherits:
Object
  • Object
show all
Defined in:
lib/klaviyo-api-sdk/api/coupons_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ CouponsApi

Returns a new instance of CouponsApi.



19
20
21
# File 'lib/klaviyo-api-sdk/api/coupons_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/coupons_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#bulk_create_coupon_codes(coupon_code_create_job_create_query, opts = {}) ⇒ Hash<String, Object> Also known as: spawn_coupon_code_bulk_create_job, create_coupon_code_bulk_create_job

Bulk Create Coupon Codes Create a coupon-code-bulk-create-job to bulk create a list of coupon codes. Max number of coupon codes per job we allow for is 1000. Max number of jobs queued at once we allow for is 100.
*Rate limits*:
Burst: ‘75/s`
Steady: `700/m` Scopes: `coupon-codes:write`

Parameters:

Returns:

  • (Hash<String, Object>)


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

def bulk_create_coupon_codes(coupon_code_create_job_create_query, opts = {})
  data, _status_code, _headers = bulk_create_coupon_codes_with_http_info(coupon_code_create_job_create_query, opts)
  data
end

#bulk_create_coupon_codes_with_http_info(coupon_code_create_job_create_query, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)> Also known as: spawn_coupon_code_bulk_create_job_with_http_info, create_coupon_code_bulk_create_job_with_http_info

Bulk Create Coupon Codes Create a coupon-code-bulk-create-job to bulk create a list of coupon codes. Max number of coupon codes per job we allow for is 1000. Max number of jobs queued at once we allow for is 100.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;75/s&#x60;&lt;br&gt;Steady: &#x60;700/m&#x60; Scopes: &#x60;coupon-codes:write&#x60;

Parameters:

Returns:

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

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



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/klaviyo-api-sdk/api/coupons_api.rb', line 43

def bulk_create_coupon_codes_with_http_info(coupon_code_create_job_create_query, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CouponsApi.bulk_create_coupon_codes ...'
  end
  # verify the required parameter 'coupon_code_create_job_create_query' is set
  if @api_client.config.client_side_validation && coupon_code_create_job_create_query.nil?
    fail ArgumentError, "Missing the required parameter 'coupon_code_create_job_create_query' when calling CouponsApi.bulk_create_coupon_codes"
  end
  # resource path
  local_var_path = '/api/coupon-code-bulk-create-jobs'

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

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2025-04-15"
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/vnd.api+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(coupon_code_create_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', 'OAuth']

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

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

Create Coupon Creates a new coupon.
*Rate limits*:
Burst: ‘3/s`
Steady: `60/m` Scopes: `coupons:write`

Parameters:

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

    the optional parameters

Returns:

  • (Hash<String, Object>)


109
110
111
112
# File 'lib/klaviyo-api-sdk/api/coupons_api.rb', line 109

def create_coupon(coupon_create_query, opts = {})
  data, _status_code, _headers = create_coupon_with_http_info(coupon_create_query, opts)
  data
end

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

Create Coupon Code Synchronously creates a coupon code for the given coupon.
*Rate limits*:
Burst: ‘350/s`
Steady: `3500/m` Scopes: `coupon-codes:write`

Parameters:

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

    the optional parameters

Returns:

  • (Hash<String, Object>)


179
180
181
182
# File 'lib/klaviyo-api-sdk/api/coupons_api.rb', line 179

def create_coupon_code(coupon_code_create_query, opts = {})
  data, _status_code, _headers = create_coupon_code_with_http_info(coupon_code_create_query, opts)
  data
end

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

Create Coupon Code Synchronously creates a coupon code for the given coupon.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;350/s&#x60;&lt;br&gt;Steady: &#x60;3500/m&#x60; Scopes: &#x60;coupon-codes:write&#x60;

Parameters:

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

    the optional parameters

Returns:

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

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



189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
# File 'lib/klaviyo-api-sdk/api/coupons_api.rb', line 189

def create_coupon_code_with_http_info(coupon_code_create_query, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CouponsApi.create_coupon_code ...'
  end
  # verify the required parameter 'coupon_code_create_query' is set
  if @api_client.config.client_side_validation && coupon_code_create_query.nil?
    fail ArgumentError, "Missing the required parameter 'coupon_code_create_query' when calling CouponsApi.create_coupon_code"
  end
  # resource path
  local_var_path = '/api/coupon-codes'

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

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2025-04-15"
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/vnd.api+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(coupon_code_create_query)

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

  # auth_names
  auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth']

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

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

Create Coupon Creates a new coupon.&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;coupons:write&#x60;

Parameters:

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

    the optional parameters

Returns:

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

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



119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# File 'lib/klaviyo-api-sdk/api/coupons_api.rb', line 119

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

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

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2025-04-15"
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/vnd.api+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(coupon_create_query)

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

  # auth_names
  auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth']

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

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

Delete Coupon Delete the coupon with the given coupon ID.
*Rate limits*:
Burst: ‘3/s`
Steady: `60/m` Scopes: `coupons:write`

Parameters:

  • id (String)

    The internal id of a Coupon is equivalent to its external id stored within an integration.

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

    the optional parameters

Returns:

  • (nil)


249
250
251
252
# File 'lib/klaviyo-api-sdk/api/coupons_api.rb', line 249

def delete_coupon(id, opts = {})
  delete_coupon_with_http_info(id, opts)
  nil
end

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

Delete Coupon Code Deletes a coupon code specified by the given identifier synchronously. If a profile has been assigned to the coupon code, an exception will be raised
*Rate limits*:
Burst: ‘350/s`
Steady: `3500/m` Scopes: `coupon-codes:write`

Parameters:

  • id (String)

    The id of a coupon code is a combination of its unique code and the id of the coupon it is associated with.

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

    the optional parameters

Returns:

  • (nil)


314
315
316
317
# File 'lib/klaviyo-api-sdk/api/coupons_api.rb', line 314

def delete_coupon_code(id, opts = {})
  delete_coupon_code_with_http_info(id, opts)
  nil
end

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

Delete Coupon Code Deletes a coupon code specified by the given identifier synchronously. If a profile has been assigned to the coupon code, an exception will be raised&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;350/s&#x60;&lt;br&gt;Steady: &#x60;3500/m&#x60; Scopes: &#x60;coupon-codes:write&#x60;

Parameters:

  • id (String)

    The id of a coupon code is a combination of its unique code and the id of the coupon it is associated with.

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

    the optional parameters

Returns:

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

    nil, response status code and response headers



324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
# File 'lib/klaviyo-api-sdk/api/coupons_api.rb', line 324

def delete_coupon_code_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CouponsApi.delete_coupon_code ...'
  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 CouponsApi.delete_coupon_code"
  end
  # resource path
  local_var_path = '/api/coupon-codes/{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['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2025-04-15"
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+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', 'OAuth']

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

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

Delete Coupon Delete the coupon with the given coupon ID.&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;coupons:write&#x60;

Parameters:

  • id (String)

    The internal id of a Coupon is equivalent to its external id stored within an integration.

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

    the optional parameters

Returns:

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

    nil, response status code and response headers



259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
# File 'lib/klaviyo-api-sdk/api/coupons_api.rb', line 259

def delete_coupon_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CouponsApi.delete_coupon ...'
  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 CouponsApi.delete_coupon"
  end
  # resource path
  local_var_path = '/api/coupons/{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['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2025-04-15"
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+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', 'OAuth']

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

#get_bulk_create_coupon_code_jobs(opts = {}) ⇒ Hash<String, Object> Also known as: get_coupon_code_bulk_create_jobs

Get Bulk Create Coupon Code Jobs Get all coupon code bulk create jobs. Returns a maximum of 100 jobs per request.
*Rate limits*:
Burst: ‘75/s`
Steady: `700/m` Scopes: `coupon-codes:read`

Parameters:

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

    the optional parameters

Options Hash (opts):

Returns:

  • (Hash<String, Object>)


381
382
383
384
# File 'lib/klaviyo-api-sdk/api/coupons_api.rb', line 381

def get_bulk_create_coupon_code_jobs(opts = {})
  data, _status_code, _headers = get_bulk_create_coupon_code_jobs_with_http_info(opts)
  data
end

#get_bulk_create_coupon_code_jobs_with_http_info(opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)> Also known as: get_coupon_code_bulk_create_jobs_with_http_info

Get Bulk Create Coupon Code Jobs Get all coupon code bulk create jobs. Returns a maximum of 100 jobs per request.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;75/s&#x60;&lt;br&gt;Steady: &#x60;700/m&#x60; Scopes: &#x60;coupon-codes:read&#x60;

Parameters:

  • 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



396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
# File 'lib/klaviyo-api-sdk/api/coupons_api.rb', line 396

def get_bulk_create_coupon_code_jobs_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CouponsApi.get_bulk_create_coupon_code_jobs ...'
  end
  allowable_values = ["status", "created_at", "total_count", "completed_count", "failed_count", "completed_at", "errors", "expires_at"]
  if @api_client.config.client_side_validation && opts[:'fields_coupon_code_bulk_create_job'] && !opts[:'fields_coupon_code_bulk_create_job'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"fields_coupon_code_bulk_create_job\", must include one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/api/coupon-code-bulk-create-jobs'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'fields[coupon-code-bulk-create-job]'] = @api_client.build_collection_param(opts[:'fields_coupon_code_bulk_create_job'], :csv) if !opts[:'fields_coupon_code_bulk_create_job'].nil?
  query_params[:'filter'] = opts[:'filter'] if !opts[:'filter'].nil?
  query_params[:'page[cursor]'] = opts[:'page_cursor'] if !opts[:'page_cursor'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2025-04-15"
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+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', 'OAuth']

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

#get_bulk_create_coupon_codes_job(job_id, opts = {}) ⇒ Hash<String, Object> Also known as: get_coupon_code_bulk_create_job

Get Bulk Create Coupon Codes Job Get a coupon code bulk create job with the given job ID.
*Rate limits*:
Burst: ‘75/s`
Steady: `700/m` Scopes: `coupon-codes:read`

Parameters:

  • job_id (String)

    ID of the job to retrieve.

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

    the optional parameters

Options Hash (opts):

Returns:

  • (Hash<String, Object>)


460
461
462
463
# File 'lib/klaviyo-api-sdk/api/coupons_api.rb', line 460

def get_bulk_create_coupon_codes_job(job_id, opts = {})
  data, _status_code, _headers = get_bulk_create_coupon_codes_job_with_http_info(job_id, opts)
  data
end

#get_bulk_create_coupon_codes_job_with_http_info(job_id, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)> Also known as: get_coupon_code_bulk_create_job_with_http_info

Get Bulk Create Coupon Codes Job Get a coupon code bulk create job with the given job ID.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;75/s&#x60;&lt;br&gt;Steady: &#x60;700/m&#x60; Scopes: &#x60;coupon-codes:read&#x60;

Parameters:

  • job_id (String)

    ID of the job to retrieve.

  • 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



476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
# File 'lib/klaviyo-api-sdk/api/coupons_api.rb', line 476

def get_bulk_create_coupon_codes_job_with_http_info(job_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CouponsApi.get_bulk_create_coupon_codes_job ...'
  end
  # verify the required parameter 'job_id' is set
  if @api_client.config.client_side_validation && job_id.nil?
    fail ArgumentError, "Missing the required parameter 'job_id' when calling CouponsApi.get_bulk_create_coupon_codes_job"
  end
  allowable_values = ["status", "created_at", "total_count", "completed_count", "failed_count", "completed_at", "errors", "expires_at"]
  if @api_client.config.client_side_validation && opts[:'fields_coupon_code_bulk_create_job'] && !opts[:'fields_coupon_code_bulk_create_job'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"fields_coupon_code_bulk_create_job\", must include one of #{allowable_values}"
  end
  allowable_values = ["unique_code", "expires_at", "status"]
  if @api_client.config.client_side_validation && opts[:'fields_coupon_code'] && !opts[:'fields_coupon_code'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"fields_coupon_code\", must include one of #{allowable_values}"
  end
  allowable_values = ["coupon-codes"]
  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/coupon-code-bulk-create-jobs/{job_id}'.sub('{' + 'job_id' + '}', CGI.escape(job_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'fields[coupon-code-bulk-create-job]'] = @api_client.build_collection_param(opts[:'fields_coupon_code_bulk_create_job'], :csv) if !opts[:'fields_coupon_code_bulk_create_job'].nil?
  query_params[:'fields[coupon-code]'] = @api_client.build_collection_param(opts[:'fields_coupon_code'], :csv) if !opts[:'fields_coupon_code'].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['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2025-04-15"
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+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', 'OAuth']

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

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

Get Coupon Get a specific coupon with the given coupon ID.
*Rate limits*:
Burst: ‘75/s`
Steady: `700/m` Scopes: `coupons:read`

Parameters:

  • id (String)

    The internal id of a Coupon is equivalent to its external id stored within an integration.

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

    the optional parameters

Options Hash (opts):

Returns:

  • (Hash<String, Object>)


550
551
552
553
# File 'lib/klaviyo-api-sdk/api/coupons_api.rb', line 550

def get_coupon(id, opts = {})
  data, _status_code, _headers = get_coupon_with_http_info(id, opts)
  data
end

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

Get Coupon Code Returns a Coupon Code specified by the given identifier.
*Rate limits*:
Burst: ‘350/s`
Steady: `3500/m` Scopes: `coupon-codes:read`

Parameters:

  • id (String)

    The id of a coupon code is a combination of its unique code and the id of the coupon it is associated with.

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

    the optional parameters

Options Hash (opts):

Returns:

  • (Hash<String, Object>)


624
625
626
627
# File 'lib/klaviyo-api-sdk/api/coupons_api.rb', line 624

def get_coupon_code(id, opts = {})
  data, _status_code, _headers = get_coupon_code_with_http_info(id, opts)
  data
end

#get_coupon_code_ids_for_coupon(id, opts = {}) ⇒ Hash<String, Object> Also known as: get_coupon_code_relationships_coupon, get_code_ids_for_coupon, get_coupon_relationships_codes

Get Coupon Code IDs for Coupon Gets a list of coupon code relationships associated with the given coupon id
*Rate limits*:
Burst: ‘75/s`
Steady: `700/m` Scopes: `coupon-codes:read`

Parameters:

  • id (String)

    The ID of the coupon to look up the relationship of.

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

    the optional parameters

Options Hash (opts):

Returns:

  • (Hash<String, Object>)


709
710
711
712
# File 'lib/klaviyo-api-sdk/api/coupons_api.rb', line 709

def get_coupon_code_ids_for_coupon(id, opts = {})
  data, _status_code, _headers = get_coupon_code_ids_for_coupon_with_http_info(id, opts)
  data
end

#get_coupon_code_ids_for_coupon_with_http_info(id, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)> Also known as: get_coupon_code_relationships_coupon_with_http_info, get_code_ids_for_coupon_with_http_info, get_coupon_relationships_codes_with_http_info

Get Coupon Code IDs for Coupon Gets a list of coupon code relationships associated with the given coupon id&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;75/s&#x60;&lt;br&gt;Steady: &#x60;700/m&#x60; Scopes: &#x60;coupon-codes:read&#x60;

Parameters:

  • id (String)

    The ID of the coupon to look up the relationship of.

  • 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



730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
# File 'lib/klaviyo-api-sdk/api/coupons_api.rb', line 730

def get_coupon_code_ids_for_coupon_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CouponsApi.get_coupon_code_ids_for_coupon ...'
  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 CouponsApi.get_coupon_code_ids_for_coupon"
  end
  # resource path
  local_var_path = '/api/coupons/{id}/relationships/coupon-codes'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

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

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2025-04-15"
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+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', 'OAuth']

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

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

Get Coupon Code Returns a Coupon Code specified by the given identifier.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;350/s&#x60;&lt;br&gt;Steady: &#x60;3500/m&#x60; Scopes: &#x60;coupon-codes:read&#x60;

Parameters:

  • id (String)

    The id of a coupon code is a combination of its unique code and the id of the coupon it is associated with.

  • 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



637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
# File 'lib/klaviyo-api-sdk/api/coupons_api.rb', line 637

def get_coupon_code_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CouponsApi.get_coupon_code ...'
  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 CouponsApi.get_coupon_code"
  end
  allowable_values = ["unique_code", "expires_at", "status"]
  if @api_client.config.client_side_validation && opts[:'fields_coupon_code'] && !opts[:'fields_coupon_code'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"fields_coupon_code\", must include one of #{allowable_values}"
  end
  allowable_values = ["external_id", "description"]
  if @api_client.config.client_side_validation && opts[:'fields_coupon'] && !opts[:'fields_coupon'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"fields_coupon\", must include one of #{allowable_values}"
  end
  allowable_values = ["coupon"]
  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/coupon-codes/{id}'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'fields[coupon-code]'] = @api_client.build_collection_param(opts[:'fields_coupon_code'], :csv) if !opts[:'fields_coupon_code'].nil?
  query_params[:'fields[coupon]'] = @api_client.build_collection_param(opts[:'fields_coupon'], :csv) if !opts[:'fields_coupon'].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['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2025-04-15"
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+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', 'OAuth']

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

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

Get Coupon Codes Gets a list of coupon codes associated with a coupon/coupons or a profile/profiles. A coupon/coupons or a profile/profiles must be provided as required filter params.
*Rate limits*:
Burst: ‘350/s`
Steady: `3500/m` Scopes: `coupon-codes:read`

Parameters:

  • filter (String)

    For more information please visit developers.klaviyo.com/en/v2025-04-15/reference/api-overview#filtering&lt;br&gt;Allowed field(s)/operator(s):&lt;br&gt;&#x60;expires_at&#x60;: &#x60;greater-or-equal&#x60;, &#x60;greater-than&#x60;, &#x60;less-or-equal&#x60;, &#x60;less-than&#x60;&lt;br&gt;&#x60;status&#x60;: &#x60;equals&#x60;&lt;br&gt;&#x60;coupon.id&#x60;: &#x60;any&#x60;, &#x60;equals&#x60;&lt;br&gt;&#x60;profile.id&#x60;: &#x60;any&#x60;, &#x60;equals&#x60;

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

    the optional parameters

Options Hash (opts):

Returns:

  • (Hash<String, Object>)


800
801
802
803
# File 'lib/klaviyo-api-sdk/api/coupons_api.rb', line 800

def get_coupon_codes(filter, opts = {})
  data, _status_code, _headers = get_coupon_codes_with_http_info(filter, opts)
  data
end

#get_coupon_codes_for_coupon(id, opts = {}) ⇒ Hash<String, Object> Also known as: get_coupon_coupon_codes, get_codes_for_coupon

Get Coupon Codes for Coupon Gets a list of coupon codes associated with the given coupon id
*Rate limits*:
Burst: ‘75/s`
Steady: `700/m` Scopes: `coupon-codes:read`

Parameters:

  • id (String)

    The ID of the coupon to look up the relationship of.

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

    the optional parameters

Options Hash (opts):

Returns:

  • (Hash<String, Object>)


889
890
891
892
# File 'lib/klaviyo-api-sdk/api/coupons_api.rb', line 889

def get_coupon_codes_for_coupon(id, opts = {})
  data, _status_code, _headers = get_coupon_codes_for_coupon_with_http_info(id, opts)
  data
end

#get_coupon_codes_for_coupon_with_http_info(id, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)> Also known as: get_coupon_coupon_codes_with_http_info, get_codes_for_coupon_with_http_info

Get Coupon Codes for Coupon Gets a list of coupon codes associated with the given coupon id&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;75/s&#x60;&lt;br&gt;Steady: &#x60;700/m&#x60; Scopes: &#x60;coupon-codes:read&#x60;

Parameters:

  • id (String)

    The ID of the coupon to look up the relationship of.

  • 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



908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
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
# File 'lib/klaviyo-api-sdk/api/coupons_api.rb', line 908

def get_coupon_codes_for_coupon_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CouponsApi.get_coupon_codes_for_coupon ...'
  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 CouponsApi.get_coupon_codes_for_coupon"
  end
  allowable_values = ["unique_code", "expires_at", "status"]
  if @api_client.config.client_side_validation && opts[:'fields_coupon_code'] && !opts[:'fields_coupon_code'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"fields_coupon_code\", must include one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/api/coupons/{id}/coupon-codes'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'fields[coupon-code]'] = @api_client.build_collection_param(opts[:'fields_coupon_code'], :csv) if !opts[:'fields_coupon_code'].nil?
  query_params[:'filter'] = opts[:'filter'] if !opts[:'filter'].nil?
  query_params[:'page[cursor]'] = opts[:'page_cursor'] if !opts[:'page_cursor'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2025-04-15"
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+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', 'OAuth']

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

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

Get Coupon Codes Gets a list of coupon codes associated with a coupon/coupons or a profile/profiles. A coupon/coupons or a profile/profiles must be provided as required filter params.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;350/s&#x60;&lt;br&gt;Steady: &#x60;3500/m&#x60; Scopes: &#x60;coupon-codes:read&#x60;

Parameters:

  • filter (String)

    For more information please visit developers.klaviyo.com/en/v2025-04-15/reference/api-overview#filtering&lt;br&gt;Allowed field(s)/operator(s):&lt;br&gt;&#x60;expires_at&#x60;: &#x60;greater-or-equal&#x60;, &#x60;greater-than&#x60;, &#x60;less-or-equal&#x60;, &#x60;less-than&#x60;&lt;br&gt;&#x60;status&#x60;: &#x60;equals&#x60;&lt;br&gt;&#x60;coupon.id&#x60;: &#x60;any&#x60;, &#x60;equals&#x60;&lt;br&gt;&#x60;profile.id&#x60;: &#x60;any&#x60;, &#x60;equals&#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



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
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
# File 'lib/klaviyo-api-sdk/api/coupons_api.rb', line 814

def get_coupon_codes_with_http_info(filter, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CouponsApi.get_coupon_codes ...'
  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 CouponsApi.get_coupon_codes"
  end
  allowable_values = ["unique_code", "expires_at", "status"]
  if @api_client.config.client_side_validation && opts[:'fields_coupon_code'] && !opts[:'fields_coupon_code'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"fields_coupon_code\", must include one of #{allowable_values}"
  end
  allowable_values = ["external_id", "description"]
  if @api_client.config.client_side_validation && opts[:'fields_coupon'] && !opts[:'fields_coupon'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"fields_coupon\", must include one of #{allowable_values}"
  end
  allowable_values = ["coupon"]
  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/coupon-codes'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'filter'] = filter
  query_params[:'fields[coupon-code]'] = @api_client.build_collection_param(opts[:'fields_coupon_code'], :csv) if !opts[:'fields_coupon_code'].nil?
  query_params[:'fields[coupon]'] = @api_client.build_collection_param(opts[:'fields_coupon'], :csv) if !opts[:'fields_coupon'].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?

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2025-04-15"
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+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', 'OAuth']

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

#get_coupon_for_coupon_code(id, opts = {}) ⇒ Hash<String, Object> Also known as: get_coupon_code_coupon

Get Coupon For Coupon Code Get the coupon associated with a given coupon code ID.
*Rate limits*:
Burst: ‘75/s`
Steady: `700/m` Scopes: `coupons:read`

Parameters:

  • id (String)

    The ID of the coupon to look up the relationship of.

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

    the optional parameters

Options Hash (opts):

Returns:

  • (Hash<String, Object>)


977
978
979
980
# File 'lib/klaviyo-api-sdk/api/coupons_api.rb', line 977

def get_coupon_for_coupon_code(id, opts = {})
  data, _status_code, _headers = get_coupon_for_coupon_code_with_http_info(id, opts)
  data
end

#get_coupon_for_coupon_code_with_http_info(id, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)> Also known as: get_coupon_code_coupon_with_http_info

Get Coupon For Coupon Code Get the coupon associated with a given coupon code ID.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;75/s&#x60;&lt;br&gt;Steady: &#x60;700/m&#x60; Scopes: &#x60;coupons:read&#x60;

Parameters:

  • id (String)

    The ID of the coupon to look up the relationship of.

  • 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



991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
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
# File 'lib/klaviyo-api-sdk/api/coupons_api.rb', line 991

def get_coupon_for_coupon_code_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CouponsApi.get_coupon_for_coupon_code ...'
  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 CouponsApi.get_coupon_for_coupon_code"
  end
  allowable_values = ["external_id", "description"]
  if @api_client.config.client_side_validation && opts[:'fields_coupon'] && !opts[:'fields_coupon'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"fields_coupon\", must include one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/api/coupon-codes/{id}/coupon'.sub('{' + 'id' + '}', CGI.escape(id.to_s))

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

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2025-04-15"
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+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', 'OAuth']

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

#get_coupon_id_for_coupon_code(id, opts = {}) ⇒ Hash<String, Object> Also known as: get_coupon_relationships_coupon_codes

Get Coupon ID for Coupon Code Gets the coupon relationship associated with the given coupon code id
*Rate limits*:
Burst: ‘75/s`
Steady: `700/m` Scopes: `coupons:read`

Parameters:

  • id (String)

    The ID of the coupon to look up the relationship of.

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

    the optional parameters

Returns:

  • (Hash<String, Object>)


1054
1055
1056
1057
# File 'lib/klaviyo-api-sdk/api/coupons_api.rb', line 1054

def get_coupon_id_for_coupon_code(id, opts = {})
  data, _status_code, _headers = get_coupon_id_for_coupon_code_with_http_info(id, opts)
  data
end

#get_coupon_id_for_coupon_code_with_http_info(id, opts = {}) ⇒ Array<(Hash<String, Object>, Integer, Hash)> Also known as: get_coupon_relationships_coupon_codes_with_http_info

Get Coupon ID for Coupon Code Gets the coupon relationship associated with the given coupon code id&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;75/s&#x60;&lt;br&gt;Steady: &#x60;700/m&#x60; Scopes: &#x60;coupons:read&#x60;

Parameters:

  • id (String)

    The ID of the coupon to look up the relationship of.

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

    the optional parameters

Returns:

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

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



1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
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
# File 'lib/klaviyo-api-sdk/api/coupons_api.rb', line 1067

def get_coupon_id_for_coupon_code_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CouponsApi.get_coupon_id_for_coupon_code ...'
  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 CouponsApi.get_coupon_id_for_coupon_code"
  end
  # resource path
  local_var_path = '/api/coupon-codes/{id}/relationships/coupon'.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['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2025-04-15"
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+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', 'OAuth']

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

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

Get Coupon Get a specific coupon with the given coupon ID.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;75/s&#x60;&lt;br&gt;Steady: &#x60;700/m&#x60; Scopes: &#x60;coupons:read&#x60;

Parameters:

  • id (String)

    The internal id of a Coupon is equivalent to its external id stored within an integration.

  • 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



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

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

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

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2025-04-15"
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+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', 'OAuth']

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

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

Get Coupons Get all coupons in an account. To learn more, see our [Coupons API guide](developers.klaviyo.com/en/docs/use_klaviyos_coupons_api).
*Rate limits*:
Burst: ‘75/s`
Steady: `700/m` Scopes: `coupons:read`

Parameters:

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

    the optional parameters

Options Hash (opts):

Returns:

  • (Hash<String, Object>)


1126
1127
1128
1129
# File 'lib/klaviyo-api-sdk/api/coupons_api.rb', line 1126

def get_coupons(opts = {})
  data, _status_code, _headers = get_coupons_with_http_info(opts)
  data
end

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

Get Coupons Get all coupons in an account. To learn more, see our [Coupons API guide](developers.klaviyo.com/en/docs/use_klaviyos_coupons_api).&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;75/s&#x60;&lt;br&gt;Steady: &#x60;700/m&#x60; Scopes: &#x60;coupons:read&#x60;

Parameters:

  • 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



1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
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
# File 'lib/klaviyo-api-sdk/api/coupons_api.rb', line 1137

def get_coupons_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CouponsApi.get_coupons ...'
  end
  allowable_values = ["external_id", "description"]
  if @api_client.config.client_side_validation && opts[:'fields_coupon'] && !opts[:'fields_coupon'].all? { |item| allowable_values.include?(item) }
    fail ArgumentError, "invalid value for \"fields_coupon\", must include one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/api/coupons'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'fields[coupon]'] = @api_client.build_collection_param(opts[:'fields_coupon'], :csv) if !opts[:'fields_coupon'].nil?
  query_params[:'page[cursor]'] = opts[:'page_cursor'] if !opts[:'page_cursor'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2025-04-15"
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+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', 'OAuth']

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

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

Update Coupon *Rate limits*:
Burst: ‘3/s`
Steady: `60/m` Scopes: `coupons:write`

Parameters:

  • id (String)

    The internal id of a Coupon is equivalent to its external id stored within an integration.

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

    the optional parameters

Returns:

  • (Hash<String, Object>)


1195
1196
1197
1198
# File 'lib/klaviyo-api-sdk/api/coupons_api.rb', line 1195

def update_coupon(id, coupon_update_query, opts = {})
  data, _status_code, _headers = update_coupon_with_http_info(id, coupon_update_query, opts)
  data
end

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

Update Coupon Code Updates a coupon code specified by the given identifier synchronously. We allow updating the ‘status’ and ‘expires_at’ of coupon codes.
*Rate limits*:
Burst: ‘350/s`
Steady: `3500/m` Scopes: `coupon-codes:write`

Parameters:

  • id (String)

    The id of a coupon code is a combination of its unique code and the id of the coupon it is associated with.

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

    the optional parameters

Returns:

  • (Hash<String, Object>)


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

def update_coupon_code(id, coupon_code_update_query, opts = {})
  data, _status_code, _headers = update_coupon_code_with_http_info(id, coupon_code_update_query, opts)
  data
end

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

Update Coupon Code Updates a coupon code specified by the given identifier synchronously. We allow updating the &#39;status&#39; and &#39;expires_at&#39; of coupon codes.&lt;br&gt;&lt;br&gt;*Rate limits*:&lt;br&gt;Burst: &#x60;350/s&#x60;&lt;br&gt;Steady: &#x60;3500/m&#x60; Scopes: &#x60;coupon-codes:write&#x60;

Parameters:

  • id (String)

    The id of a coupon code is a combination of its unique code and the id of the coupon it is associated with.

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

    the optional parameters

Returns:

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

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



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
1335
1336
1337
1338
1339
# File 'lib/klaviyo-api-sdk/api/coupons_api.rb', line 1282

def update_coupon_code_with_http_info(id, coupon_code_update_query, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CouponsApi.update_coupon_code ...'
  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 CouponsApi.update_coupon_code"
  end
  # verify the required parameter 'coupon_code_update_query' is set
  if @api_client.config.client_side_validation && coupon_code_update_query.nil?
    fail ArgumentError, "Missing the required parameter 'coupon_code_update_query' when calling CouponsApi.update_coupon_code"
  end
  # resource path
  local_var_path = '/api/coupon-codes/{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['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2025-04-15"
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/vnd.api+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(coupon_code_update_query)

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

  # auth_names
  auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth']

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

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

Update Coupon *Rate limits*:&lt;br&gt;Burst: &#x60;3/s&#x60;&lt;br&gt;Steady: &#x60;60/m&#x60; Scopes: &#x60;coupons:write&#x60;

Parameters:

  • id (String)

    The internal id of a Coupon is equivalent to its external id stored within an integration.

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

    the optional parameters

Returns:

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

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



1206
1207
1208
1209
1210
1211
1212
1213
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
1263
# File 'lib/klaviyo-api-sdk/api/coupons_api.rb', line 1206

def update_coupon_with_http_info(id, coupon_update_query, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CouponsApi.update_coupon ...'
  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 CouponsApi.update_coupon"
  end
  # verify the required parameter 'coupon_update_query' is set
  if @api_client.config.client_side_validation && coupon_update_query.nil?
    fail ArgumentError, "Missing the required parameter 'coupon_update_query' when calling CouponsApi.update_coupon"
  end
  # resource path
  local_var_path = '/api/coupons/{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['KLAVIYO_API_REVISION'] || ENV['API_REVISION'] || "2025-04-15"
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/vnd.api+json'])
  # HTTP header 'Content-Type'
  content_type = @api_client.select_header_content_type(['application/vnd.api+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(coupon_update_query)

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

  # auth_names
  auth_names = opts[:debug_auth_names] || ['Klaviyo-API-Key', 'OAuth']

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