Class: Ifeelgoods::RedemptionsApi

Inherits:
Object
  • Object
show all
Defined in:
lib/ifeelgoods/api/redemptions_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ RedemptionsApi

Returns a new instance of RedemptionsApi.



19
20
21
# File 'lib/ifeelgoods/api/redemptions_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/ifeelgoods/api/redemptions_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#activate_redemption(redemption_id, opts = {}) ⇒ CreateRedemption201Response

Activate Use this function to perform an activation from an existing redemption object and retrieve a authenticated link (url key).

Parameters:

  • redemption_id (String)

    Unique Redemption identifier (eg. ZN7RS-9RNLY)

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

    the optional parameters

Options Hash (opts):

Returns:



28
29
30
31
# File 'lib/ifeelgoods/api/redemptions_api.rb', line 28

def activate_redemption(redemption_id, opts = {})
  data, _status_code, _headers = activate_redemption_with_http_info(redemption_id, opts)
  data
end

#activate_redemption_with_http_info(redemption_id, opts = {}) ⇒ Array<(CreateRedemption201Response, Integer, Hash)>

Activate Use this function to perform an activation from an existing redemption object and retrieve a authenticated link (url key).

Parameters:

  • redemption_id (String)

    Unique Redemption identifier (eg. ZN7RS-9RNLY)

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

    the optional parameters

Options Hash (opts):

Returns:

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

    CreateRedemption201Response data, response status code and response headers



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/ifeelgoods/api/redemptions_api.rb', line 39

