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 = {}) ⇒ CampaignsVouchersCreateResponseBody

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:



105
106
107
108
# File 'lib/VoucherifySdk/api/campaigns_api.rb', line 105

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:



176
177
178
179
# File 'lib/VoucherifySdk/api/campaigns_api.rb', line 176

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

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

Delete Campaign Permanently deletes a campaign and all related vouchers. This action cannot be undone. Also, this method immediately removes any redemptions on the voucher. 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. Going forward, the user will be able to create the next campaign with exactly the same name.

Returns:



241
242
243
244
# File 'lib/VoucherifySdk/api/campaigns_api.rb', line 241

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 = {}) ⇒ CampaignsDisableResponseBody

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:



306
307
308
309
# File 'lib/VoucherifySdk/api/campaigns_api.rb', line 306

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 = {}) ⇒ CampaignsEnableResponseBody

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:



369
370
371
372
# File 'lib/VoucherifySdk/api/campaigns_api.rb', line 369

def enable_campaign(campaign_id, opts = {})
  data, _status_code, _headers = enable_campaign_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:



432
433
434
435
# File 'lib/VoucherifySdk/api/campaigns_api.rb', line 432

def get_campaign(campaign_id, opts = {})
  data, _status_code, _headers = get_campaign_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:



496
497
498
499
# File 'lib/VoucherifySdk/api/campaigns_api.rb', line 496

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, file, 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.

  • file (File)

    File path.

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

    the optional parameters

Returns:



566
567
568
569
# File 'lib/VoucherifySdk/api/campaigns_api.rb', line 566

def import_vouchers_to_campaign_using_csv(campaign_id, file, opts = {})
  data, _status_code, _headers = import_vouchers_to_campaign_using_csv_with_http_info(campaign_id, file, 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)

    A limit on the number of objects to be returned. Limit can range between 1 and 100 items.

  • :page (Integer)

    Which page of results to return.

  • :campaign_type (ParameterCampaignType)

    This attribute allows filtering by campaign type.

  • :expand (ParameterExpandListCampaigns)

    Include an expanded categories object in the response. (default to β€˜category’)

  • :order (ParameterOrderListCampaigns)

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

Returns:



644
645
646
647
# File 'lib/VoucherifySdk/api/campaigns_api.rb', line 644

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:



725
726
727
728
# File 'lib/VoucherifySdk/api/campaigns_api.rb', line 725

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