Class: VoucherifySdk::VouchersApi

Inherits:
Object
  • Object
show all
Defined in:
lib/VoucherifySdk/api/vouchers_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ VouchersApi



19
20
21
# File 'lib/VoucherifySdk/api/vouchers_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/vouchers_api.rb', line 17

def api_client
  @api_client
end

Instance Method Details

#create_voucher(code, opts = {}) ⇒ VouchersCreateResponseBody

Create Voucher Create a standalone voucher. You can choose to create a GIFT_VOUCHER, a DISCOUNT_VOUCHER, or a LOYALTY_CARD. The code path parameter can use all letters of the English alphabet, Arabic numerals and special characters. When you create a new voucher, you can specify a type to create it. Creating a new voucher will create a new standalone voucher if no campaign name or campaign_id is provided. However, if an ID or name of a campaign with the type set to STANDALONE is provided, the voucher will be added to such campaign. In the case of the loyalty card, a campaign name or ID is required. 🚧 Standalone Vouchers and Campaigns In version [v20241004](support.voucherify.io/article/23-whats-new-in-voucherify#v20241004), standalone vouchers created through the Voucherify dashboard create a campaign for that voucher. However, vouchers created through the API do not have a campaign attached, so the values for campaign and campaign_id are null. Voucherify developers work on adding an optional feature to create a standalone voucher campaign through the API. Follow the [Voucherify Release Notes](support.voucherify.io/article/23-whats-new-in-voucherify#v20241004) for more details about released features.

Options Hash (opts):



28
29
30
31
# File 'lib/VoucherifySdk/api/vouchers_api.rb', line 28

def create_voucher(code, opts = {})
  data, _status_code, _headers = create_voucher_with_http_info(code, opts)
  data
end

#delete_voucher(code, opts = {}) ⇒ nil

Delete Voucher Deletes a voucher. This operation cannot be undone. Additionally, this operation removes any redemptions on the voucher. If the force parameter is set to false or not set at all, the voucher will be moved to the bin.

Options Hash (opts):

  • :force (Boolean)

    If this flag is set to true, the voucher will be removed permanently. If it is set to false or not set at all, the voucher will be moved to the bin. Going forward, the user will be able to create another voucher with exactly the same code.



94
95
96
97
# File 'lib/VoucherifySdk/api/vouchers_api.rb', line 94

def delete_voucher(code, opts = {})
  delete_voucher_with_http_info(code, opts)
  nil
end

#disable_voucher(code, opts = {}) ⇒ VouchersDisableResponseBody

Disable Voucher There are various times when youll want to manage a vouchers accessibility. This can be done by two API methods for managing the voucher state - enable and disable. _ This method sets the voucher state to inactive. The voucher cannot be redeemed.



153
154
155
156
# File 'lib/VoucherifySdk/api/vouchers_api.rb', line 153

def disable_voucher(code, opts = {})
  data, _status_code, _headers = disable_voucher_with_http_info(code, opts)
  data
end

#enable_voucher(code, opts = {}) ⇒ VouchersEnableResponseBody

Enable Voucher There are various times when youll want to manage a vouchers accessibility. This can be done by two API methods for managing the voucher state - enable and disable. _ The method sets the voucher state to active. The voucher can be redeemed - only if the redemption occurs after the start date and the voucher is not expired.



212
213
214
215
# File 'lib/VoucherifySdk/api/vouchers_api.rb', line 212

def enable_voucher(code, opts = {})
  data, _status_code, _headers = enable_voucher_with_http_info(code, opts)
  data
end

#export_voucher_transactions(code, opts = {}) ⇒ VouchersTransactionsExportCreateResponseBody

Export Voucher Transactions Export transactions that are associated with credit movements on a gift card or loyalty card.

Options Hash (opts):



272
273
274
275
# File 'lib/VoucherifySdk/api/vouchers_api.rb', line 272

def export_voucher_transactions(code, opts = {})
  data, _status_code, _headers = export_voucher_transactions_with_http_info(code, opts)
  data
end

#generate_random_code(opts = {}) ⇒ VouchersCreateResponseBody

Generate Random Code Create a standalone voucher. You can choose to create a GIFT_VOUCHER, a DISCOUNT_VOUCHER, or a LOYALTY_CARD. When you create a new voucher, you can specify a type to create it. Creating a new voucher will create a new standalone voucher if no campaign name or campaign_id is provided. However, if an ID or name of a campaign with the type set to STANDALONE is provided, the voucher will be added to such campaign. In case of the loyalty card, a campaign name is required. You can optionally use the code parameter to define a specific code or the code_config parameter to design rules for Voucherify API to create a random code. If neither of the two parameters are passed, then a random code is generated by the Voucherify API. This method will return an error when trying to create a voucher that already exists. 🚧 Standalone Vouchers and Campaigns In version [v20241004](support.voucherify.io/article/23-whats-new-in-voucherify#v20241004), standalone vouchers created through the Voucherify dashboard create a campaign for that voucher. However, vouchers created through the API do not have a campaign attached, so the values for campaign and campaign_id are null. Voucherify developers work on adding an optional feature to create a standalone voucher campaign through the API. Follow the [Voucherify Release Notes](support.voucherify.io/article/23-whats-new-in-voucherify#v20241004) for more details about released features.

Options Hash (opts):

  • :vouchers_create_request_body (VouchersCreateRequestBody)

    Specify the details of the voucher that you would like to create.



337
338
339
340
# File 'lib/VoucherifySdk/api/vouchers_api.rb', line 337

def generate_random_code(opts = {})
  data, _status_code, _headers = generate_random_code_with_http_info(opts)
  data
end

#get_voucher(code, opts = {}) ⇒ VouchersGetResponseBody

Get Voucher Retrieves the voucher with the given code or unique Voucherify ID. You can either pass the voucher ID which was assigned by Voucherify, e.g., v_7HxHkf4VAkMuc8u4lZs78lyRwhRze5UE, or the code of the voucher as the path parameter value, e.g., 7fjWdr.



401
402
403
404
# File 'lib/VoucherifySdk/api/vouchers_api.rb', line 401

def get_voucher(code, opts = {})
  data, _status_code, _headers = get_voucher_with_http_info(code, opts)
  data
end

#import_vouchers(vouchers_import_create_item_request_body, opts = {}) ⇒ VouchersImportCreateResponseBody

Import Vouchers Import standalone vouchers and gift cards into the repository. 📘 Important notes - **Start and expiration dates** need to be provided in compliance with the ISO 8601 norms. For example, 2020-03-11T09:00:00.000Z. - Custom code attributes (not supported by-default) need to be added as code metadata. - You **cannot import the same codes** to a single Voucherify Project. Any parameters not provided in the payload will be left blank or null. For both **standalone discount vouchers and gift cards**, you can import the following fields: - code - category - active - type - start_date - expiration_date - redemption.quantity - additional_info - metadata For **gift cards**, you can also import the following field: - gift.amount For **discount vouchers**, you can import the discount object. The object will slightly vary depending on the type of discount. Each discount type requires the type to be defined in the import. Fields other than the ones listed above wont be imported. Even if provided, they will be silently skipped. This API request starts a process that affects Voucherify data in bulk. In case of small jobs (like bulk update) the request is put into a queue and processed once every other bulk request placed in the queue prior to this request is finished. However, when the job takes a longer time (like vouchers generation) then it is processed in small portions in a round-robin fashion. When there is a list of vouchers generation scheduled, then they will all have the IN_PROGRESS status shortly. This way, small jobs added just after scheduling big jobs of the same type will be processed in a short time window. The result will return the async ID. You can verify the status of your request via this API request. 🚧 Standalone Vouchers and Campaigns In version [v20241004](support.voucherify.io/article/23-whats-new-in-voucherify#v20241004), standalone vouchers created through the Voucherify dashboard create a campaign for that voucher. However, vouchers imported through the dashboard in the Vouchers section or through the API do not have a campaign attached, so the values for campaign and campaign_id are null.



460
461
462
463
# File 'lib/VoucherifySdk/api/vouchers_api.rb', line 460

def import_vouchers(vouchers_import_create_item_request_body, opts = {})
  data, _status_code, _headers = import_vouchers_with_http_info(vouchers_import_create_item_request_body, opts)
  data
end

#import_vouchers_using_csv(opts = {}) ⇒ VouchersImportCsvCreateResponseBody

Import Vouchers using CSV Import standalone vouchers into the repository using a CSV file. The CSV file has to include headers in the first line. All properties listed in the file headers that cannot be mapped to standard voucher fields will be added to the metadata object. You can find an example CSV file [here](support.voucherify.io/article/45-import-codes-and-share-them-digitally#coupons). _ 📘 Standard voucher fields mapping - Go to the import vouchers endpoint to see all standard CSV fields description (body params section). - Supported CSV file headers: Code,Voucher Type,Value,Discount Type,Category,Start Date,Expiration Date,Redemption Limit,Redeemed Quantity, Redeemed Amount,Active,Additional Info,Custom Metadata Property Name - **Start and expiration dates** need to be provided in compliance with the ISO 8601 norms. For example, 2020-03-11T09:00:00.000Z. - YYYY-MM-DD - YYYY-MM-DDTHH - YYYY-MM-DDTHH:mm - YYYY-MM-DDTHH:mm:ss - YYYY-MM-DDTHH:mm:ssZ - YYYY-MM-DDTHH:mm:ssZ - YYYY-MM-DDTHH:mm:ss.SSSZ - Custom code attributes (not supported by-default) need to be added as code metadata. - You **cannot import the same codes** to a single Voucherify Project. 📘 Categories In the structure representing your data, you can define a category that the voucher belongs to. You can later use the category of a voucher to group and search by specific criteria in the Dashboard and using the List Vouchers endpoint. This API request starts a process that affects Voucherify data in bulk. In case of small jobs (like bulk update) the request is put into a queue and processed once every other bulk request placed in the queue prior to this request is finished. However, when the job takes a longer time (like vouchers generation) then it is processed in small portions in a round-robin fashion. When there is a list of vouchers generation scheduled, then they will all have the IN_PROGRESS status shortly. This way, small jobs added just after scheduling big jobs of the same type will be processed in a short time window. The result will return the async ID. You can verify the status of your request via this API request. 🚧 Standalone Vouchers and Campaigns In version [v20241004](support.voucherify.io/article/23-whats-new-in-voucherify#v20241004), standalone vouchers created through the Voucherify dashboard create a campaign for that voucher. However, vouchers imported through the dashboard in the Vouchers section or through the API do not have a campaign attached, so the values for campaign and campaign_id are null.

Options Hash (opts):

  • :file (File)

    File path.



524
525
526
527
# File 'lib/VoucherifySdk/api/vouchers_api.rb', line 524

def import_vouchers_using_csv(opts = {})
  data, _status_code, _headers = import_vouchers_using_csv_with_http_info(opts)
  data
end

#list_voucher_transactions(code, opts = {}) ⇒ VouchersTransactionsListResponseBody

List Voucher Transactions List transactions that are associated with credit movements on a gift card or loyalty card.

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.

  • :order (ParameterOrderListTransactions)

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

  • :starting_after_id (String)

    A cursor for pagination. It retrieves the transactions starting after a transaction with the given ID.



592
593
594
595
# File 'lib/VoucherifySdk/api/vouchers_api.rb', line 592

def list_voucher_transactions(code, opts = {})
  data, _status_code, _headers = list_voucher_transactions_with_http_info(code, opts)
  data
end

#list_vouchers(opts = {}) ⇒ VouchersListResponseBody

List Vouchers Returns a list of vouchers. By default, the vouchers are returned sorted by creation date, with the most recent vouchers appearing first. A maximum of 100 vouchers are returned in the response. When you get a list of vouchers, you can optionally specify query parameters to customize the number of vouchers returned per call using limit, which page of vouchers to return using page, sort the vouchers using the order query parameter and more. This method will return an error when trying to return a limit of more than 100 vouchers.

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.

  • :category (String)

    Limit search results to vouchers within the specified category.

  • :campaign_id (String)

    Limit search results to vouchers within the specified campaign

  • :customer (String)

    A tracking identifier of a customer who is the holder of the vouchers. It can be an id generated by Voucherify or the source_id. Remember to use the proper URL escape codes if the source_id contains special characters.

  • :campaign (String)

    A unique campaign name, identifies the parent campaign.

  • :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] 2017-09-08T13:52:18.227Z

  • :updated_at (ParameterUpdatedBeforeAfter)

    A filter on the list based on the object updated_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: [updated_at] 2017-09-08T13:52:18.227Z

  • :order (ParameterOrderVouchers)

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

  • :code (String)
  • :ids (Array<String>)


667
668
669
670
# File 'lib/VoucherifySdk/api/vouchers_api.rb', line 667

def list_vouchers(opts = {})
  data, _status_code, _headers = list_vouchers_with_http_info(opts)
  data
end

#release_validation_session(code, session_key, opts = {}) ⇒ nil

Release Validation Session Manually release a validation session that has been set up for the voucher. This method undos the actions that are explained in our guide on how a validation session was established, you can read more here. 📘 Release Session using Dashboard You can also use the Validations Manager in the Dashboard to unlock sessions. [Read more](support.voucherify.io/article/16-dashboard-sections#validations).



748
749
750
751
# File 'lib/VoucherifySdk/api/vouchers_api.rb', line 748

def release_validation_session(code, session_key, opts = {})
  release_validation_session_with_http_info(code, session_key, opts)
  nil
end

#update_voucher(code, vouchers_update_request_body, opts = {}) ⇒ VouchersUpdateResponseBody

Update Voucher Updates the specified voucher by setting the values of the parameters passed in the request body. Any parameters not provided in the payload will be left unchanged. Fields other than the ones listed in the request body wont be modified. Even if provided, they will be silently skipped.



807
808
809
810
# File 'lib/VoucherifySdk/api/vouchers_api.rb', line 807

def update_voucher(code, vouchers_update_request_body, opts = {})
  data, _status_code, _headers = update_voucher_with_http_info(code, vouchers_update_request_body, opts)
  data
end

#update_voucher_balance(code, vouchers_balance_update_request_body, opts = {}) ⇒ VouchersBalanceUpdateResponseBody

Add or Remove Voucher Balance Add balance to an existing gift card or loyalty card.



873
874
875
876
# File 'lib/VoucherifySdk/api/vouchers_api.rb', line 873

def update_voucher_balance(code, vouchers_balance_update_request_body, opts = {})
  data, _status_code, _headers = update_voucher_balance_with_http_info(code, vouchers_balance_update_request_body, opts)
  data
end

#update_vouchers_in_bulk(vouchers_update_in_bulk_item_request_body, opts = {}) ⇒ VouchersUpdateInBulkResponseBody

Update Vouchers in Bulk Updates specific metadata parameters for each code, respectively, in one asynchronous operation. The request can include up to **10 MB** of data. Upserts are not supported. 🚧 Currently, only metadata updates are supported. The response returns a unique asynchronous action ID. Use this ID in the query paramater of the GET Async Action endpoint to check, e.g.: - The status of your request (in queue, in progress, done, or failed) - Resources that failed to be updated - The report file with details about the update This API request starts a process that affects Voucherify data in bulk. In the case of small jobs (like bulk update), the request is put into a queue and processed when every other bulk request placed in the queue prior to this request is finished.



938
939
940
941
# File 'lib/VoucherifySdk/api/vouchers_api.rb', line 938

def update_vouchers_in_bulk(vouchers_update_in_bulk_item_request_body, opts = {})
  data, _status_code, _headers = update_vouchers_in_bulk_with_http_info(vouchers_update_in_bulk_item_request_body, opts)
  data
end

#update_vouchers_metadata_in_bulk(vouchers_metadata_update_in_bulk_request_body, opts = {}) ⇒ VouchersMetadataUpdateInBulkResponseBody

Update Vouchers’ Metadata in Bulk Updates metadata parameters for a list of codes. Every resource in the list will receive the metadata defined in the request. The request can include up to **10 MB** of data. Upserts are not supported. The response returns a unique asynchronous action ID. Use this ID in the query paramater of the GET Async Action endpoint to check, e.g.: - The status of your request (in queue, in progress, done, or failed) - Resources that failed to be updated - The report file with details about the update This API request starts a process that affects Voucherify data in bulk. In the case of small jobs (like bulk update), the request is put into a queue and processed when every other bulk request placed in the queue prior to this request is finished.



1002
1003
1004
1005
# File 'lib/VoucherifySdk/api/vouchers_api.rb', line 1002

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