=begin #Voucherify API #Voucherify promotion engine REST API. Please see https://docs.voucherify.io/docs for more details. The version of the OpenAPI document: v2018-08-01 Contact: support@voucherify.io Generated by: https://openapi-generator.tech OpenAPI Generator version: 7.0.1 =end require 'cgi' module VoucherifySdk class CampaignsApi attr_accessor :api_client def initialize(api_client = ApiClient.default) @api_client = api_client end # 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. # @param 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. # @param code [String] A custom **code** that identifies the voucher. # @param [Hash] opts the optional parameters # @option opts [CampaignsVouchersCreateRequestBody] :campaigns_vouchers_create_request_body Specify the voucher parameters that you would like to overwrite. # @return [CampaignsVouchersCreateResponseBody] 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 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. # @param 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. # @param code [String] A custom **code** that identifies the voucher. # @param [Hash] opts the optional parameters # @option opts [CampaignsVouchersCreateRequestBody] :campaigns_vouchers_create_request_body Specify the voucher parameters that you would like to overwrite. # @return [Array<(CampaignsVouchersCreateResponseBody, Integer, Hash)>] CampaignsVouchersCreateResponseBody data, response status code and response headers private def add_voucher_with_specific_code_to_campaign_with_http_info(campaign_id, code, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: CampaignsApi.add_voucher_with_specific_code_to_campaign ...' end # verify the required parameter 'campaign_id' is set if @api_client.config.client_side_validation && campaign_id.nil? fail ArgumentError, "Missing the required parameter 'campaign_id' when calling CampaignsApi.add_voucher_with_specific_code_to_campaign" end # verify the required parameter 'code' is set if @api_client.config.client_side_validation && code.nil? fail ArgumentError, "Missing the required parameter 'code' when calling CampaignsApi.add_voucher_with_specific_code_to_campaign" end # resource path local_var_path = '/v1/campaigns/{campaignId}/vouchers/{code}'.sub('{' + 'campaignId' + '}', CGI.escape(campaign_id.to_s)).sub('{' + 'code' + '}', CGI.escape(code.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' content_type = @api_client.select_header_content_type(['application/json']) if !content_type.nil? header_params['Content-Type'] = content_type end # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'campaigns_vouchers_create_request_body']) # return_type return_type = opts[:debug_return_type] || 'CampaignsVouchersCreateResponseBody' # auth_names auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] new_options = opts.merge( :operation => :"CampaignsApi.add_voucher_with_specific_code_to_campaign", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: CampaignsApi#add_voucher_with_specific_code_to_campaign\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # 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. # @param 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. # @param [Hash] opts the optional parameters # @option opts [Integer] :vouchers_count Number of vouchers that should be added. # @option opts [CampaignsVouchersCreateInBulkRequestBody] :campaigns_vouchers_create_in_bulk_request_body Specify the voucher parameters that you would like to overwrite. # @return [CampaignsVouchersCreateResponseBody] def add_vouchers_to_campaign(campaign_id, opts = {}) data, _status_code, _headers = add_vouchers_to_campaign_with_http_info(campaign_id, opts) data end # 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. # @param 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. # @param [Hash] opts the optional parameters # @option opts [Integer] :vouchers_count Number of vouchers that should be added. # @option opts [CampaignsVouchersCreateInBulkRequestBody] :campaigns_vouchers_create_in_bulk_request_body Specify the voucher parameters that you would like to overwrite. # @return [Array<(CampaignsVouchersCreateResponseBody, Integer, Hash)>] CampaignsVouchersCreateResponseBody data, response status code and response headers private def add_vouchers_to_campaign_with_http_info(campaign_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: CampaignsApi.add_vouchers_to_campaign ...' end # verify the required parameter 'campaign_id' is set if @api_client.config.client_side_validation && campaign_id.nil? fail ArgumentError, "Missing the required parameter 'campaign_id' when calling CampaignsApi.add_vouchers_to_campaign" end # resource path local_var_path = '/v1/campaigns/{campaignId}/vouchers'.sub('{' + 'campaignId' + '}', CGI.escape(campaign_id.to_s)) # query parameters query_params = opts[:query_params] || {} query_params[:'vouchers_count'] = opts[:'vouchers_count'] if !opts[:'vouchers_count'].nil? # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' content_type = @api_client.select_header_content_type(['application/json']) if !content_type.nil? header_params['Content-Type'] = content_type end # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'campaigns_vouchers_create_in_bulk_request_body']) # return_type return_type = opts[:debug_return_type] || 'CampaignsVouchersCreateResponseBody' # auth_names auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] new_options = opts.merge( :operation => :"CampaignsApi.add_vouchers_to_campaign", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: CampaignsApi#add_vouchers_to_campaign\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # 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. # @param [Hash] opts the optional parameters # @option opts [CampaignsCreateRequestBody] :campaigns_create_request_body Specify the details of the campaign that you would like to create. # @return [CampaignsCreateResponseBody] def create_campaign(opts = {}) data, _status_code, _headers = create_campaign_with_http_info(opts) data end # 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. # @param [Hash] opts the optional parameters # @option opts [CampaignsCreateRequestBody] :campaigns_create_request_body Specify the details of the campaign that you would like to create. # @return [Array<(CampaignsCreateResponseBody, Integer, Hash)>] CampaignsCreateResponseBody data, response status code and response headers private def create_campaign_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: CampaignsApi.create_campaign ...' end # resource path local_var_path = '/v1/campaigns' # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' content_type = @api_client.select_header_content_type(['application/json']) if !content_type.nil? header_params['Content-Type'] = content_type end # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'campaigns_create_request_body']) # return_type return_type = opts[:debug_return_type] || 'CampaignsCreateResponseBody' # auth_names auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] new_options = opts.merge( :operation => :"CampaignsApi.create_campaign", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: CampaignsApi#create_campaign\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # 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. # @param 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. # @param [Hash] opts the optional parameters # @option opts [Boolean] :force 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. # @return [CampaignsDeleteResponseBody] def delete_campaign(campaign_id, opts = {}) data, _status_code, _headers = delete_campaign_with_http_info(campaign_id, opts) data end # 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. # @param 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. # @param [Hash] opts the optional parameters # @option opts [Boolean] :force 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. # @return [Array<(CampaignsDeleteResponseBody, Integer, Hash)>] CampaignsDeleteResponseBody data, response status code and response headers private def delete_campaign_with_http_info(campaign_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: CampaignsApi.delete_campaign ...' end # verify the required parameter 'campaign_id' is set if @api_client.config.client_side_validation && campaign_id.nil? fail ArgumentError, "Missing the required parameter 'campaign_id' when calling CampaignsApi.delete_campaign" end # resource path local_var_path = '/v1/campaigns/{campaignId}'.sub('{' + 'campaignId' + '}', CGI.escape(campaign_id.to_s)) # query parameters query_params = opts[:query_params] || {} query_params[:'force'] = opts[:'force'] if !opts[:'force'].nil? # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'CampaignsDeleteResponseBody' # auth_names auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] new_options = opts.merge( :operation => :"CampaignsApi.delete_campaign", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: CampaignsApi#delete_campaign\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # 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. # @param 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. # @param [Hash] opts the optional parameters # @return [CampaignsDisableResponseBody] def disable_campaign(campaign_id, opts = {}) data, _status_code, _headers = disable_campaign_with_http_info(campaign_id, opts) data end # 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. # @param 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. # @param [Hash] opts the optional parameters # @return [Array<(CampaignsDisableResponseBody, Integer, Hash)>] CampaignsDisableResponseBody data, response status code and response headers private def disable_campaign_with_http_info(campaign_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: CampaignsApi.disable_campaign ...' end # verify the required parameter 'campaign_id' is set if @api_client.config.client_side_validation && campaign_id.nil? fail ArgumentError, "Missing the required parameter 'campaign_id' when calling CampaignsApi.disable_campaign" end # resource path local_var_path = '/v1/campaigns/{campaignId}/disable'.sub('{' + 'campaignId' + '}', CGI.escape(campaign_id.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'CampaignsDisableResponseBody' # auth_names auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] new_options = opts.merge( :operation => :"CampaignsApi.disable_campaign", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: CampaignsApi#disable_campaign\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # 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. # @param 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. # @param [Hash] opts the optional parameters # @return [CampaignsEnableResponseBody] def enable_campaign(campaign_id, opts = {}) data, _status_code, _headers = enable_campaign_with_http_info(campaign_id, opts) data end # 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. # @param 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. # @param [Hash] opts the optional parameters # @return [Array<(CampaignsEnableResponseBody, Integer, Hash)>] CampaignsEnableResponseBody data, response status code and response headers private def enable_campaign_with_http_info(campaign_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: CampaignsApi.enable_campaign ...' end # verify the required parameter 'campaign_id' is set if @api_client.config.client_side_validation && campaign_id.nil? fail ArgumentError, "Missing the required parameter 'campaign_id' when calling CampaignsApi.enable_campaign" end # resource path local_var_path = '/v1/campaigns/{campaignId}/enable'.sub('{' + 'campaignId' + '}', CGI.escape(campaign_id.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'CampaignsEnableResponseBody' # auth_names auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] new_options = opts.merge( :operation => :"CampaignsApi.enable_campaign", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: CampaignsApi#enable_campaign\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get Campaign # Retrieves the campaign with the given campaign ID or campaign name. # @param 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. # @param [Hash] opts the optional parameters # @return [CampaignsGetResponseBody] def get_campaign(campaign_id, opts = {}) data, _status_code, _headers = get_campaign_with_http_info(campaign_id, opts) data end # Get Campaign # Retrieves the campaign with the given campaign ID or campaign name. # @param 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. # @param [Hash] opts the optional parameters # @return [Array<(CampaignsGetResponseBody, Integer, Hash)>] CampaignsGetResponseBody data, response status code and response headers private def get_campaign_with_http_info(campaign_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: CampaignsApi.get_campaign ...' end # verify the required parameter 'campaign_id' is set if @api_client.config.client_side_validation && campaign_id.nil? fail ArgumentError, "Missing the required parameter 'campaign_id' when calling CampaignsApi.get_campaign" end # resource path local_var_path = '/v1/campaigns/{campaignId}'.sub('{' + 'campaignId' + '}', CGI.escape(campaign_id.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'CampaignsGetResponseBody' # auth_names auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] new_options = opts.merge( :operation => :"CampaignsApi.get_campaign", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: CampaignsApi#get_campaign\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # 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. # @param 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. # @param [Hash] opts the optional parameters # @option opts [Array] :campaigns_import_voucher_item Discount type, expiration date and the remaining attributes will be taken from the Campaign settings. # @return [CampaignsImportCreateResponseBody] 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 # 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. # @param 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. # @param [Hash] opts the optional parameters # @option opts [Array] :campaigns_import_voucher_item Discount type, expiration date and the remaining attributes will be taken from the Campaign settings. # @return [Array<(CampaignsImportCreateResponseBody, Integer, Hash)>] CampaignsImportCreateResponseBody data, response status code and response headers private def import_vouchers_to_campaign_with_http_info(campaign_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: CampaignsApi.import_vouchers_to_campaign ...' end # verify the required parameter 'campaign_id' is set if @api_client.config.client_side_validation && campaign_id.nil? fail ArgumentError, "Missing the required parameter 'campaign_id' when calling CampaignsApi.import_vouchers_to_campaign" end # resource path local_var_path = '/v1/campaigns/{campaignId}/import'.sub('{' + 'campaignId' + '}', CGI.escape(campaign_id.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' content_type = @api_client.select_header_content_type(['application/json']) if !content_type.nil? header_params['Content-Type'] = content_type end # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'campaigns_import_voucher_item']) # return_type return_type = opts[:debug_return_type] || 'CampaignsImportCreateResponseBody' # auth_names auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] new_options = opts.merge( :operation => :"CampaignsApi.import_vouchers_to_campaign", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: CampaignsApi#import_vouchers_to_campaign\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # 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. # @param 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. # @param file [File] File path. # @param [Hash] opts the optional parameters # @return [CampaignsImportCsvCreateResponseBody] 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 # 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. # @param 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. # @param file [File] File path. # @param [Hash] opts the optional parameters # @return [Array<(CampaignsImportCsvCreateResponseBody, Integer, Hash)>] CampaignsImportCsvCreateResponseBody data, response status code and response headers private def import_vouchers_to_campaign_using_csv_with_http_info(campaign_id, file, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: CampaignsApi.import_vouchers_to_campaign_using_csv ...' end # verify the required parameter 'campaign_id' is set if @api_client.config.client_side_validation && campaign_id.nil? fail ArgumentError, "Missing the required parameter 'campaign_id' when calling CampaignsApi.import_vouchers_to_campaign_using_csv" end # verify the required parameter 'file' is set if @api_client.config.client_side_validation && file.nil? fail ArgumentError, "Missing the required parameter 'file' when calling CampaignsApi.import_vouchers_to_campaign_using_csv" end # resource path local_var_path = '/v1/campaigns/{campaignId}/importCSV'.sub('{' + 'campaignId' + '}', CGI.escape(campaign_id.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' content_type = @api_client.select_header_content_type(['multipart/form-data']) if !content_type.nil? header_params['Content-Type'] = content_type end # form parameters form_params = opts[:form_params] || {} form_params['file'] = file # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'CampaignsImportCsvCreateResponseBody' # auth_names auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] new_options = opts.merge( :operation => :"CampaignsApi.import_vouchers_to_campaign_using_csv", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: CampaignsApi#import_vouchers_to_campaign_using_csv\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # 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. # @param [Hash] opts the optional parameters # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100 items. # @option opts [Integer] :page Which page of results to return. # @option opts [ParameterCampaignType] :campaign_type This attribute allows filtering by campaign type. # @option opts [ParameterExpandListCampaigns] :expand Include an expanded categories object in the response. (default to 'category') # @option opts [ParameterOrderListCampaigns] :order Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. # @return [CampaignsListResponseBody] def list_campaigns(opts = {}) data, _status_code, _headers = list_campaigns_with_http_info(opts) data end # 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. # @param [Hash] opts the optional parameters # @option opts [Integer] :limit A limit on the number of objects to be returned. Limit can range between 1 and 100 items. # @option opts [Integer] :page Which page of results to return. # @option opts [ParameterCampaignType] :campaign_type This attribute allows filtering by campaign type. # @option opts [ParameterExpandListCampaigns] :expand Include an expanded categories object in the response. (default to 'category') # @option opts [ParameterOrderListCampaigns] :order Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. # @return [Array<(CampaignsListResponseBody, Integer, Hash)>] CampaignsListResponseBody data, response status code and response headers private def list_campaigns_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: CampaignsApi.list_campaigns ...' end if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] > 100 fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling CampaignsApi.list_campaigns, must be smaller than or equal to 100.' end if @api_client.config.client_side_validation && !opts[:'limit'].nil? && opts[:'limit'] < 1 fail ArgumentError, 'invalid value for "opts[:"limit"]" when calling CampaignsApi.list_campaigns, must be greater than or equal to 1.' end if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] > 100 fail ArgumentError, 'invalid value for "opts[:"page"]" when calling CampaignsApi.list_campaigns, must be smaller than or equal to 100.' end # resource path local_var_path = '/v1/campaigns' # query parameters query_params = opts[:query_params] || {} query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil? query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil? query_params[:'campaign_type'] = opts[:'campaign_type'] if !opts[:'campaign_type'].nil? query_params[:'expand'] = opts[:'expand'] if !opts[:'expand'].nil? query_params[:'order'] = opts[:'order'] if !opts[:'order'].nil? # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] || 'CampaignsListResponseBody' # auth_names auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] new_options = opts.merge( :operation => :"CampaignsApi.list_campaigns", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: CampaignsApi#list_campaigns\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # 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. # @param 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. # @param [Hash] opts the optional parameters # @option opts [CampaignsUpdateRequestBody] :campaigns_update_request_body Specify the campaign parameters to be updated. # @return [CampaignsUpdateResponseBody] def update_campaign(campaign_id, opts = {}) data, _status_code, _headers = update_campaign_with_http_info(campaign_id, opts) data end # 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. # @param 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. # @param [Hash] opts the optional parameters # @option opts [CampaignsUpdateRequestBody] :campaigns_update_request_body Specify the campaign parameters to be updated. # @return [Array<(CampaignsUpdateResponseBody, Integer, Hash)>] CampaignsUpdateResponseBody data, response status code and response headers private def update_campaign_with_http_info(campaign_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: CampaignsApi.update_campaign ...' end # verify the required parameter 'campaign_id' is set if @api_client.config.client_side_validation && campaign_id.nil? fail ArgumentError, "Missing the required parameter 'campaign_id' when calling CampaignsApi.update_campaign" end # resource path local_var_path = '/v1/campaigns/{campaignId}'.sub('{' + 'campaignId' + '}', CGI.escape(campaign_id.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' content_type = @api_client.select_header_content_type(['application/json']) if !content_type.nil? header_params['Content-Type'] = content_type end # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'campaigns_update_request_body']) # return_type return_type = opts[:debug_return_type] || 'CampaignsUpdateResponseBody' # auth_names auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] new_options = opts.merge( :operation => :"CampaignsApi.update_campaign", :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => return_type ) data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options) if @api_client.config.debugging @api_client.config.logger.debug "API called: CampaignsApi#update_campaign\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end end end