Class: VoucherifySdk::RedemptionsApi

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

def api_client
  @api_client
end

Instance Method Details

#get_redemption(redemption_id, opts = {}) ⇒ RedemptionsGetResponseBody

Get Redemption Return a redemption or redemption rollback object. This object can either be a successfull or failed redemption or redemption rollback.

Parameters:

  • redemption_id (String)

    ID of previously created redemption.

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

    the optional parameters

Returns:



27
28
29
30
# File 'lib/VoucherifySdk/api/redemptions_api.rb', line 27

def get_redemption(redemption_id, opts = {})
  data, _status_code, _headers = get_redemption_with_http_info(redemption_id, opts)
  data
end

#get_voucher_redemptions(code, opts = {}) ⇒ VouchersRedemptionGetResponseBody

Get Voucher's Redemptions Retrieve the number of times a voucher was redeemed and each of the redemption details.

Parameters:

  • code (String)

    A code that identifies the voucher.

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

    the optional parameters

Returns:



86
87
88
89
# File 'lib/VoucherifySdk/api/redemptions_api.rb', line 86

def get_voucher_redemptions(code, opts = {})
  data, _status_code, _headers = get_voucher_redemptions_with_http_info(code, opts)
  data
end

#list_redemptions(opts = {}) ⇒ RedemptionsListResponseBody

List Redemptions Returns a list of redemptions previously created. The redemptions are returned in a sorted order, with the most recent redemptions appearing first. The response returns a list of redemptions of all vouchers. # Filtering results The result can be narrowed according to specified (or default) filters, for example, you can sort redemptions by date: https://api.voucherify.io/v1/redemptions?limit 3&[created_at][before] 2017-09-08T13:52:18.227Z. A filter based on the object created_at field narrows down the results and lists redemptions done before or after a particular date time. You can use the following options: [created_at][after], [created_at][before]. A date value must be presented in ISO 8601 format (2016-11-16T14:14:31Z or 2016-11-16). An example: [created_at][before] 2017-09-08T13:52:18.227Z. # Failed Redemptions A redemption may fail for various reasons. You can figure out an exact reason from the failure_code: - resource_not_found - voucher with given code does not exist - voucher_not_active - voucher is not active yet (before start date) - voucher_expired - voucher has already expired (after expiration date) - voucher_disabled - voucher has been disabled (active: false) - quantity_exceeded - vouchers redemptions limit has been exceeded - gift_amount_exceeded - gift amount has been exceeded - customer_rules_violated - customer did not match the segment - order_rules_violated - order did not match validation rules - invalid_order - order was specified incorrectly - invalid_amount - order amount was specified incorrectly - missing_amount - order amount was not specified - missing_order_items - order items were not specified - missing_customer - customer was not specified

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :limit (Integer)

    Limits the number of objects to be returned. The limit can range between 1 and 100 items. If no limit is set, it returns 10 items.

  • :page (Integer)

    Which page of results to return. The lowest value is 1.

  • :result (String)

    A filter on the list based on the redemption result. Available options are: SUCCESS, FAILURE. You can provide multiple values by repeating the param.

  • :campaign (String)

    A filter by the campaign name that the redemption resources originate from.

  • :customer (String)

    Return redemptions performed by the customer with given id or source_id.

  • :order (ParameterOrderListRedemptions)

    Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order.

  • :created_at (ParameterCreatedBeforeAfter)

    A filter on the list based on the object created_at field. The value is a dictionary with the following options: before, after. A date value must be presented in ISO 8601 format (2016-11-16T14:14:31Z or 2016-11-16). An example: [created_at][before] 2017-09-08T13:52:18.227Z

  • :filters (ParameterFiltersListRedemptions)

    Filters for listing responses.

Returns:



152
153
154
155
# File 'lib/VoucherifySdk/api/redemptions_api.rb', line 152

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

#redeem_stacked_discounts(opts = {}) ⇒ RedemptionsRedeemResponseBody

Redeem Stackable Discounts In the table below, you can see the logic the API follows to calculate discounts and amounts: API keys with a Merchant role cant use this endpoint. πŸ“˜ Rollbacks You cant roll back a child redemption. When you call rollback on a stacked redemption, all child redemptions will be rolled back. You need to refer to a parent redemption ID in your rollback request. πŸ“˜ Also available on client-side This method is also accessible through public keys which you can use in client-side​ apps: mobile and web browser apps. Go to the dedicated endpoint to learn more.

Parameters:

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

    the optional parameters

Options Hash (opts):

Returns:



226
227
228
229
# File 'lib/VoucherifySdk/api/redemptions_api.rb', line 226

def redeem_stacked_discounts(opts = {})
  data, _status_code, _headers = redeem_stacked_discounts_with_http_info(opts)
  data
end

#rollback_redemption(redemption_id, opts = {}) ⇒ RedemptionsRollbackCreateResponseBody

Rollback Redemption Your business logic may include a case when you need to undo a redemption. You can revert a redemption by calling this API endpoint. This endpoint rolls back only single redemptions, meaning those that are not stacked. Stacked redemptions belong to a parent redemption. To roll back a parent redemption, including all of its individual redemptions, use the POST Rollback Stackable Redemptions 🚧 You can roll back a redemption up to 3 months back. # Effect The operation - creates a rollback entry in vouchers redemption history (redemption.redemption_entries) and - gives 1 redemption back to the pool (decreases redeemed_quantity by 1). # Returned funds In case of gift card vouchers, this method returns funds back according to the source redemption. In case of loyalty card vouchers, this method returns points back according to the source redemption.

Parameters:

  • redemption_id (String)

    The original redemption ID to be rolled back (undone).

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

    the optional parameters

Options Hash (opts):

  • :reason (String)

    Reason for the rollback.

  • :tracking_id (String)

    Customers source_id.

  • :redemptions_rollback_create_request_body (RedemptionsRollbackCreateRequestBody)

    Add information about the original customer and order. Customer data and Redemption metadata can be updated in Voucherify when passing the customer data in the request body.

Returns:



293
294
295
296
# File 'lib/VoucherifySdk/api/redemptions_api.rb', line 293

def rollback_redemption(redemption_id, opts = {})
  data, _status_code, _headers = rollback_redemption_with_http_info(redemption_id, opts)
  data
end

#rollback_stacked_redemptions(parent_redemption_id, opts = {}) ⇒ RedemptionsRollbacksCreateResponseBody

Rollback Stackable Redemptions Rollback a stackable redemption. When you roll back a stacked redemption, all child redemptions will be rolled back. Provide the parent redemption ID as the path parameter. However, you can use this endpoint to roll back a single redemption that does not have a parent, similarly to POST Rollback redemption. 🚧 You can roll back a redemption up to 3 months back.

Parameters:

  • parent_redemption_id (String)

    Unique identifier of a parent redemption, e.g. r_JQfm73zWSJFQxs3bGxweYjgm.

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

    the optional parameters

Options Hash (opts):

  • :reason (String)

    Reason for the rollback.

  • :tracking_id (String)

    Customers source_id.

  • :redemptions_rollbacks_create_request_body (RedemptionsRollbacksCreateRequestBody)

    Add information about the original customer and order. Customer data and Redemption metadata can be updated in Voucherify when passing the customer data in the request body.

Returns:



365
366
367
368
# File 'lib/VoucherifySdk/api/redemptions_api.rb', line 365

def rollback_stacked_redemptions(parent_redemption_id, opts = {})
  data, _status_code, _headers = rollback_stacked_redemptions_with_http_info(parent_redemption_id, opts)
  data
end