Class: VoucherifySdk::CampaignsApi

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ CampaignsApi

Returns a new instance of CampaignsApi.



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

def api_client
  @api_client
end

Instance Method Details

#add_voucher_with_specific_code_to_campaign(campaign_id, code, opts = {}) ⇒ CampaignsVouchersCreateResponseBody

Add Voucher with Specific Code to Campaign This method gives a possibility to add a new voucher to an existing campaign. The voucher definition will be inherited from the definition kept in the campaign profile. However, you are able to overwrite a few properties inherited from the campaign.

Parameters:

  • campaign_id (String)

    The campaign ID or name of the campaign to which voucher will be added. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value.

  • code (String)

    A custom code that identifies the voucher.

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

    the optional parameters

Options Hash (opts):

Returns:



29
30
31
32
# File 'lib/VoucherifySdk/api/campaigns_api.rb', line 29

def add_voucher_with_specific_code_to_campaign(campaign_id, code, opts = {})
  data, _status_code, _headers = add_voucher_with_specific_code_to_campaign_with_http_info(campaign_id, code, opts)
  data
end

#add_vouchers_to_campaign(campaign_id, opts = {}) ⇒ CampaignsVouchersCreateCombinedResponseBody

Add Vouchers to Campaign This method gives the possibility to push new vouchers to an existing campaign. New vouchers will inherit properties from the campaign profile. However, it is possible to overwrite some of them in the request body. If you provide an optional code_config parameter with a voucher code configuration, then it will be used to generate new voucher codes. Otherwise, the voucher code configuration from the campaign will be used. 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.

Parameters:

  • campaign_id (String)

    The campaign ID or name of the campaign to which voucher(s) will be added. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value.

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

    the optional parameters

Options Hash (opts):

  • :vouchers_count (Integer)

    Number of vouchers that should be added.

  • :campaigns_vouchers_create_in_bulk_request_body (CampaignsVouchersCreateInBulkRequestBody)

    Specify the voucher parameters that you would like to overwrite.

Returns:



97
98
99
100
# File 'lib/VoucherifySdk/api/campaigns_api.rb', line 97

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

#create_campaign(opts = {}) ⇒ CampaignsCreateResponseBody

Create Campaign Method to create a batch of vouchers aggregated in one campaign. You can choose a variety of voucher types and define a unique pattern for generating codes. 📘 Global uniqueness All campaign codes are unique across the whole project. Voucherify will not allow you to generate 2 campaigns with the same coupon code. 🚧 Code generation status This is an asynchronous action; you cant read or modify a newly created campaign until the code generation is completed. See the creation_status field in the campaign object description.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :campaigns_create_request_body (CampaignsCreateRequestBody)

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

Returns:



164
165
166
167
# File 'lib/VoucherifySdk/api/campaigns_api.rb', line 164

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

#delete_campaign(campaign_id, opts = {}) ⇒ CampaignsDeleteResponseBody

Delete Campaign Deletes a campaign and all related vouchers. This action cannot be undone. Also, this method immediately removes any redemptions on the voucher. If the force parameter is set to false or not set at all, the campaign and all related vouchers will be moved to the bin. 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.

Parameters:

  • campaign_id (String)

    You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value.

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

    the optional parameters

Options Hash (opts):

  • :force (Boolean)

    If this flag is set to true, the campaign and related vouchers will be removed permanently. If it is set to false or not set at all, the campaign and related vouchers will be moved to the bin. Going forward, the user will be able to create the next campaign with exactly the same name.

Returns:



229
230
231
232
# File 'lib/VoucherifySdk/api/campaigns_api.rb', line 229

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

#disable_campaign(campaign_id, opts = {}) ⇒ Object

Disable Campaign There are various times when youll want to manage a campaigns accessibility. This can be done by two API methods for managing the campaign state - enable and disable. Sets campaign state to inactive. The vouchers in this campaign can no longer be redeemed.

Parameters:

  • campaign_id (String)

    The campaign ID or name of the campaign being disabled. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value.

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

    the optional parameters

Returns:

  • (Object)


290
291
292
293
# File 'lib/VoucherifySdk/api/campaigns_api.rb', line 290

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

#enable_campaign(campaign_id, opts = {}) ⇒ Object

Enable Campaign There are various times when youll want to manage a campaigns accessibility. This can be done by two API methods for managing the campaign state - enable and disable. Sets campaign state to active. The vouchers in this campaign can be redeemed - only if the redemption occurs after the start date of the campaign and voucher and the voucher and campaign are not expired.

Parameters:

  • campaign_id (String)

    The campaign ID or name of the campaign being enabled. You can either pass the campaign ID, which was assigned by Voucherify or the name of the campaign as the path parameter value.

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

    the optional parameters

Returns:

  • (Object)


349
350
351
352
# File 'lib/VoucherifySdk/api/campaigns_api.rb', line 349

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

#export_campaign_transactions(campaign_id, opts = {}) ⇒ CampaignsTransactionsExportCreateResponseBody

