/** * Redemptions service. * @module api/RedemptionsApi */ export default class RedemptionsApi { /** * Constructs a new RedemptionsApi. * @alias RedemptionsApi * @class * @param {module:ApiClient} [apiClient] Optional API client implementation to use, * default to {@link module:ApiClient#instance} if unspecified. */ constructor(apiClient?: any); apiClient: any; /** * Callback function to receive the result of the getRedemption operation. * @callback getRedemptionCallback * @param {Error|null} error Error object if failed, null otherwise. * @param {RedemptionsGetResponseBody} [data] The data returned by the service call. * @param {Object} [response] Full response object if successful. */ /** * Get Redemption * Return a redemption or redemption rollback object. This object can either be a successfull or failed redemption or redemption rollback. * @param {String} redemptionId ID of previously created redemption. * @param {getRedemptionCallback} [callback] The callback function, accepting three arguments: error, data, response * data is of type: {@link RedemptionsGetResponseBody} * @returns {Promise<(RedemptionsGetResponseBody | undefined)>} Depending on whether the `callback` parameter is provided, the promise will resolve with a `RedemptionsGetResponseBody` object or with `undefined`. */ getRedemption(redemptionId: string, callback?: (error: Error | null, data?: RedemptionsGetResponseBody, response?: any) => any): Promise<(RedemptionsGetResponseBody | undefined)>; /** * Callback function to receive the result of the getVoucherRedemptions operation. * @callback getVoucherRedemptionsCallback * @param {Error|null} error Error object if failed, null otherwise. * @param {VouchersRedemptionGetResponseBody} [data] The data returned by the service call. * @param {Object} [response] Full response object if successful. */ /** * Get Voucher's Redemptions * Retrieve the number of times a voucher was redeemed and each of the redemption details. * @param {String} code A **code** that identifies the voucher. * @param {getVoucherRedemptionsCallback} [callback] The callback function, accepting three arguments: error, data, response * data is of type: {@link VouchersRedemptionGetResponseBody} * @returns {Promise<(VouchersRedemptionGetResponseBody | undefined)>} Depending on whether the `callback` parameter is provided, the promise will resolve with a `VouchersRedemptionGetResponseBody` object or with `undefined`. */ getVoucherRedemptions(code: string, callback?: (error: Error | null, data?: VouchersRedemptionGetResponseBody, response?: any) => any): Promise<(VouchersRedemptionGetResponseBody | undefined)>; /** * Callback function to receive the result of the listRedemptions operation. * @callback listRedemptionsCallback * @param {Error|null} error Error object if failed, null otherwise. * @param {RedemptionsListResponseBody} [data] The data returned by the service call. * @param {Object} [response] Full response object if successful. */ /** * 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 * @param {{ limit?: Number, page?: Number, result?: String, campaign?: String, customer?: String, order?: Exclude, createdAt?: ParameterCreatedBeforeAfter, filters?: ParameterFiltersListRedemptions, }} [opts] Optional parameters * @param {listRedemptionsCallback} [callback] The callback function, accepting three arguments: error, data, response * data is of type: {@link RedemptionsListResponseBody} * @returns {Promise<(RedemptionsListResponseBody | undefined)>} Depending on whether the `callback` parameter is provided, the promise will resolve with a `RedemptionsListResponseBody` object or with `undefined`. */ listRedemptions(opts?: { limit?: number; page?: number; result?: string; campaign?: string; customer?: string; order?: Exclude; createdAt?: ParameterCreatedBeforeAfter; filters?: ParameterFiltersListRedemptions; }, callback?: (error: Error | null, data?: RedemptionsListResponseBody, response?: any) => any): Promise<(RedemptionsListResponseBody | undefined)>; /** * Callback function to receive the result of the redeemStackedDiscounts operation. * @callback redeemStackedDiscountsCallback * @param {Error|null} error Error object if failed, null otherwise. * @param {RedemptionsRedeemResponseBody} [data] The data returned by the service call. * @param {Object} [response] Full response object if successful. */ /** * 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](/api-reference/redemptions/rollback-stackable-redemptions). 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](/api-reference/client-side/redeem-stackable-discounts-client-side) to learn more. * @param {RedemptionsRedeemRequestBody} redemptionsRedeemRequestBody * @param {redeemStackedDiscountsCallback} [callback] The callback function, accepting three arguments: error, data, response * data is of type: {@link RedemptionsRedeemResponseBody} * @returns {Promise<(RedemptionsRedeemResponseBody | undefined)>} Depending on whether the `callback` parameter is provided, the promise will resolve with a `RedemptionsRedeemResponseBody` object or with `undefined`. */ redeemStackedDiscounts(redemptionsRedeemRequestBody: RedemptionsRedeemRequestBody, callback?: (error: Error | null, data?: RedemptionsRedeemResponseBody, response?: any) => any): Promise<(RedemptionsRedeemResponseBody | undefined)>; /** * Callback function to receive the result of the rollbackRedemption operation. * @callback rollbackRedemptionCallback * @param {Error|null} error Error object if failed, null otherwise. * @param {RedemptionsRollbackCreateResponseBody} [data] The data returned by the service call. * @param {Object} [response] Full response object if successful. */ /** * 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](/api-reference/redemptions/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. * @param {String} redemptionId The original redemption ID to be rolled back (undone). * @param {RedemptionsRollbackCreateRequestBody} 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. * @param {{ reason?: String, trackingId?: String, }} [opts] Optional parameters * @param {rollbackRedemptionCallback} [callback] The callback function, accepting three arguments: error, data, response * data is of type: {@link RedemptionsRollbackCreateResponseBody} * @returns {Promise<(RedemptionsRollbackCreateResponseBody | undefined)>} Depending on whether the `callback` parameter is provided, the promise will resolve with a `RedemptionsRollbackCreateResponseBody` object or with `undefined`. */ rollbackRedemption(redemptionId: string, redemptionsRollbackCreateRequestBody: RedemptionsRollbackCreateRequestBody, opts?: { reason?: string; trackingId?: string; }, callback?: (error: Error | null, data?: RedemptionsRollbackCreateResponseBody, response?: any) => any): Promise<(RedemptionsRollbackCreateResponseBody | undefined)>; /** * Callback function to receive the result of the rollbackStackedRedemptions operation. * @callback rollbackStackedRedemptionsCallback * @param {Error|null} error Error object if failed, null otherwise. * @param {RedemptionsRollbacksCreateResponseBody} [data] The data returned by the service call. * @param {Object} [response] Full response object if successful. */ /** * 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](/api-reference/redemptions/rollback-redemption). You can roll back a redemption up to 3 months back. * @param {String} parentRedemptionId Unique identifier of a parent redemption, e.g. r_JQfm73zWSJFQxs3bGxweYjgm. * @param {RedemptionsRollbacksCreateRequestBody} 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. * @param {{ reason?: String, trackingId?: String, }} [opts] Optional parameters * @param {rollbackStackedRedemptionsCallback} [callback] The callback function, accepting three arguments: error, data, response * data is of type: {@link RedemptionsRollbacksCreateResponseBody} * @returns {Promise<(RedemptionsRollbacksCreateResponseBody | undefined)>} Depending on whether the `callback` parameter is provided, the promise will resolve with a `RedemptionsRollbacksCreateResponseBody` object or with `undefined`. */ rollbackStackedRedemptions(parentRedemptionId: string, redemptionsRollbacksCreateRequestBody: RedemptionsRollbacksCreateRequestBody, opts?: { reason?: string; trackingId?: string; }, callback?: (error: Error | null, data?: RedemptionsRollbacksCreateResponseBody, response?: any) => any): Promise<(RedemptionsRollbacksCreateResponseBody | undefined)>; } import RedemptionsGetResponseBody from '../model/RedemptionsGetResponseBody'; import VouchersRedemptionGetResponseBody from '../model/VouchersRedemptionGetResponseBody'; import ParameterOrderListRedemptions from '../model/ParameterOrderListRedemptions'; import ParameterCreatedBeforeAfter from '../model/ParameterCreatedBeforeAfter'; import ParameterFiltersListRedemptions from '../model/ParameterFiltersListRedemptions'; import RedemptionsListResponseBody from '../model/RedemptionsListResponseBody'; import RedemptionsRedeemRequestBody from '../model/RedemptionsRedeemRequestBody'; import RedemptionsRedeemResponseBody from '../model/RedemptionsRedeemResponseBody'; import RedemptionsRollbackCreateRequestBody from '../model/RedemptionsRollbackCreateRequestBody'; import RedemptionsRollbackCreateResponseBody from '../model/RedemptionsRollbackCreateResponseBody'; import RedemptionsRollbacksCreateRequestBody from '../model/RedemptionsRollbacksCreateRequestBody'; import RedemptionsRollbacksCreateResponseBody from '../model/RedemptionsRollbacksCreateResponseBody';