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

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


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

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


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

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



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/coupons_api.rb', line 107

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['API_REVISION'] || "2024-02-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(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']

  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



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/coupons_api.rb', line 37

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['API_REVISION'] || "2024-02-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(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']

  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)


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

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)


232
233
234
235
# File 'lib/klaviyo-api-sdk/api/coupons_api.rb', line 232

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



242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
# File 'lib/klaviyo-api-sdk/api/coupons_api.rb', line 242

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['API_REVISION'] || "2024-02-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 => :"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



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

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['API_REVISION'] || "2024-02-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 => :"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_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>)


298
299
300
301
# File 'lib/klaviyo-api-sdk/api/coupons_api.rb', line 298

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


372
373
374
375
# File 'lib/klaviyo-api-sdk/api/coupons_api.rb', line 372

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

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

Get Coupon Code Bulk Create 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>)


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

def get_coupon_code_bulk_create_job(job_id, opts = {})
  data, _status_code, _headers = get_coupon_code_bulk_create_job_with_http_info(job_id, opts)
  data
end

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

Get Coupon Code Bulk Create 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



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

def get_coupon_code_bulk_create_job_with_http_info(job_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CouponsApi.get_coupon_code_bulk_create_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_coupon_code_bulk_create_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['API_REVISION'] || "2024-02-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 => :"CouponsApi.get_coupon_code_bulk_create_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_coupon_code_bulk_create_job\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

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

Get Coupon Code Bulk Create 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>)


543
544
545
546
# File 'lib/klaviyo-api-sdk/api/coupons_api.rb', line 543

def get_coupon_code_bulk_create_jobs(opts = {})
  data, _status_code, _headers = get_coupon_code_bulk_create_jobs_with_http_info(opts)
  data
end

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

Get Coupon Code Bulk Create 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



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

def get_coupon_code_bulk_create_jobs_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CouponsApi.get_coupon_code_bulk_create_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['API_REVISION'] || "2024-02-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 => :"CouponsApi.get_coupon_code_bulk_create_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_coupon_code_bulk_create_jobs\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

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

Get Coupon Code Relationships 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)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

Returns:

  • (Hash<String, Object>)


614
615
616
617
# File 'lib/klaviyo-api-sdk/api/coupons_api.rb', line 614

def get_coupon_code_relationships_coupon(id, opts = {})
  data, _status_code, _headers = get_coupon_code_relationships_coupon_with_http_info(id, opts)
  data
end

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

Get Coupon Code Relationships 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)
  • 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



625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
# File 'lib/klaviyo-api-sdk/api/coupons_api.rb', line 625

def get_coupon_code_relationships_coupon_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CouponsApi.get_coupon_code_relationships_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_relationships_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[:'page[cursor]'] = opts[:'page_cursor'] if !opts[:'page_cursor'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # klaviyo api revision
  header_params['revision'] =  ENV['API_REVISION'] || "2024-02-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 => :"CouponsApi.get_coupon_code_relationships_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_relationships_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



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

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['API_REVISION'] || "2024-02-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 => :"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(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:

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

    the optional parameters

Options Hash (opts):

Returns:

  • (Hash<String, Object>)


685
686
687
688
# File 'lib/klaviyo-api-sdk/api/coupons_api.rb', line 685

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

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

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)
  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

Returns:

  • (Hash<String, Object>)


770
771
772
773
# File 'lib/klaviyo-api-sdk/api/coupons_api.rb', line 770

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

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



783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
# File 'lib/klaviyo-api-sdk/api/coupons_api.rb', line 783

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['API_REVISION'] || "2024-02-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 => :"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(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:

  • 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



699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
# File 'lib/klaviyo-api-sdk/api/coupons_api.rb', line 699

def get_coupon_codes_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: 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[:'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[:'filter'] = opts[:'filter'] if !opts[:'filter'].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['API_REVISION'] || "2024-02-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 => :"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>

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

Parameters:

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

    the optional parameters

Options Hash (opts):

Returns:

  • (Hash<String, Object>)


846
847
848
849
# File 'lib/klaviyo-api-sdk/api/coupons_api.rb', line 846

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

Get Coupon For Coupon Code 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;coupons: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



857
858
859
860
861
862
863
864
865
866
867
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
# File 'lib/klaviyo-api-sdk/api/coupons_api.rb', line 857

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['API_REVISION'] || "2024-02-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 => :"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_relationships_coupon_codes(id, opts = {}) ⇒ Hash<String, Object>

Get Coupon Relationships Coupon Codes 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)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Hash<String, Object>)


917
918
919
920
# File 'lib/klaviyo-api-sdk/api/coupons_api.rb', line 917

def get_coupon_relationships_coupon_codes(id, opts = {})
  data, _status_code, _headers = get_coupon_relationships_coupon_codes_with_http_info(id, opts)
  data
end

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

Get Coupon Relationships Coupon Codes 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)
  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

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

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



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
964
965
966
967
968
969
970
971
972
973
974
975
# File 'lib/klaviyo-api-sdk/api/coupons_api.rb', line 927

def get_coupon_relationships_coupon_codes_with_http_info(id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CouponsApi.get_coupon_relationships_coupon_codes ...'
  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_relationships_coupon_codes"
  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['API_REVISION'] || "2024-02-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 => :"CouponsApi.get_coupon_relationships_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_relationships_coupon_codes\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



309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
# File 'lib/klaviyo-api-sdk/api/coupons_api.rb', line 309

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['API_REVISION'] || "2024-02-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 => :"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>)


983
984
985
986
# File 'lib/klaviyo-api-sdk/api/coupons_api.rb', line 983

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



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 994

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['API_REVISION'] || "2024-02-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 => :"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

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

Spawn Coupon Code Bulk Create Job Create a coupon-code-bulk-create-job to bulk create a list of coupon codes. 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>)


1051
1052
1053
1054
# File 'lib/klaviyo-api-sdk/api/coupons_api.rb', line 1051

def spawn_coupon_code_bulk_create_job(coupon_code_create_job_create_query, opts = {})
  data, _status_code, _headers = spawn_coupon_code_bulk_create_job_with_http_info(coupon_code_create_job_create_query, opts)
  data
end

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

Spawn Coupon Code Bulk Create Job Create a coupon-code-bulk-create-job to bulk create a list of coupon codes. 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



1061
1062
1063
1064
1065
1066
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
# File 'lib/klaviyo-api-sdk/api/coupons_api.rb', line 1061

def spawn_coupon_code_bulk_create_job_with_http_info(coupon_code_create_job_create_query, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: CouponsApi.spawn_coupon_code_bulk_create_job ...'
  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.spawn_coupon_code_bulk_create_job"
  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['API_REVISION'] || "2024-02-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(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']

  new_options = opts.merge(
    :operation => :"CouponsApi.spawn_coupon_code_bulk_create_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: CouponsApi#spawn_coupon_code_bulk_create_job\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>)


1122
1123
1124
1125
# File 'lib/klaviyo-api-sdk/api/coupons_api.rb', line 1122

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


1198
1199
1200
1201
# File 'lib/klaviyo-api-sdk/api/coupons_api.rb', line 1198

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



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

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['API_REVISION'] || "2024-02-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(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']

  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



1133
1134
1135
1136
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
1188
1189
1190
# File 'lib/klaviyo-api-sdk/api/coupons_api.rb', line 1133

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['API_REVISION'] || "2024-02-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(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']

  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