Export Campaign Transactions Export transactions is an asynchronous process that generates a CSV file with the data about credit movements on all gift cards or point movements on all loyalty cards in a given campaign. To export transactions: 1. In the export request, use parameters to select which fields will be exported, in what order, and which data will be filtered. 2. Use the returned id to track the export status with the GET Export method. 3. In the GET Export method, when the returned status field has the DONE value, the export file has been generated. 4. Use the URL in the result property to download the file. You must be logged to your Voucherify account on a given cluster in the browser to be able to download the file. An export request will almost always result in a single file being generated by the system. However, when the data volume is large, the system may split the results into multiple files. An example export file can look as follows: 👍 Export Loyalty Campaign Transactions For loyalty campaigns, this method works in the same way the POST Export Loyalty Campaign Transactions does.

Parameters:

  • campaign_id (String)

    You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value.

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

    the optional parameters

Options Hash (opts):

Returns:



409
410
411
412
# File 'lib/VoucherifySdk/api/campaigns_api.rb', line 409

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

#get_campaign(campaign_id, opts = {}) ⇒ CampaignsGetResponseBody

Get Campaign Retrieves the campaign with the given campaign ID or campaign name.

Parameters:

  • campaign_id (String)

    You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value.

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

    the optional parameters

Returns:



474
475
476
477
# File 'lib/VoucherifySdk/api/campaigns_api.rb', line 474

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

#get_campaign_summary(campaign_id, opts = {}) ⇒ CampaignsSummaryGetResponseBody

Get Campaign Summary Returns data for campaign analytics, covering validations, redemptions, publications, and other details specific to a given campaign type. Use start_date and end_date to narrow down the data to specific periods. 🚧 Campaigns created before 17 June 2025 This endpoint returns analytics data for campaigns that were created after 17 June 2025. Older campaigns return empty data.

Parameters:

  • campaign_id (String)

    You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value.

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

    the optional parameters

Options Hash (opts):

  • :start_date (Date)

    Timestamp representing the date which results must begin on. Represented in ISO 8601 format.

  • :end_date (Date)

    Timestamp representing the date which results must end on. Represented in ISO 8601 format.

Returns:



535
536
537
538
# File 'lib/VoucherifySdk/api/campaigns_api.rb', line 535

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

#import_vouchers_to_campaign(campaign_id, opts = {}) ⇒ CampaignsImportCreateResponseBody

Import Vouchers to Campaign Imports vouchers to an existing campaign. 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.

Parameters:

  • campaign_id (String)

    The ID of an existing campaign to which youre importing the codes. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value.

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

    the optional parameters

Options Hash (opts):

  • :campaigns_import_voucher_item (Array<CampaignsImportVoucherItem>)

    Discount type, expiration date and the remaining attributes will be taken from the Campaign settings.

Returns:



599
600
601
602
# File 'lib/VoucherifySdk/api/campaigns_api.rb', line 599

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

#import_vouchers_to_campaign_using_csv(campaign_id, opts = {}) ⇒ CampaignsImportCsvCreateResponseBody

Import Vouchers to Campaign by CSV Imports vouchers to an existing campaign. The CSV file has to include headers in the first line. 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.

Parameters:

  • campaign_id (String)

    The campaign ID or name of the campaign being enabled. You can either pass the campaign ID, which was assigned by Voucherify or the name of the campaign as the path parameter value.

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

    the optional parameters

Options Hash (opts):

  • :file (File)

    File path.

Returns:



665
666
667
668
# File 'lib/VoucherifySdk/api/campaigns_api.rb', line 665

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

#list_campaign_transactions(campaign_id, opts = {}) ⇒ CampaignsTransactionsListResponseBody

List Campaign Transactions Retrieves all transactions for the campaign with the given campaign ID or campaign name. The id filter denotes the unique transaction identifier. 🚧 The endpoint works only for gift card and loyalty campaigns.

Parameters:

  • campaign_id (String)

    You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value.

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

  • :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.

  • :filters (ParametersFiltersListCampaignTransactions)

    Filters for listing responses.

Returns:



735
736
737
738
# File 'lib/VoucherifySdk/api/campaigns_api.rb', line 735

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

#list_campaigns(opts = {}) ⇒ CampaignsListResponseBody

List Campaigns Retrieve a list of campaigns in a project. The campaigns are returned sorted by creation date, with the most recent campaigns appearing first. When you get a list of campaigns, you can optionally specify query parameters to customize the amount of campaigns returned per call using limit, which page of campaigns to return using page, sort the campaigns using the order query parameter and filter the results by the campaign_type. This method will return an error when trying to return a limit of more than 100 campaigns.

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.

  • :campaign_type (ParameterCampaignType)

    This attribute allows filtering by campaign type.

  • :expand (ParameterExpandListCampaigns)

    Includes an expanded categories object in the response. If the Areas and Stores Enterprise feature is enabled, add access_settings_assignments to return assigned areas and stores.

  • :order (ParameterOrderListCampaigns)

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

  • :filters (ParameterFiltersListCampaigns)

    Filters the results by various campaign properties.

Returns:



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

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

#update_campaign(campaign_id, opts = {}) ⇒ CampaignsUpdateResponseBody

Update Campaign Updates the specified campaign 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. 🚧 Vouchers will be affected This method will update vouchers aggregated in the campaign. It will affect all vouchers that are not published or redeemed yet.

Parameters:

  • campaign_id (String)

    You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value.

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

    the optional parameters

Options Hash (opts):

Returns:



878
879
880
881
# File 'lib/VoucherifySdk/api/campaigns_api.rb', line 878

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