=begin #Subskribe API #No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen) OpenAPI spec version: 1.0.0 Generated by: https://github.com/swagger-api/swagger-codegen.git Swagger Codegen version: 2.4.41 =end require 'uri' module SubskribeDevClient class DiscountsApi attr_accessor :api_client def initialize(api_client = ApiClient.default) @api_client = api_client end # Create a discount # Creates a discount with the specified details. On success, the ID of the new discount is returned. # @param [Hash] opts the optional parameters # @option opts [DiscountJson] :body details of the discount # @return [String] def add_discount(opts = {}) data, _status_code, _headers = add_discount_with_http_info(opts) data end # Create a discount # Creates a discount with the specified details. On success, the ID of the new discount is returned. # @param [Hash] opts the optional parameters # @option opts [DiscountJson] :body details of the discount # @return [Array<(String, Fixnum, Hash)>] String data, response status code and response headers def add_discount_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: DiscountsApi.add_discount ...' end # resource path local_var_path = '/discounts' # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) # form parameters form_params = {} # http body (model) post_body = @api_client.object_to_http_body(opts[:'body']) auth_names = ['ApiKeyAuth'] data, status_code, headers = @api_client.call_api(:POST, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'String') if @api_client.config.debugging @api_client.config.logger.debug "API called: DiscountsApi#add_discount\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Delete a discount # Deletes a discount. Note that a discount may not be deleted if it is in use. # @param id # @param [Hash] opts the optional parameters # @return [nil] def delete_discount(id, opts = {}) delete_discount_with_http_info(id, opts) nil end # Delete a discount # Deletes a discount. Note that a discount may not be deleted if it is in use. # @param id # @param [Hash] opts the optional parameters # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def delete_discount_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: DiscountsApi.delete_discount ...' end # verify the required parameter 'id' is set if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling DiscountsApi.delete_discount" end # resource path local_var_path = '/discounts/{id}'.sub('{' + 'id' + '}', id.to_s) # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['ApiKeyAuth'] data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names) if @api_client.config.debugging @api_client.config.logger.debug "API called: DiscountsApi#delete_discount\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get discount # Returns the details of the specified discount. # @param id id of the discount # @param [Hash] opts the optional parameters # @return [DiscountJson] def get_discount(id, opts = {}) data, _status_code, _headers = get_discount_with_http_info(id, opts) data end # Get discount # Returns the details of the specified discount. # @param id id of the discount # @param [Hash] opts the optional parameters # @return [Array<(DiscountJson, Fixnum, Hash)>] DiscountJson data, response status code and response headers def get_discount_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: DiscountsApi.get_discount ...' end # verify the required parameter 'id' is set if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling DiscountsApi.get_discount" end # resource path local_var_path = '/discounts/{id}'.sub('{' + 'id' + '}', id.to_s) # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['ApiKeyAuth'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'DiscountJson') if @api_client.config.debugging @api_client.config.logger.debug "API called: DiscountsApi#get_discount\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Get discounts # Returns all discounts that have been defined # @param [Hash] opts the optional parameters # @return [Array] def get_discounts(opts = {}) data, _status_code, _headers = get_discounts_with_http_info(opts) data end # Get discounts # Returns all discounts that have been defined # @param [Hash] opts the optional parameters # @return [Array<(Array, Fixnum, Hash)>] Array data, response status code and response headers def get_discounts_with_http_info(opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: DiscountsApi.get_discounts ...' end # resource path local_var_path = '/discounts' # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['ApiKeyAuth'] data, status_code, headers = @api_client.call_api(:GET, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names, :return_type => 'Array') if @api_client.config.debugging @api_client.config.logger.debug "API called: DiscountsApi#get_discounts\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Update discount details # Updates the details of the specified discount. Note that a discount cannot be updated once it is in use by an order. # @param id id of the discount # @param [Hash] opts the optional parameters # @option opts [DiscountJson] :body # @return [nil] def update_discount(id, opts = {}) update_discount_with_http_info(id, opts) nil end # Update discount details # Updates the details of the specified discount. Note that a discount cannot be updated once it is in use by an order. # @param id id of the discount # @param [Hash] opts the optional parameters # @option opts [DiscountJson] :body # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def update_discount_with_http_info(id, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: DiscountsApi.update_discount ...' end # verify the required parameter 'id' is set if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling DiscountsApi.update_discount" end # resource path local_var_path = '/discounts/{id}'.sub('{' + 'id' + '}', id.to_s) # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) # form parameters form_params = {} # http body (model) post_body = @api_client.object_to_http_body(opts[:'body']) auth_names = ['ApiKeyAuth'] data, status_code, headers = @api_client.call_api(:PUT, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names) if @api_client.config.debugging @api_client.config.logger.debug "API called: DiscountsApi#update_discount\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end # Update discount status # Updates the status of a discount # @param id id of the discount # @param status new status to set # @param [Hash] opts the optional parameters # @return [nil] def update_discount_status(id, status, opts = {}) update_discount_status_with_http_info(id, status, opts) nil end # Update discount status # Updates the status of a discount # @param id id of the discount # @param status new status to set # @param [Hash] opts the optional parameters # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers def update_discount_status_with_http_info(id, status, opts = {}) if @api_client.config.debugging @api_client.config.logger.debug 'Calling API: DiscountsApi.update_discount_status ...' end # verify the required parameter 'id' is set if @api_client.config.client_side_validation && id.nil? fail ArgumentError, "Missing the required parameter 'id' when calling DiscountsApi.update_discount_status" end # verify the required parameter 'status' is set if @api_client.config.client_side_validation && status.nil? fail ArgumentError, "Missing the required parameter 'status' when calling DiscountsApi.update_discount_status" end # verify enum value if @api_client.config.client_side_validation && !['ACTIVE', 'DEPRECATED'].include?(status) fail ArgumentError, "invalid value for 'status', must be one of ACTIVE, DEPRECATED" end # resource path local_var_path = '/discounts/{id}/status/{status}'.sub('{' + 'id' + '}', id.to_s).sub('{' + 'status' + '}', status.to_s) # query parameters query_params = {} # header parameters header_params = {} # HTTP header 'Accept' (if needed) header_params['Accept'] = @api_client.select_header_accept(['application/json']) # HTTP header 'Content-Type' header_params['Content-Type'] = @api_client.select_header_content_type(['application/json']) # form parameters form_params = {} # http body (model) post_body = nil auth_names = ['ApiKeyAuth'] data, status_code, headers = @api_client.call_api(:PUT, local_var_path, :header_params => header_params, :query_params => query_params, :form_params => form_params, :body => post_body, :auth_names => auth_names) if @api_client.config.debugging @api_client.config.logger.debug "API called: DiscountsApi#update_discount_status\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" end return data, status_code, headers end end end