=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 PromotionsApi attr_accessor :api_client def initialize(api_client = ApiClient.default) @api_client = api_client end # Add Promotion Tier to Campaign # This method allows you to add a new promotion tier to an existing campaign. The tier hierarchy will be set as the next consequtive integer following the lowest ranking tier. # @param campaign_id [String] Unique campaign ID assigned by Voucherify. # @param [Hash] opts the optional parameters # @option opts [PromotionsTiersCreateRequestBody] :promotions_tiers_create_request_body Specify the promotion tier parameters. # @return [PromotionsTiersCreateResponseBody] def add_promotion_tier_to_campaign(campaign_id, opts = {}) data, _status_code, _headers = add_promotion_tier_to_campaign_with_http_info(campaign_id, opts) data end # Add Promotion Tier to Campaign # This method allows you to add a new promotion tier to an existing campaign. The tier hierarchy will be set as the next consequtive integer following the lowest ranking tier. # @param campaign_id [String] Unique campaign ID assigned by Voucherify. # @param [Hash] opts the optional parameters # @option opts [PromotionsTiersCreateRequestBody] :promotions_tiers_create_request_body Specify the promotion tier parameters. # @return [Array<(PromotionsTiersCreateResponseBody, Integer, Hash)>] PromotionsTiersCreateResponseBody data, response status code and response headers private def add_promotion_tier_to_campaign_with_http_info(campaign_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: PromotionsApi.add_promotion_tier_to_campaign ...' end # resource path local_var_path = '/v1/promotions/{campaignId}/tiers'.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[:'promotions_tiers_create_request_body']) # return_type return_type = opts[:debug_return_type] || 'PromotionsTiersCreateResponseBody' # auth_names auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] new_options = opts.merge( :operation => :"PromotionsApi.add_promotion_tier_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: PromotionsApi#add_promotion_tier_to_campaign\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Create Promotion Stack # This method creates one promotion stack. The sequence of promotion tier IDs will determine the promotion stacking order. # @param campaign_id [String] Unique campaign ID. # @param [Hash] opts the optional parameters # @option opts [PromotionsStacksCreateRequestBody] :promotions_stacks_create_request_body Specify the order of promotion tiers for the promotion stack. # @return [PromotionsStacksCreateResponseBody] def create_promotion_stack(campaign_id, opts = {}) data, _status_code, _headers = create_promotion_stack_with_http_info(campaign_id, opts) data end # Create Promotion Stack # This method creates one promotion stack. The sequence of promotion tier IDs will determine the promotion stacking order. # @param campaign_id [String] Unique campaign ID. # @param [Hash] opts the optional parameters # @option opts [PromotionsStacksCreateRequestBody] :promotions_stacks_create_request_body Specify the order of promotion tiers for the promotion stack. # @return [Array<(PromotionsStacksCreateResponseBody, Integer, Hash)>] PromotionsStacksCreateResponseBody data, response status code and response headers private def create_promotion_stack_with_http_info(campaign_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: PromotionsApi.create_promotion_stack ...' end # resource path local_var_path = '/v1/promotions/{campaignId}/stacks'.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[:'promotions_stacks_create_request_body']) # return_type return_type = opts[:debug_return_type] || 'PromotionsStacksCreateResponseBody' # auth_names auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] new_options = opts.merge( :operation => :"PromotionsApi.create_promotion_stack", :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: PromotionsApi#create_promotion_stack\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Delete Promotion Stack # This method deletes a promotion stack. # @param campaign_id [String] ID of the promotion campaign. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value, e.g., Loyalty Campaign. # @param stack_id [String] Promotion stack ID. # @param [Hash] opts the optional parameters # @return [nil] def delete_promotion_stack(campaign_id, stack_id, opts = {}) delete_promotion_stack_with_http_info(campaign_id, stack_id, opts) nil end # Delete Promotion Stack # This method deletes a promotion stack. # @param campaign_id [String] ID of the promotion campaign. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value, e.g., Loyalty Campaign. # @param stack_id [String] Promotion stack ID. # @param [Hash] opts the optional parameters # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers private def delete_promotion_stack_with_http_info(campaign_id, stack_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: PromotionsApi.delete_promotion_stack ...' end # resource path local_var_path = '/v1/promotions/{campaignId}/stacks/{stackId}'.sub('{' + 'campaignId' + '}', CGI.escape(campaign_id.to_s)).sub('{' + 'stackId' + '}', CGI.escape(stack_id.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] # auth_names auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] new_options = opts.merge( :operation => :"PromotionsApi.delete_promotion_stack", :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: PromotionsApi#delete_promotion_stack\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Delete Promotion Tier # This method deletes a promotion tier. # @param promotion_tier_id [String] Unique promotion tier ID. # @param [Hash] opts the optional parameters # @return [nil] def delete_promotion_tier(promotion_tier_id, opts = {}) delete_promotion_tier_with_http_info(promotion_tier_id, opts) nil end # Delete Promotion Tier # This method deletes a promotion tier. # @param promotion_tier_id [String] Unique promotion tier ID. # @param [Hash] opts the optional parameters # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers private def delete_promotion_tier_with_http_info(promotion_tier_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: PromotionsApi.delete_promotion_tier ...' end # resource path local_var_path = '/v1/promotions/tiers/{promotionTierId}'.sub('{' + 'promotionTierId' + '}', CGI.escape(promotion_tier_id.to_s)) # query parameters query_params = opts[:query_params] || {} # header parameters header_params = opts[:header_params] || {} # form parameters form_params = opts[:form_params] || {} # http body (model) post_body = opts[:debug_body] # return_type return_type = opts[:debug_return_type] # auth_names auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] new_options = opts.merge( :operation => :"PromotionsApi.delete_promotion_tier", :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: PromotionsApi#delete_promotion_tier\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Disable Promotion Tier # This method disables a promotion tier, i.e. makes the active parameter false. # @param promotion_tier_id [String] Unique promotion tier ID. # @param [Hash] opts the optional parameters # @return [PromotionsTiersDisableResponseBody] def disable_promotion_tier(promotion_tier_id, opts = {}) data, _status_code, _headers = disable_promotion_tier_with_http_info(promotion_tier_id, opts) data end # Disable Promotion Tier # This method disables a promotion tier, i.e. makes the active parameter false. # @param promotion_tier_id [String] Unique promotion tier ID. # @param [Hash] opts the optional parameters # @return [Array<(PromotionsTiersDisableResponseBody, Integer, Hash)>] PromotionsTiersDisableResponseBody data, response status code and response headers private def disable_promotion_tier_with_http_info(promotion_tier_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: PromotionsApi.disable_promotion_tier ...' end # resource path local_var_path = '/v1/promotions/tiers/{promotionTierId}/disable'.sub('{' + 'promotionTierId' + '}', CGI.escape(promotion_tier_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] || 'PromotionsTiersDisableResponseBody' # auth_names auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] new_options = opts.merge( :operation => :"PromotionsApi.disable_promotion_tier", :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: PromotionsApi#disable_promotion_tier\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Enable Promotion Tier # This method enables a promotion tier, i.e. makes the active parameter true. # @param promotion_tier_id [String] Unique promotion tier ID. # @param [Hash] opts the optional parameters # @return [PromotionsTiersEnableResponseBody] def enable_promotion_tier(promotion_tier_id, opts = {}) data, _status_code, _headers = enable_promotion_tier_with_http_info(promotion_tier_id, opts) data end # Enable Promotion Tier # This method enables a promotion tier, i.e. makes the active parameter true. # @param promotion_tier_id [String] Unique promotion tier ID. # @param [Hash] opts the optional parameters # @return [Array<(PromotionsTiersEnableResponseBody, Integer, Hash)>] PromotionsTiersEnableResponseBody data, response status code and response headers private def enable_promotion_tier_with_http_info(promotion_tier_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: PromotionsApi.enable_promotion_tier ...' end # resource path local_var_path = '/v1/promotions/tiers/{promotionTierId}/enable'.sub('{' + 'promotionTierId' + '}', CGI.escape(promotion_tier_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] || 'PromotionsTiersEnableResponseBody' # auth_names auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] new_options = opts.merge( :operation => :"PromotionsApi.enable_promotion_tier", :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: PromotionsApi#enable_promotion_tier\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get Promotion Stack # This method returns the details of a promotion stack, including the promotion tiers grouped within the stack. # @param campaign_id [String] ID of the promotion campaign. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value, e.g., Loyalty Campaign. # @param stack_id [String] Promotion stack ID. # @param [Hash] opts the optional parameters # @return [PromotionsStacksGetResponseBody] def get_promotion_stack(campaign_id, stack_id, opts = {}) data, _status_code, _headers = get_promotion_stack_with_http_info(campaign_id, stack_id, opts) data end # Get Promotion Stack # This method returns the details of a promotion stack, including the promotion tiers grouped within the stack. # @param campaign_id [String] ID of the promotion campaign. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value, e.g., Loyalty Campaign. # @param stack_id [String] Promotion stack ID. # @param [Hash] opts the optional parameters # @return [Array<(PromotionsStacksGetResponseBody, Integer, Hash)>] PromotionsStacksGetResponseBody data, response status code and response headers private def get_promotion_stack_with_http_info(campaign_id, stack_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: PromotionsApi.get_promotion_stack ...' end # resource path local_var_path = '/v1/promotions/{campaignId}/stacks/{stackId}'.sub('{' + 'campaignId' + '}', CGI.escape(campaign_id.to_s)).sub('{' + 'stackId' + '}', CGI.escape(stack_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] || 'PromotionsStacksGetResponseBody' # auth_names auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] new_options = opts.merge( :operation => :"PromotionsApi.get_promotion_stack", :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: PromotionsApi#get_promotion_stack\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get Promotion Tier # This method enables you to retrieve a specific promotion tier. # @param promotion_tier_id [String] Unique promotion tier ID. # @param [Hash] opts the optional parameters # @return [PromotionsTiersGetResponseBody] def get_promotion_tier(promotion_tier_id, opts = {}) data, _status_code, _headers = get_promotion_tier_with_http_info(promotion_tier_id, opts) data end # Get Promotion Tier # This method enables you to retrieve a specific promotion tier. # @param promotion_tier_id [String] Unique promotion tier ID. # @param [Hash] opts the optional parameters # @return [Array<(PromotionsTiersGetResponseBody, Integer, Hash)>] PromotionsTiersGetResponseBody data, response status code and response headers private def get_promotion_tier_with_http_info(promotion_tier_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: PromotionsApi.get_promotion_tier ...' end # resource path local_var_path = '/v1/promotions/tiers/{promotionTierId}'.sub('{' + 'promotionTierId' + '}', CGI.escape(promotion_tier_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] || 'PromotionsTiersGetResponseBody' # auth_names auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] new_options = opts.merge( :operation => :"PromotionsApi.get_promotion_tier", :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: PromotionsApi#get_promotion_tier\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # List Promotion Stacks # This method enables you to list promotion stacks irrespective of the campaign they are associated with. You can use filters in the query parameters to specify the stacks to be returned in the response. # Advanced filters for fetching promotion stacks # @param [Hash] opts the optional parameters # @option opts [Integer] :limit Limits the number of objects to be returned. The limit can range between 1 and 100 items. # @option opts [Integer] :page Which page of results to return. The lowest value is 1. # @option opts [ParameterOrderListAllPromotionStacks] :order Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. # @option opts [ParameterCreatedBeforeAfter] :created_at 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][before] 2017-09-08T13:52:18.227Z # @option opts [ParameterUpdatedBeforeAfter] :updated_at 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][before] 2017-09-08T13:52:18.227Z # @return [PromotionsStacksListResponseBody] def list_all_promotion_stacks(opts = {}) data, _status_code, _headers = list_all_promotion_stacks_with_http_info(opts) data end # List Promotion Stacks # This method enables you to list promotion stacks irrespective of the campaign they are associated with. You can use filters in the query parameters to specify the stacks to be returned in the response. # Advanced filters for fetching promotion stacks # @param [Hash] opts the optional parameters # @option opts [Integer] :limit Limits the number of objects to be returned. The limit can range between 1 and 100 items. # @option opts [Integer] :page Which page of results to return. The lowest value is 1. # @option opts [ParameterOrderListAllPromotionStacks] :order Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. # @option opts [ParameterCreatedBeforeAfter] :created_at 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][before] 2017-09-08T13:52:18.227Z # @option opts [ParameterUpdatedBeforeAfter] :updated_at 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][before] 2017-09-08T13:52:18.227Z # @return [Array<(PromotionsStacksListResponseBody, Integer, Hash)>] PromotionsStacksListResponseBody data, response status code and response headers private def list_all_promotion_stacks_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: PromotionsApi.list_all_promotion_stacks ...' end # resource path local_var_path = '/v1/promotions/stacks' # 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[:'order'] = opts[:'order'] if !opts[:'order'].nil? query_params[:'created_at'] = opts[:'created_at'] if !opts[:'created_at'].nil? query_params[:'updated_at'] = opts[:'updated_at'] if !opts[:'updated_at'].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] || 'PromotionsStacksListResponseBody' # auth_names auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] new_options = opts.merge( :operation => :"PromotionsApi.list_all_promotion_stacks", :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: PromotionsApi#list_all_promotion_stacks\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # List Promotion Stacks in Campaign # This method enables you to list promotion stacks from a specified campaign. # @param campaign_id [String] Unique campaign ID. # @param [Hash] opts the optional parameters # @return [PromotionsStacksListResponseBody] def list_promotion_stacks_in_campaign(campaign_id, opts = {}) data, _status_code, _headers = list_promotion_stacks_in_campaign_with_http_info(campaign_id, opts) data end # List Promotion Stacks in Campaign # This method enables you to list promotion stacks from a specified campaign. # @param campaign_id [String] Unique campaign ID. # @param [Hash] opts the optional parameters # @return [Array<(PromotionsStacksListResponseBody, Integer, Hash)>] PromotionsStacksListResponseBody data, response status code and response headers private def list_promotion_stacks_in_campaign_with_http_info(campaign_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: PromotionsApi.list_promotion_stacks_in_campaign ...' end # resource path local_var_path = '/v1/promotions/{campaignId}/stacks'.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] || 'PromotionsStacksListResponseBody' # auth_names auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] new_options = opts.merge( :operation => :"PromotionsApi.list_promotion_stacks_in_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: PromotionsApi#list_promotion_stacks_in_campaign\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # List Promotion Tiers # This method enables you to list promotion tiers. # @param [Hash] opts the optional parameters # @option opts [Boolean] :is_available This parameter allows filtering promotions that are only available at the moment. When set to true, it selects only non-expired and active promotions. # @option opts [Integer] :limit Limits the number of objects to be returned. The limit can range between 1 and 100 items. # @option opts [Integer] :page Which page of results to return. The lowest value is 1. # @option opts [ParameterOrderListPromotionTiers] :order Sorts the results using one of the filtering options, where the dash - preceding a sorting option means sorting in a descending order. # @return [PromotionsTiersListResponseBody] def list_promotion_tiers(opts = {}) data, _status_code, _headers = list_promotion_tiers_with_http_info(opts) data end # List Promotion Tiers # This method enables you to list promotion tiers. # @param [Hash] opts the optional parameters # @option opts [Boolean] :is_available This parameter allows filtering promotions that are only available at the moment. When set to true, it selects only non-expired and active promotions. # @option opts [Integer] :limit Limits the number of objects to be returned. The limit can range between 1 and 100 items. # @option opts [Integer] :page Which page of results to return. The lowest value is 1. # @option opts [ParameterOrderListPromotionTiers] :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<(PromotionsTiersListResponseBody, Integer, Hash)>] PromotionsTiersListResponseBody data, response status code and response headers private def list_promotion_tiers_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: PromotionsApi.list_promotion_tiers ...' end # resource path local_var_path = '/v1/promotions/tiers' # query parameters query_params = opts[:query_params] || {} query_params[:'is_available'] = opts[:'is_available'] if !opts[:'is_available'].nil? query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil? query_params[:'page'] = opts[:'page'] if !opts[:'page'].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] || 'PromotionsTiersListResponseBody' # auth_names auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] new_options = opts.merge( :operation => :"PromotionsApi.list_promotion_tiers", :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: PromotionsApi#list_promotion_tiers\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # List Promotion Tiers from Campaign # This method enables you to list promotion tiers from a specified campaign. # @param campaign_id [String] Unique campaign ID assigned by Voucherify. # @param [Hash] opts the optional parameters # @return [PromotionsTiersListResponseBody] def list_promotion_tiers_from_campaign(campaign_id, opts = {}) data, _status_code, _headers = list_promotion_tiers_from_campaign_with_http_info(campaign_id, opts) data end # List Promotion Tiers from Campaign # This method enables you to list promotion tiers from a specified campaign. # @param campaign_id [String] Unique campaign ID assigned by Voucherify. # @param [Hash] opts the optional parameters # @return [Array<(PromotionsTiersListResponseBody, Integer, Hash)>] PromotionsTiersListResponseBody data, response status code and response headers private def list_promotion_tiers_from_campaign_with_http_info(campaign_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: PromotionsApi.list_promotion_tiers_from_campaign ...' end # resource path local_var_path = '/v1/promotions/{campaignId}/tiers'.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] || 'PromotionsTiersListResponseBody' # auth_names auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] new_options = opts.merge( :operation => :"PromotionsApi.list_promotion_tiers_from_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: PromotionsApi#list_promotion_tiers_from_campaign\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Update Promotion Stack # This methods allows for editing an existing stack. # @param campaign_id [String] ID of the promotion campaign. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value, e.g., Loyalty Campaign. # @param stack_id [String] Promotion stack ID. # @param [Hash] opts the optional parameters # @option opts [PromotionsStacksUpdateRequestBody] :promotions_stacks_update_request_body Specify the promotion stack parameters that you would like to update. # @return [PromotionsStacksUpdateResponseBody] def update_promotion_stack(campaign_id, stack_id, opts = {}) data, _status_code, _headers = update_promotion_stack_with_http_info(campaign_id, stack_id, opts) data end # Update Promotion Stack # This methods allows for editing an existing stack. # @param campaign_id [String] ID of the promotion campaign. You can either pass the campaign ID, which was assigned by Voucherify, or the name of the campaign as the path parameter value, e.g., Loyalty Campaign. # @param stack_id [String] Promotion stack ID. # @param [Hash] opts the optional parameters # @option opts [PromotionsStacksUpdateRequestBody] :promotions_stacks_update_request_body Specify the promotion stack parameters that you would like to update. # @return [Array<(PromotionsStacksUpdateResponseBody, Integer, Hash)>] PromotionsStacksUpdateResponseBody data, response status code and response headers private def update_promotion_stack_with_http_info(campaign_id, stack_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: PromotionsApi.update_promotion_stack ...' end # resource path local_var_path = '/v1/promotions/{campaignId}/stacks/{stackId}'.sub('{' + 'campaignId' + '}', CGI.escape(campaign_id.to_s)).sub('{' + 'stackId' + '}', CGI.escape(stack_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[:'promotions_stacks_update_request_body']) # return_type return_type = opts[:debug_return_type] || 'PromotionsStacksUpdateResponseBody' # auth_names auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] new_options = opts.merge( :operation => :"PromotionsApi.update_promotion_stack", :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: PromotionsApi#update_promotion_stack\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Update Promotion Tier # This method updates a promotion tier. # @param promotion_tier_id [String] Unique promotion tier ID. # @param [Hash] opts the optional parameters # @option opts [PromotionsTiersUpdateRequestBody] :promotions_tiers_update_request_body Specify the promotion tier parameters that you would like to update. # @return [PromotionsTiersUpdateResponseBody] def update_promotion_tier(promotion_tier_id, opts = {}) data, _status_code, _headers = update_promotion_tier_with_http_info(promotion_tier_id, opts) data end # Update Promotion Tier # This method updates a promotion tier. # @param promotion_tier_id [String] Unique promotion tier ID. # @param [Hash] opts the optional parameters # @option opts [PromotionsTiersUpdateRequestBody] :promotions_tiers_update_request_body Specify the promotion tier parameters that you would like to update. # @return [Array<(PromotionsTiersUpdateResponseBody, Integer, Hash)>] PromotionsTiersUpdateResponseBody data, response status code and response headers private def update_promotion_tier_with_http_info(promotion_tier_id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: PromotionsApi.update_promotion_tier ...' end # resource path local_var_path = '/v1/promotions/tiers/{promotionTierId}'.sub('{' + 'promotionTierId' + '}', CGI.escape(promotion_tier_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[:'promotions_tiers_update_request_body']) # return_type return_type = opts[:debug_return_type] || 'PromotionsTiersUpdateResponseBody' # auth_names auth_names = opts[:debug_auth_names] || ['X-App-Id', 'X-App-Token'] new_options = opts.merge( :operation => :"PromotionsApi.update_promotion_tier", :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: PromotionsApi#update_promotion_tier\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end end end