def activate_redemption_with_http_info(redemption_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: RedemptionsApi.activate_redemption ...'
  end
  # verify the required parameter 'redemption_id' is set
  if @api_client.config.client_side_validation && redemption_id.nil?
    fail ArgumentError, "Missing the required parameter 'redemption_id' when calling RedemptionsApi.activate_redemption"
  end
  # resource path
  local_var_path = '/fulfillment/v2/redemptions/{redemption_id}/actions/activate'.sub('{redemption_id}', CGI.escape(redemption_id.to_s))

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

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json', 'application/pdf']) unless header_params['Accept']
  # 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(opts[:'activate_redemption_request'])

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

  # auth_names
  auth_names = opts[:debug_auth_names] || ['api_key', 'bearer_auth', 'api_secret']

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

#book_redemption(promotion_id, reward_sku, opts = {}) ⇒ CreateRedemption201Response

Book Use this function to book a reward code before redeem it. This action will do the same as in Create a Redemption API but will also book a reward code for a duration of 30 minutes. You can then redeem the redemption using Create and Redeem or Redeem APIs using the same parameters (eg. same order_id and user email).

Parameters:

  • promotion_id (String)

    The promotion identifier

  • reward_sku (String)

    The reward SKU

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

    the optional parameters

Options Hash (opts):

Returns:



99
100
101
102
# File 'lib/ifeelgoods/api/redemptions_api.rb', line 99

def book_redemption(promotion_id, reward_sku, opts = {})
  data, _status_code, _headers = book_redemption_with_http_info(promotion_id, reward_sku, opts)
  data
end

#book_redemption_with_http_info(promotion_id, reward_sku, opts = {}) ⇒ Array<(CreateRedemption201Response, Integer, Hash)>

Book Use this function to book a reward code before redeem it. This action will do the same as in Create a Redemption API but will also book a reward code for a duration of 30 minutes. You can then redeem the redemption using Create and Redeem or Redeem APIs using the same parameters (eg. same order_id and user email).

Parameters:

  • promotion_id (String)

    The promotion identifier

  • reward_sku (String)

    The reward SKU

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

    the optional parameters

Options Hash (opts):

Returns:

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

    CreateRedemption201Response data, response status code and response headers



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# File 'lib/ifeelgoods/api/redemptions_api.rb', line 111

def book_redemption_with_http_info(promotion_id, reward_sku, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: RedemptionsApi.book_redemption ...'
  end
  # verify the required parameter 'promotion_id' is set
  if @api_client.config.client_side_validation && promotion_id.nil?
    fail ArgumentError, "Missing the required parameter 'promotion_id' when calling RedemptionsApi.book_redemption"
  end
  # verify the required parameter 'reward_sku' is set
  if @api_client.config.client_side_validation && reward_sku.nil?
    fail ArgumentError, "Missing the required parameter 'reward_sku' when calling RedemptionsApi.book_redemption"
  end
  # resource path
  local_var_path = '/fulfillment/v2/promotions/{promotion_id}/rewards/{reward_sku}/redemptions/book'.sub('{promotion_id}', CGI.escape(promotion_id.to_s)).sub('{reward_sku}', CGI.escape(reward_sku.to_s))

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

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
  # 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(opts[:'create_and_redeem_request'])

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

  # auth_names
  auth_names = opts[:debug_auth_names] || ['api_key', 'bearer_auth', 'api_secret']

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

#cancel_redemption(redemption_id, opts = {}) ⇒ CreateRedemption201Response

Cancel Use this function to cancel a pending/failed redemption.

Parameters:

  • redemption_id (String)

    The redemption identifier

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

    the optional parameters

Returns:



173
174
175
176
# File 'lib/ifeelgoods/api/redemptions_api.rb', line 173

def cancel_redemption(redemption_id, opts = {})
  data, _status_code, _headers = cancel_redemption_with_http_info(redemption_id, opts)
  data
end

#cancel_redemption_with_http_info(redemption_id, opts = {}) ⇒ Array<(CreateRedemption201Response, Integer, Hash)>

Cancel Use this function to cancel a pending/failed redemption.

Parameters:

  • redemption_id (String)

    The redemption identifier

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

    the optional parameters

Returns:

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

    CreateRedemption201Response data, response status code and response headers



183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
# File 'lib/ifeelgoods/api/redemptions_api.rb', line 183

def cancel_redemption_with_http_info(redemption_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: RedemptionsApi.cancel_redemption ...'
  end
  # verify the required parameter 'redemption_id' is set
  if @api_client.config.client_side_validation && redemption_id.nil?
    fail ArgumentError, "Missing the required parameter 'redemption_id' when calling RedemptionsApi.cancel_redemption"
  end
  # resource path
  local_var_path = '/fulfillment/v2/redemptions/{redemption_id}/actions/cancel'.sub('{redemption_id}', CGI.escape(redemption_id.to_s))

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

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

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

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

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

  # auth_names
  auth_names = opts[:debug_auth_names] || ['api_key', 'bearer_auth', 'api_secret']

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

#card_consult_redemption(redemption_id, opts = {}) ⇒ CardConsultRedemption200Response

Consult Card Use this function to retrieve card information (balance, currency) for a redemption when supported by the reward provider.

Parameters:

  • redemption_id (String)

    The redemption identifier

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

    the optional parameters

Returns:



236
237
238
239
# File 'lib/ifeelgoods/api/redemptions_api.rb', line 236

def card_consult_redemption(redemption_id, opts = {})
  data, _status_code, _headers = card_consult_redemption_with_http_info(redemption_id, opts)
  data
end

#card_consult_redemption_with_http_info(redemption_id, opts = {}) ⇒ Array<(CardConsultRedemption200Response, Integer, Hash)>

Consult Card Use this function to retrieve card information (balance, currency) for a redemption when supported by the reward provider.

Parameters:

  • redemption_id (String)

    The redemption identifier

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

    the optional parameters

Returns:



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
291
292
# File 'lib/ifeelgoods/api/redemptions_api.rb', line 246

def card_consult_redemption_with_http_info(redemption_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: RedemptionsApi.card_consult_redemption ...'
  end
  # verify the required parameter 'redemption_id' is set
  if @api_client.config.client_side_validation && redemption_id.nil?
    fail ArgumentError, "Missing the required parameter 'redemption_id' when calling RedemptionsApi.card_consult_redemption"
  end
  # resource path
  local_var_path = '/fulfillment/v2/redemptions/{redemption_id}/card_consult'.sub('{redemption_id}', CGI.escape(redemption_id.to_s))

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

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

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

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

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

  # auth_names
  auth_names = opts[:debug_auth_names] || ['api_key', 'bearer_auth', 'api_secret']

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

#create_and_redeem(promotion_id, reward_sku, opts = {}) ⇒ CreateRedemption201Response

Create and Redeem Use this function to create a redemption object and perform a reward delivery. Calling this endpoint on an existing order_id with the exact same parameters will return the existing order.

Parameters:

  • promotion_id (String)

    The promotion identifier

  • reward_sku (String)

    The reward SKU

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

    the optional parameters

Options Hash (opts):

Returns:



301
302
303
304
# File 'lib/ifeelgoods/api/redemptions_api.rb', line 301

def create_and_redeem(promotion_id, reward_sku, opts = {})
  data, _status_code, _headers = create_and_redeem_with_http_info(promotion_id, reward_sku, opts)
  data
end

#create_and_redeem_with_http_info(promotion_id, reward_sku, opts = {}) ⇒ Array<(CreateRedemption201Response, Integer, Hash)>

Create and Redeem Use this function to create a redemption object and perform a reward delivery. Calling this endpoint on an existing order_id with the exact same parameters will return the existing order.

Parameters:

  • promotion_id (String)

    The promotion identifier

  • reward_sku (String)

    The reward SKU

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

    the optional parameters

Options Hash (opts):

Returns:

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

    CreateRedemption201Response data, response status code and response headers



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
363
364
365
366
367
368
# File 'lib/ifeelgoods/api/redemptions_api.rb', line 313

def create_and_redeem_with_http_info(promotion_id, reward_sku, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: RedemptionsApi.create_and_redeem ...'
  end
  # verify the required parameter 'promotion_id' is set
  if @api_client.config.client_side_validation && promotion_id.nil?
    fail ArgumentError, "Missing the required parameter 'promotion_id' when calling RedemptionsApi.create_and_redeem"
  end
  # verify the required parameter 'reward_sku' is set
  if @api_client.config.client_side_validation && reward_sku.nil?
    fail ArgumentError, "Missing the required parameter 'reward_sku' when calling RedemptionsApi.create_and_redeem"
  end
  # resource path
  local_var_path = '/fulfillment/v2/promotions/{promotion_id}/rewards/{reward_sku}/redemptions/redeem'.sub('{promotion_id}', CGI.escape(promotion_id.to_s)).sub('{reward_sku}', CGI.escape(reward_sku.to_s))

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

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json', 'application/pdf']) unless header_params['Accept']
  # 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(opts[:'create_and_redeem_request'])

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

  # auth_names
  auth_names = opts[:debug_auth_names] || ['api_key', 'bearer_auth', 'api_secret']

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

#create_redemption(promotion_id, create_redemption_request, opts = {}) ⇒ CreateRedemption201Response

Create a redemption Use this function to create a redemption object and initiate a reward delivery.

Parameters:

  • promotion_id (String)

    The promotion identifier

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

    the optional parameters

Returns:



376
377
378
379
# File 'lib/ifeelgoods/api/redemptions_api.rb', line 376

def create_redemption(promotion_id, create_redemption_request, opts = {})
  data, _status_code, _headers = create_redemption_with_http_info(promotion_id, create_redemption_request, opts)
  data
end

#create_redemption_with_http_info(promotion_id, create_redemption_request, opts = {}) ⇒ Array<(CreateRedemption201Response, Integer, Hash)>

Create a redemption Use this function to create a redemption object and initiate a reward delivery.

Parameters:

  • promotion_id (String)

    The promotion identifier

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

    the optional parameters

Returns:

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

    CreateRedemption201Response data, response status code and response headers



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

def create_redemption_with_http_info(promotion_id, create_redemption_request, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: RedemptionsApi.create_redemption ...'
  end
  # verify the required parameter 'promotion_id' is set
  if @api_client.config.client_side_validation && promotion_id.nil?
    fail ArgumentError, "Missing the required parameter 'promotion_id' when calling RedemptionsApi.create_redemption"
  end
  # verify the required parameter 'create_redemption_request' is set
  if @api_client.config.client_side_validation && create_redemption_request.nil?
    fail ArgumentError, "Missing the required parameter 'create_redemption_request' when calling RedemptionsApi.create_redemption"
  end
  # resource path
  local_var_path = '/fulfillment/v2/promotions/{promotion_id}/redemptions'.sub('{promotion_id}', CGI.escape(promotion_id.to_s))

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

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json', 'application/pdf']) unless header_params['Accept']
  # 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(create_redemption_request)

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

  # auth_names
  auth_names = opts[:debug_auth_names] || ['api_key', 'bearer_auth', 'api_secret']

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

#get_redemption_by_id(redemption_id, opts = {}) ⇒ CreateRedemption201Response

Get a redemption Use this function to retrieve detailed information about a redemption object.

Parameters:

  • redemption_id (String)

    The redemption identifier

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

    the optional parameters

Returns:



449
450
451
452
# File 'lib/ifeelgoods/api/redemptions_api.rb', line 449

def get_redemption_by_id(redemption_id, opts = {})
  data, _status_code, _headers = get_redemption_by_id_with_http_info(redemption_id, opts)
  data
end

#get_redemption_by_id_with_http_info(redemption_id, opts = {}) ⇒ Array<(CreateRedemption201Response, Integer, Hash)>

Get a redemption Use this function to retrieve detailed information about a redemption object.

Parameters:

  • redemption_id (String)

    The redemption identifier

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

    the optional parameters

Returns:

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

    CreateRedemption201Response data, response status code and response headers



459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
# File 'lib/ifeelgoods/api/redemptions_api.rb', line 459

def get_redemption_by_id_with_http_info(redemption_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: RedemptionsApi.get_redemption_by_id ...'
  end
  # verify the required parameter 'redemption_id' is set
  if @api_client.config.client_side_validation && redemption_id.nil?
    fail ArgumentError, "Missing the required parameter 'redemption_id' when calling RedemptionsApi.get_redemption_by_id"
  end
  # resource path
  local_var_path = '/fulfillment/v2/redemptions/{redemption_id}'.sub('{redemption_id}', CGI.escape(redemption_id.to_s))

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

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json', 'application/pdf']) unless header_params['Accept']

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

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

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

  # auth_names
  auth_names = opts[:debug_auth_names] || ['api_key', 'bearer_auth', 'api_secret']

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

#list_redemptions(promotion_id, opts = {}) ⇒ ListRedemptions200Response

List all Redemptions Use this function to list the status of all redemptions created as part of a promotion.

Parameters:

  • promotion_id (String)

    The promotion identifier

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

    the optional parameters

Options Hash (opts):

  • :reward_sku (String)
  • :email (String)
  • :order_id (String)
  • :state (String)

    Redemption state filter (eg. `pending`, `redeemed`, `canceled`, etc.)

  • :redeemed_datetime_start (Time)

    Filter redemptions redeemed on or after this datetime (ISO 8601 format, e.g. `2024-01-01T00:00:00Z`)

  • :redeemed_datetime_end (Time)

    Filter redemptions redeemed on or before this datetime (ISO 8601 format, e.g. `2024-01-31T23:59:59Z`)

  • :activation_datetime_start (Time)

    Filter redemptions activated on or after this datetime (ISO 8601 format, e.g. `2024-01-01T00:00:00Z`)

  • :activation_datetime_end (Time)

    Filter redemptions activated on or before this datetime (ISO 8601 format, e.g. `2024-01-31T23:59:59Z`)

  • :refund_datetime_start (Time)

    Filter redemptions refunded on or after this datetime (ISO 8601 format, e.g. `2024-01-01T00:00:00Z`)

  • :refund_datetime_end (Time)

    Filter redemptions refunded on or before this datetime (ISO 8601 format, e.g. `2024-01-31T23:59:59Z`)

  • :sort (String)

    Field to sort by, prefixed with `-` for descending order (e.g. `activation_datetime` or `-activation_datetime`)

  • :page (Integer) — default: default to 1
  • :per_page (Integer) — default: default to 20

Returns:



525
526
527
528
# File 'lib/ifeelgoods/api/redemptions_api.rb', line 525

def list_redemptions(promotion_id, opts = {})
  data, _status_code, _headers = list_redemptions_with_http_info(promotion_id, opts)
  data
end

#list_redemptions_with_http_info(promotion_id, opts = {}) ⇒ Array<(ListRedemptions200Response, Integer, Hash)>

List all Redemptions Use this function to list the status of all redemptions created as part of a promotion.

Parameters:

  • promotion_id (String)

    The promotion identifier

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

    the optional parameters

Options Hash (opts):

  • :reward_sku (String)
  • :email (String)
  • :order_id (String)
  • :state (String)

    Redemption state filter (eg. `pending`, `redeemed`, `canceled`, etc.)

  • :redeemed_datetime_start (Time)

    Filter redemptions redeemed on or after this datetime (ISO 8601 format, e.g. `2024-01-01T00:00:00Z`)

  • :redeemed_datetime_end (Time)

    Filter redemptions redeemed on or before this datetime (ISO 8601 format, e.g. `2024-01-31T23:59:59Z`)

  • :activation_datetime_start (Time)

    Filter redemptions activated on or after this datetime (ISO 8601 format, e.g. `2024-01-01T00:00:00Z`)

  • :activation_datetime_end (Time)

    Filter redemptions activated on or before this datetime (ISO 8601 format, e.g. `2024-01-31T23:59:59Z`)

  • :refund_datetime_start (Time)

    Filter redemptions refunded on or after this datetime (ISO 8601 format, e.g. `2024-01-01T00:00:00Z`)

  • :refund_datetime_end (Time)

    Filter redemptions refunded on or before this datetime (ISO 8601 format, e.g. `2024-01-31T23:59:59Z`)

  • :sort (String)

    Field to sort by, prefixed with `-` for descending order (e.g. `activation_datetime` or `-activation_datetime`)

  • :page (Integer) — default: default to 1
  • :per_page (Integer) — default: default to 20

Returns:

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

    ListRedemptions200Response data, response status code and response headers



548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
# File 'lib/ifeelgoods/api/redemptions_api.rb', line 548

def list_redemptions_with_http_info(promotion_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: RedemptionsApi.list_redemptions ...'
  end
  # verify the required parameter 'promotion_id' is set
  if @api_client.config.client_side_validation && promotion_id.nil?
    fail ArgumentError, "Missing the required parameter 'promotion_id' when calling RedemptionsApi.list_redemptions"
  end
  allowable_values = ["pending", "booked", "redeemed", "denied", "failed", "refunded", "blocked", "canceled", "expired"]
  if @api_client.config.client_side_validation && opts[:'state'] && !allowable_values.include?(opts[:'state'])
    fail ArgumentError, "invalid value for \"state\", must be one of #{allowable_values}"
  end
  allowable_values = ["activation_datetime", "-activation_datetime", "updated_datetime", "-updated_datetime", "redeem_datetime", "-redeem_datetime", "refund_datetime", "-refund_datetime"]
  if @api_client.config.client_side_validation && opts[:'sort'] && !allowable_values.include?(opts[:'sort'])
    fail ArgumentError, "invalid value for \"sort\", must be one of #{allowable_values}"
  end
  if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] < 1
    fail ArgumentError, 'invalid value for "opts[:"page"]" when calling RedemptionsApi.list_redemptions, must be greater than or equal to 1.'
  end

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

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

  # resource path
  local_var_path = '/fulfillment/v2/promotions/{promotion_id}/redemptions'.sub('{promotion_id}', CGI.escape(promotion_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'reward_sku'] = opts[:'reward_sku'] if !opts[:'reward_sku'].nil?
  query_params[:'email'] = opts[:'email'] if !opts[:'email'].nil?
  query_params[:'order_id'] = opts[:'order_id'] if !opts[:'order_id'].nil?
  query_params[:'state'] = opts[:'state'] if !opts[:'state'].nil?
  query_params[:'redeemed_datetime_start'] = opts[:'redeemed_datetime_start'] if !opts[:'redeemed_datetime_start'].nil?
  query_params[:'redeemed_datetime_end'] = opts[:'redeemed_datetime_end'] if !opts[:'redeemed_datetime_end'].nil?
  query_params[:'activation_datetime_start'] = opts[:'activation_datetime_start'] if !opts[:'activation_datetime_start'].nil?
  query_params[:'activation_datetime_end'] = opts[:'activation_datetime_end'] if !opts[:'activation_datetime_end'].nil?
  query_params[:'refund_datetime_start'] = opts[:'refund_datetime_start'] if !opts[:'refund_datetime_start'].nil?
  query_params[:'refund_datetime_end'] = opts[:'refund_datetime_end'] if !opts[:'refund_datetime_end'].nil?
  query_params[:'sort'] = opts[:'sort'] if !opts[:'sort'].nil?
  query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?
  query_params[:'per_page'] = opts[:'per_page'] if !opts[:'per_page'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']

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

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

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

  # auth_names
  auth_names = opts[:debug_auth_names] || ['api_key', 'bearer_auth', 'api_secret']

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

#redeem_redemption(redemption_id, opts = {}) ⇒ CreateRedemption201Response

Redeem Use this function to perform a reward delivery from an existing redemption object.

Parameters:

  • redemption_id (String)

    Unique Redemption identifier (eg. ZN7RS-9RNLY)

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

    the optional parameters

Options Hash (opts):

Returns:



635
636
637
638
# File 'lib/ifeelgoods/api/redemptions_api.rb', line 635

def redeem_redemption(redemption_id, opts = {})
  data, _status_code, _headers = redeem_redemption_with_http_info(redemption_id, opts)
  data
end

#redeem_redemption_with_http_info(redemption_id, opts = {}) ⇒ Array<(CreateRedemption201Response, Integer, Hash)>

Redeem Use this function to perform a reward delivery from an existing redemption object.

Parameters:

  • redemption_id (String)

    Unique Redemption identifier (eg. ZN7RS-9RNLY)

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

    the optional parameters

Options Hash (opts):

Returns:

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

    CreateRedemption201Response data, response status code and response headers



646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
# File 'lib/ifeelgoods/api/redemptions_api.rb', line 646

def redeem_redemption_with_http_info(redemption_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: RedemptionsApi.redeem_redemption ...'
  end
  # verify the required parameter 'redemption_id' is set
  if @api_client.config.client_side_validation && redemption_id.nil?
    fail ArgumentError, "Missing the required parameter 'redemption_id' when calling RedemptionsApi.redeem_redemption"
  end
  # resource path
  local_var_path = '/fulfillment/v2/redemptions/{redemption_id}/actions/redeem'.sub('{redemption_id}', CGI.escape(redemption_id.to_s))

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

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json', 'application/pdf']) unless header_params['Accept']
  # 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(opts[:'activate_redemption_request'])

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

  # auth_names
  auth_names = opts[:debug_auth_names] || ['api_key', 'bearer_auth', 'api_secret']

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

#refund_redemption(redemption_id, opts = {}) ⇒ CreateRedemption201Response

Refund Refunds a redemption if it is redeemed, or if debited = true and the state is booked, failed, or pending. Only redemptions from the current month are refundable.

Parameters:

  • redemption_id (String)

    The redemption identifier

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

    the optional parameters

Returns:



704
705
706
707
# File 'lib/ifeelgoods/api/redemptions_api.rb', line 704

def refund_redemption(redemption_id, opts = {})
  data, _status_code, _headers = refund_redemption_with_http_info(redemption_id, opts)
  data
end

#refund_redemption_with_http_info(redemption_id, opts = {}) ⇒ Array<(CreateRedemption201Response, Integer, Hash)>

Refund Refunds a redemption if it is redeemed, or if debited = true and the state is booked, failed, or pending. Only redemptions from the current month are refundable.

Parameters:

  • redemption_id (String)

    The redemption identifier

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

    the optional parameters

Returns:

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

    CreateRedemption201Response data, response status code and response headers



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/ifeelgoods/api/redemptions_api.rb', line 714

def refund_redemption_with_http_info(redemption_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: RedemptionsApi.refund_redemption ...'
  end
  # verify the required parameter 'redemption_id' is set
  if @api_client.config.client_side_validation && redemption_id.nil?
    fail ArgumentError, "Missing the required parameter 'redemption_id' when calling RedemptionsApi.refund_redemption"
  end
  # resource path
  local_var_path = '/fulfillment/v2/redemptions/{redemption_id}/actions/refund'.sub('{redemption_id}', CGI.escape(redemption_id.to_s))

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

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json', 'application/pdf']) unless header_params['Accept']

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

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

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

  # auth_names
  auth_names = opts[:debug_auth_names] || ['api_key', 'bearer_auth', 'api_secret']

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