=begin
#UltraCart Rest API V2

#UltraCart REST API Version 2

OpenAPI spec version: 2.0.0
Contact: support@ultracart.com
Generated by: https://github.com/swagger-api/swagger-codegen.git
Swagger Codegen version: 2.4.15-SNAPSHOT

=end

require 'uri'

module UltracartClient
  class OrderApi
    attr_accessor :api_client

    def initialize(api_client = ApiClient.default)
      @api_client = api_client
    end

    def self.new_using_api_key(simple_key, verify_ssl = true, debugging = false)
      api_config = Configuration.new
      api_config.api_key_prefix['x-ultracart-simple-key'] = simple_key
      api_config.api_version = '2017-03-01'
      api_config.verify_ssl = verify_ssl

      api_client = ApiClient.new(api_config)
      api_client.config.debugging = debugging

      UltracartClient::OrderApi.new(api_client)
    end

    # Adjusts an order total
    # Adjusts an order total.  Adjusts individual items appropriately and considers taxes.  Desired total should be provided in the same currency as the order and must be less than the current total and greater than zero.  This call will change the order total.  It returns true if the desired total is achieved.  If the goal seeking algorithm falls short (usually by pennies), this method returns back false.  View the merchant notes for the order for further details. 
    # @param order_id The order id to cancel.
    # @param desired_total The desired total with no formatting. example 123.45
    # @param [Hash] opts the optional parameters
    # @return [BaseResponse]
    def adjust_order_total(order_id, desired_total, opts = {})
      data, _status_code, _headers = adjust_order_total_with_http_info(order_id, desired_total, opts)
      data
    end

    # Adjusts an order total
    # Adjusts an order total.  Adjusts individual items appropriately and considers taxes.  Desired total should be provided in the same currency as the order and must be less than the current total and greater than zero.  This call will change the order total.  It returns true if the desired total is achieved.  If the goal seeking algorithm falls short (usually by pennies), this method returns back false.  View the merchant notes for the order for further details. 
    # @param order_id The order id to cancel.
    # @param desired_total The desired total with no formatting. example 123.45
    # @param [Hash] opts the optional parameters
    # @return [Array<(BaseResponse, Fixnum, Hash)>] BaseResponse data, response status code and response headers
    def adjust_order_total_with_http_info(order_id, desired_total, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: OrderApi.adjust_order_total ...'
      end
      # verify the required parameter 'order_id' is set
      if @api_client.config.client_side_validation && order_id.nil?
        fail ArgumentError, "Missing the required parameter 'order_id' when calling OrderApi.adjust_order_total"
      end
      # verify the required parameter 'desired_total' is set
      if @api_client.config.client_side_validation && desired_total.nil?
        fail ArgumentError, "Missing the required parameter 'desired_total' when calling OrderApi.adjust_order_total"
      end
      # resource path
      local_var_path = '/order/orders/{order_id}/adjust_order_total/{desired_total}'.sub('{' + 'order_id' + '}', order_id.to_s).sub('{' + 'desired_total' + '}', desired_total.to_s)

      # query parameters
      query_params = {}

      # header parameters
      header_params = {}
      header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
      # 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 = ['ultraCartOauth', 'ultraCartSimpleApiKey']
      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 => 'BaseResponse')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: OrderApi#adjust_order_total\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end
    # Cancel an order
    # Cancel an order on the UltraCart account.  If the success flag is false, then consult the error message for why it failed. 
    # @param order_id The order id to cancel.
    # @param [Hash] opts the optional parameters
    # @return [BaseResponse]
    def cancel_order(order_id, opts = {})
      data, _status_code, _headers = cancel_order_with_http_info(order_id, opts)
      data
    end

    # Cancel an order
    # Cancel an order on the UltraCart account.  If the success flag is false, then consult the error message for why it failed. 
    # @param order_id The order id to cancel.
    # @param [Hash] opts the optional parameters
    # @return [Array<(BaseResponse, Fixnum, Hash)>] BaseResponse data, response status code and response headers
    def cancel_order_with_http_info(order_id, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: OrderApi.cancel_order ...'
      end
      # verify the required parameter 'order_id' is set
      if @api_client.config.client_side_validation && order_id.nil?
        fail ArgumentError, "Missing the required parameter 'order_id' when calling OrderApi.cancel_order"
      end
      # resource path
      local_var_path = '/order/orders/{order_id}/cancel'.sub('{' + 'order_id' + '}', order_id.to_s)

      # query parameters
      query_params = {}

      # header parameters
      header_params = {}
      header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
      # 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 = ['ultraCartOauth', 'ultraCartSimpleApiKey']
      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 => 'BaseResponse')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: OrderApi#cancel_order\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end
    # Delete an order
    # Delete an order on the UltraCart account. 
    # @param order_id The order id to delete.
    # @param [Hash] opts the optional parameters
    # @return [nil]
    def delete_order(order_id, opts = {})
      delete_order_with_http_info(order_id, opts)
      nil
    end

    # Delete an order
    # Delete an order on the UltraCart account. 
    # @param order_id The order id to delete.
    # @param [Hash] opts the optional parameters
    # @return [Array<(nil, Fixnum, Hash)>] nil, response status code and response headers
    def delete_order_with_http_info(order_id, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: OrderApi.delete_order ...'
      end
      # verify the required parameter 'order_id' is set
      if @api_client.config.client_side_validation && order_id.nil?
        fail ArgumentError, "Missing the required parameter 'order_id' when calling OrderApi.delete_order"
      end
      # resource path
      local_var_path = '/order/orders/{order_id}'.sub('{' + 'order_id' + '}', order_id.to_s)

      # query parameters
      query_params = {}

      # header parameters
      header_params = {}
      header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
      # 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 = ['ultraCartOauth', 'ultraCartSimpleApiKey']
      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: OrderApi#delete_order\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end
    # Format order
    # Format the order for display at text or html 
    # @param order_id The order id to format
    # @param format_options Format options
    # @param [Hash] opts the optional parameters
    # @return [OrderFormatResponse]
    def format(order_id, format_options, opts = {})
      data, _status_code, _headers = format_with_http_info(order_id, format_options, opts)
      data
    end

    # Format order
    # Format the order for display at text or html 
    # @param order_id The order id to format
    # @param format_options Format options
    # @param [Hash] opts the optional parameters
    # @return [Array<(OrderFormatResponse, Fixnum, Hash)>] OrderFormatResponse data, response status code and response headers
    def format_with_http_info(order_id, format_options, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: OrderApi.format ...'
      end
      # verify the required parameter 'order_id' is set
      if @api_client.config.client_side_validation && order_id.nil?
        fail ArgumentError, "Missing the required parameter 'order_id' when calling OrderApi.format"
      end
      # verify the required parameter 'format_options' is set
      if @api_client.config.client_side_validation && format_options.nil?
        fail ArgumentError, "Missing the required parameter 'format_options' when calling OrderApi.format"
      end
      # resource path
      local_var_path = '/order/orders/{order_id}/format'.sub('{' + 'order_id' + '}', order_id.to_s)

      # query parameters
      query_params = {}

      # header parameters
      header_params = {}
      header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
      # 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(format_options)
      auth_names = ['ultraCartOauth', 'ultraCartSimpleApiKey']
      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 => 'OrderFormatResponse')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: OrderApi#format\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end
    # Generate an order token for a given order id
    # Retrieves a single order token for a given order id.  The token can be used with the getOrderByToken API. 
    # @param order_id The order id to generate a token for.
    # @param [Hash] opts the optional parameters
    # @return [OrderTokenResponse]
    def generate_order_token(order_id, opts = {})
      data, _status_code, _headers = generate_order_token_with_http_info(order_id, opts)
      data
    end

    # Generate an order token for a given order id
    # Retrieves a single order token for a given order id.  The token can be used with the getOrderByToken API. 
    # @param order_id The order id to generate a token for.
    # @param [Hash] opts the optional parameters
    # @return [Array<(OrderTokenResponse, Fixnum, Hash)>] OrderTokenResponse data, response status code and response headers
    def generate_order_token_with_http_info(order_id, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: OrderApi.generate_order_token ...'
      end
      # verify the required parameter 'order_id' is set
      if @api_client.config.client_side_validation && order_id.nil?
        fail ArgumentError, "Missing the required parameter 'order_id' when calling OrderApi.generate_order_token"
      end
      # resource path
      local_var_path = '/order/orders/token/{order_id}'.sub('{' + 'order_id' + '}', order_id.to_s)

      # query parameters
      query_params = {}

      # header parameters
      header_params = {}
      header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
      # 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 = ['ultraCartOauth', 'ultraCartSimpleApiKey']
      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 => 'OrderTokenResponse')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: OrderApi#generate_order_token\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end
    # Generate a packing slip for this order across all distribution centers.
    # The packing slip PDF that is returned is base 64 encoded 
    # @param order_id Order ID
    # @param [Hash] opts the optional parameters
    # @return [OrdersResponse]
    def generate_packing_slip_all_dc(order_id, opts = {})
      data, _status_code, _headers = generate_packing_slip_all_dc_with_http_info(order_id, opts)
      data
    end

    # Generate a packing slip for this order across all distribution centers.
    # The packing slip PDF that is returned is base 64 encoded 
    # @param order_id Order ID
    # @param [Hash] opts the optional parameters
    # @return [Array<(OrdersResponse, Fixnum, Hash)>] OrdersResponse data, response status code and response headers
    def generate_packing_slip_all_dc_with_http_info(order_id, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: OrderApi.generate_packing_slip_all_dc ...'
      end
      # verify the required parameter 'order_id' is set
      if @api_client.config.client_side_validation && order_id.nil?
        fail ArgumentError, "Missing the required parameter 'order_id' when calling OrderApi.generate_packing_slip_all_dc"
      end
      # resource path
      local_var_path = '/order/orders/{order_id}/packing_slip'.sub('{' + 'order_id' + '}', order_id.to_s)

      # query parameters
      query_params = {}

      # header parameters
      header_params = {}
      header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
      # 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 = ['ultraCartOauth', 'ultraCartSimpleApiKey']
      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 => 'OrdersResponse')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: OrderApi#generate_packing_slip_all_dc\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end
    # Generate a packing slip for this order for the given distribution center.
    # The packing slip PDF that is returned is base 64 encoded 
    # @param distribution_center_code Distribution center code
    # @param order_id Order ID
    # @param [Hash] opts the optional parameters
    # @return [OrdersResponse]
    def generate_packing_slip_specific_dc(distribution_center_code, order_id, opts = {})
      data, _status_code, _headers = generate_packing_slip_specific_dc_with_http_info(distribution_center_code, order_id, opts)
      data
    end

    # Generate a packing slip for this order for the given distribution center.
    # The packing slip PDF that is returned is base 64 encoded 
    # @param distribution_center_code Distribution center code
    # @param order_id Order ID
    # @param [Hash] opts the optional parameters
    # @return [Array<(OrdersResponse, Fixnum, Hash)>] OrdersResponse data, response status code and response headers
    def generate_packing_slip_specific_dc_with_http_info(distribution_center_code, order_id, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: OrderApi.generate_packing_slip_specific_dc ...'
      end
      # verify the required parameter 'distribution_center_code' is set
      if @api_client.config.client_side_validation && distribution_center_code.nil?
        fail ArgumentError, "Missing the required parameter 'distribution_center_code' when calling OrderApi.generate_packing_slip_specific_dc"
      end
      # verify the required parameter 'order_id' is set
      if @api_client.config.client_side_validation && order_id.nil?
        fail ArgumentError, "Missing the required parameter 'order_id' when calling OrderApi.generate_packing_slip_specific_dc"
      end
      # resource path
      local_var_path = '/order/orders/{order_id}/packing_slip/{distribution_center_code}'.sub('{' + 'distribution_center_code' + '}', distribution_center_code.to_s).sub('{' + 'order_id' + '}', order_id.to_s)

      # query parameters
      query_params = {}

      # header parameters
      header_params = {}
      header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
      # 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 = ['ultraCartOauth', 'ultraCartSimpleApiKey']
      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 => 'OrdersResponse')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: OrderApi#generate_packing_slip_specific_dc\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end
    # Retrieve A/R Retry Configuration
    # Retrieve A/R Retry Configuration. This is primarily an internal API call.  It is doubtful you would ever need to use it. 
    # @param [Hash] opts the optional parameters
    # @return [AccountsReceivableRetryConfigResponse]
    def get_accounts_receivable_retry_config(opts = {})
      data, _status_code, _headers = get_accounts_receivable_retry_config_with_http_info(opts)
      data
    end

    # Retrieve A/R Retry Configuration
    # Retrieve A/R Retry Configuration. This is primarily an internal API call.  It is doubtful you would ever need to use it. 
    # @param [Hash] opts the optional parameters
    # @return [Array<(AccountsReceivableRetryConfigResponse, Fixnum, Hash)>] AccountsReceivableRetryConfigResponse data, response status code and response headers
    def get_accounts_receivable_retry_config_with_http_info(opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: OrderApi.get_accounts_receivable_retry_config ...'
      end
      # resource path
      local_var_path = '/order/accountsReceivableRetryConfig'

      # query parameters
      query_params = {}

      # header parameters
      header_params = {}
      header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
      # 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 = ['ultraCartOauth', 'ultraCartSimpleApiKey']
      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 => 'AccountsReceivableRetryConfigResponse')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: OrderApi#get_accounts_receivable_retry_config\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end
    # Retrieve A/R Retry Statistics
    # Retrieve A/R Retry Statistics. This is primarily an internal API call.  It is doubtful you would ever need to use it. 
    # @param [Hash] opts the optional parameters
    # @option opts [String] :from 
    # @option opts [String] :to 
    # @return [AccountsReceivableRetryStatsResponse]
    def get_accounts_receivable_retry_stats(opts = {})
      data, _status_code, _headers = get_accounts_receivable_retry_stats_with_http_info(opts)
      data
    end

    # Retrieve A/R Retry Statistics
    # Retrieve A/R Retry Statistics. This is primarily an internal API call.  It is doubtful you would ever need to use it. 
    # @param [Hash] opts the optional parameters
    # @option opts [String] :from 
    # @option opts [String] :to 
    # @return [Array<(AccountsReceivableRetryStatsResponse, Fixnum, Hash)>] AccountsReceivableRetryStatsResponse data, response status code and response headers
    def get_accounts_receivable_retry_stats_with_http_info(opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: OrderApi.get_accounts_receivable_retry_stats ...'
      end
      # resource path
      local_var_path = '/order/accountsReceivableRetryConfig/stats'

      # query parameters
      query_params = {}
      query_params[:'from'] = opts[:'from'] if !opts[:'from'].nil?
      query_params[:'to'] = opts[:'to'] if !opts[:'to'].nil?

      # header parameters
      header_params = {}
      header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
      # 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 = ['ultraCartOauth', 'ultraCartSimpleApiKey']
      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 => 'AccountsReceivableRetryStatsResponse')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: OrderApi#get_accounts_receivable_retry_stats\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end
    # Retrieve an order
    # Retrieves a single order using the specified order id. 
    # @param order_id The order id to retrieve.
    # @param [Hash] opts the optional parameters
    # @option opts [String] :_expand The object expansion to perform on the result.  See documentation for examples
    # @return [OrderResponse]
    def get_order(order_id, opts = {})
      data, _status_code, _headers = get_order_with_http_info(order_id, opts)
      data
    end

    # Retrieve an order
    # Retrieves a single order using the specified order id. 
    # @param order_id The order id to retrieve.
    # @param [Hash] opts the optional parameters
    # @option opts [String] :_expand The object expansion to perform on the result.  See documentation for examples
    # @return [Array<(OrderResponse, Fixnum, Hash)>] OrderResponse data, response status code and response headers
    def get_order_with_http_info(order_id, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: OrderApi.get_order ...'
      end
      # verify the required parameter 'order_id' is set
      if @api_client.config.client_side_validation && order_id.nil?
        fail ArgumentError, "Missing the required parameter 'order_id' when calling OrderApi.get_order"
      end
      # resource path
      local_var_path = '/order/orders/{order_id}'.sub('{' + 'order_id' + '}', order_id.to_s)

      # query parameters
      query_params = {}
      query_params[:'_expand'] = opts[:'_expand'] if !opts[:'_expand'].nil?

      # header parameters
      header_params = {}
      header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
      # 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 = ['ultraCartOauth', 'ultraCartSimpleApiKey']
      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 => 'OrderResponse')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: OrderApi#get_order\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end
    # Retrieve an order using a token
    # Retrieves a single order using the specified order token. 
    # @param order_by_token_query Order by token query
    # @param [Hash] opts the optional parameters
    # @option opts [String] :_expand The object expansion to perform on the result.  See documentation for examples
    # @return [OrderResponse]
    def get_order_by_token(order_by_token_query, opts = {})
      data, _status_code, _headers = get_order_by_token_with_http_info(order_by_token_query, opts)
      data
    end

    # Retrieve an order using a token
    # Retrieves a single order using the specified order token. 
    # @param order_by_token_query Order by token query
    # @param [Hash] opts the optional parameters
    # @option opts [String] :_expand The object expansion to perform on the result.  See documentation for examples
    # @return [Array<(OrderResponse, Fixnum, Hash)>] OrderResponse data, response status code and response headers
    def get_order_by_token_with_http_info(order_by_token_query, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: OrderApi.get_order_by_token ...'
      end
      # verify the required parameter 'order_by_token_query' is set
      if @api_client.config.client_side_validation && order_by_token_query.nil?
        fail ArgumentError, "Missing the required parameter 'order_by_token_query' when calling OrderApi.get_order_by_token"
      end
      # resource path
      local_var_path = '/order/orders/token'

      # query parameters
      query_params = {}
      query_params[:'_expand'] = opts[:'_expand'] if !opts[:'_expand'].nil?

      # header parameters
      header_params = {}
      header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
      # 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(order_by_token_query)
      auth_names = ['ultraCartOauth', 'ultraCartSimpleApiKey']
      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 => 'OrderResponse')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: OrderApi#get_order_by_token\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end
    # Retrieve orders
    # Retrieves a group of orders from the account.  If no parameters are specified, the API call will fail with a bad request error.  Always specify some parameters to limit the scope of the orders returned to ones you are truly interested in.  You will need to make multiple API calls in order to retrieve the entire result set since this API performs result set pagination. 
    # @param [Hash] opts the optional parameters
    # @option opts [String] :order_id Order Id
    # @option opts [String] :payment_method Payment Method
    # @option opts [String] :company Company
    # @option opts [String] :first_name First Name
    # @option opts [String] :last_name Last Name
    # @option opts [String] :city City
    # @option opts [String] :state_region State/Region
    # @option opts [String] :postal_code Postal Code
    # @option opts [String] :country_code Country Code (ISO-3166 two letter)
    # @option opts [String] :phone Phone
    # @option opts [String] :email Email
    # @option opts [String] :cc_email CC Email
    # @option opts [Float] :total Total
    # @option opts [String] :screen_branding_theme_code Screen Branding Theme Code
    # @option opts [String] :storefront_host_name StoreFront Host Name
    # @option opts [String] :creation_date_begin Creation Date Begin
    # @option opts [String] :creation_date_end Creation Date End
    # @option opts [String] :payment_date_begin Payment Date Begin
    # @option opts [String] :payment_date_end Payment Date End
    # @option opts [String] :shipment_date_begin Shipment Date Begin
    # @option opts [String] :shipment_date_end Shipment Date End
    # @option opts [String] :rma RMA
    # @option opts [String] :purchase_order_number Purchase Order Number
    # @option opts [String] :item_id Item Id
    # @option opts [String] :current_stage Current Stage
    # @option opts [String] :channel_partner_code Channel Partner Code
    # @option opts [String] :channel_partner_order_id Channel Partner Order ID
    # @option opts [Integer] :customer_profile_oid 
    # @option opts [String] :refund_date_begin 
    # @option opts [String] :refund_date_end 
    # @option opts [String] :custom_field_1 
    # @option opts [String] :custom_field_2 
    # @option opts [String] :custom_field_3 
    # @option opts [String] :custom_field_4 
    # @option opts [String] :custom_field_5 
    # @option opts [String] :custom_field_6 
    # @option opts [String] :custom_field_7 
    # @option opts [String] :ship_on_date_begin 
    # @option opts [String] :ship_on_date_end 
    # @option opts [Integer] :_limit The maximum number of records to return on this one API call. (Maximum 200) (default to 100)
    # @option opts [Integer] :_offset Pagination of the record set.  Offset is a zero based index. (default to 0)
    # @option opts [String] :_sort The sort order of the orders.  See Sorting documentation for examples of using multiple values and sorting by ascending and descending.
    # @option opts [String] :_expand The object expansion to perform on the result.
    # @return [OrdersResponse]
    def get_orders(opts = {})
      data, _status_code, _headers = get_orders_with_http_info(opts)
      data
    end

    # Retrieve orders
    # Retrieves a group of orders from the account.  If no parameters are specified, the API call will fail with a bad request error.  Always specify some parameters to limit the scope of the orders returned to ones you are truly interested in.  You will need to make multiple API calls in order to retrieve the entire result set since this API performs result set pagination. 
    # @param [Hash] opts the optional parameters
    # @option opts [String] :order_id Order Id
    # @option opts [String] :payment_method Payment Method
    # @option opts [String] :company Company
    # @option opts [String] :first_name First Name
    # @option opts [String] :last_name Last Name
    # @option opts [String] :city City
    # @option opts [String] :state_region State/Region
    # @option opts [String] :postal_code Postal Code
    # @option opts [String] :country_code Country Code (ISO-3166 two letter)
    # @option opts [String] :phone Phone
    # @option opts [String] :email Email
    # @option opts [String] :cc_email CC Email
    # @option opts [Float] :total Total
    # @option opts [String] :screen_branding_theme_code Screen Branding Theme Code
    # @option opts [String] :storefront_host_name StoreFront Host Name
    # @option opts [String] :creation_date_begin Creation Date Begin
    # @option opts [String] :creation_date_end Creation Date End
    # @option opts [String] :payment_date_begin Payment Date Begin
    # @option opts [String] :payment_date_end Payment Date End
    # @option opts [String] :shipment_date_begin Shipment Date Begin
    # @option opts [String] :shipment_date_end Shipment Date End
    # @option opts [String] :rma RMA
    # @option opts [String] :purchase_order_number Purchase Order Number
    # @option opts [String] :item_id Item Id
    # @option opts [String] :current_stage Current Stage
    # @option opts [String] :channel_partner_code Channel Partner Code
    # @option opts [String] :channel_partner_order_id Channel Partner Order ID
    # @option opts [Integer] :customer_profile_oid 
    # @option opts [String] :refund_date_begin 
    # @option opts [String] :refund_date_end 
    # @option opts [String] :custom_field_1 
    # @option opts [String] :custom_field_2 
    # @option opts [String] :custom_field_3 
    # @option opts [String] :custom_field_4 
    # @option opts [String] :custom_field_5 
    # @option opts [String] :custom_field_6 
    # @option opts [String] :custom_field_7 
    # @option opts [String] :ship_on_date_begin 
    # @option opts [String] :ship_on_date_end 
    # @option opts [Integer] :_limit The maximum number of records to return on this one API call. (Maximum 200)
    # @option opts [Integer] :_offset Pagination of the record set.  Offset is a zero based index.
    # @option opts [String] :_sort The sort order of the orders.  See Sorting documentation for examples of using multiple values and sorting by ascending and descending.
    # @option opts [String] :_expand The object expansion to perform on the result.
    # @return [Array<(OrdersResponse, Fixnum, Hash)>] OrdersResponse data, response status code and response headers
    def get_orders_with_http_info(opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: OrderApi.get_orders ...'
      end
      # resource path
      local_var_path = '/order/orders'

      # query parameters
      query_params = {}
      query_params[:'order_id'] = opts[:'order_id'] if !opts[:'order_id'].nil?
      query_params[:'payment_method'] = opts[:'payment_method'] if !opts[:'payment_method'].nil?
      query_params[:'company'] = opts[:'company'] if !opts[:'company'].nil?
      query_params[:'first_name'] = opts[:'first_name'] if !opts[:'first_name'].nil?
      query_params[:'last_name'] = opts[:'last_name'] if !opts[:'last_name'].nil?
      query_params[:'city'] = opts[:'city'] if !opts[:'city'].nil?
      query_params[:'state_region'] = opts[:'state_region'] if !opts[:'state_region'].nil?
      query_params[:'postal_code'] = opts[:'postal_code'] if !opts[:'postal_code'].nil?
      query_params[:'country_code'] = opts[:'country_code'] if !opts[:'country_code'].nil?
      query_params[:'phone'] = opts[:'phone'] if !opts[:'phone'].nil?
      query_params[:'email'] = opts[:'email'] if !opts[:'email'].nil?
      query_params[:'cc_email'] = opts[:'cc_email'] if !opts[:'cc_email'].nil?
      query_params[:'total'] = opts[:'total'] if !opts[:'total'].nil?
      query_params[:'screen_branding_theme_code'] = opts[:'screen_branding_theme_code'] if !opts[:'screen_branding_theme_code'].nil?
      query_params[:'storefront_host_name'] = opts[:'storefront_host_name'] if !opts[:'storefront_host_name'].nil?
      query_params[:'creation_date_begin'] = opts[:'creation_date_begin'] if !opts[:'creation_date_begin'].nil?
      query_params[:'creation_date_end'] = opts[:'creation_date_end'] if !opts[:'creation_date_end'].nil?
      query_params[:'payment_date_begin'] = opts[:'payment_date_begin'] if !opts[:'payment_date_begin'].nil?
      query_params[:'payment_date_end'] = opts[:'payment_date_end'] if !opts[:'payment_date_end'].nil?
      query_params[:'shipment_date_begin'] = opts[:'shipment_date_begin'] if !opts[:'shipment_date_begin'].nil?
      query_params[:'shipment_date_end'] = opts[:'shipment_date_end'] if !opts[:'shipment_date_end'].nil?
      query_params[:'rma'] = opts[:'rma'] if !opts[:'rma'].nil?
      query_params[:'purchase_order_number'] = opts[:'purchase_order_number'] if !opts[:'purchase_order_number'].nil?
      query_params[:'item_id'] = opts[:'item_id'] if !opts[:'item_id'].nil?
      query_params[:'current_stage'] = opts[:'current_stage'] if !opts[:'current_stage'].nil?
      query_params[:'channel_partner_code'] = opts[:'channel_partner_code'] if !opts[:'channel_partner_code'].nil?
      query_params[:'channel_partner_order_id'] = opts[:'channel_partner_order_id'] if !opts[:'channel_partner_order_id'].nil?
      query_params[:'customer_profile_oid'] = opts[:'customer_profile_oid'] if !opts[:'customer_profile_oid'].nil?
      query_params[:'Refund Date Begin'] = opts[:'refund_date_begin'] if !opts[:'refund_date_begin'].nil?
      query_params[:'Refund Date End'] = opts[:'refund_date_end'] if !opts[:'refund_date_end'].nil?
      query_params[:'Custom Field 1'] = opts[:'custom_field_1'] if !opts[:'custom_field_1'].nil?
      query_params[:'Custom Field 2'] = opts[:'custom_field_2'] if !opts[:'custom_field_2'].nil?
      query_params[:'Custom Field 3'] = opts[:'custom_field_3'] if !opts[:'custom_field_3'].nil?
      query_params[:'Custom Field 4'] = opts[:'custom_field_4'] if !opts[:'custom_field_4'].nil?
      query_params[:'Custom Field 5'] = opts[:'custom_field_5'] if !opts[:'custom_field_5'].nil?
      query_params[:'Custom Field 6'] = opts[:'custom_field_6'] if !opts[:'custom_field_6'].nil?
      query_params[:'Custom Field 7'] = opts[:'custom_field_7'] if !opts[:'custom_field_7'].nil?
      query_params[:'ship_on_date_begin'] = opts[:'ship_on_date_begin'] if !opts[:'ship_on_date_begin'].nil?
      query_params[:'ship_on_date_end'] = opts[:'ship_on_date_end'] if !opts[:'ship_on_date_end'].nil?
      query_params[:'_limit'] = opts[:'_limit'] if !opts[:'_limit'].nil?
      query_params[:'_offset'] = opts[:'_offset'] if !opts[:'_offset'].nil?
      query_params[:'_sort'] = opts[:'_sort'] if !opts[:'_sort'].nil?
      query_params[:'_expand'] = opts[:'_expand'] if !opts[:'_expand'].nil?

      # header parameters
      header_params = {}
      header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
      # 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 = ['ultraCartOauth', 'ultraCartSimpleApiKey']
      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 => 'OrdersResponse')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: OrderApi#get_orders\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end
    # Retrieve order batch
    # Retrieves a group of orders from the account based on an array of order ids.  If more than 500 order ids are specified, the API call will fail with a bad request error. 
    # @param order_batch Order batch
    # @param [Hash] opts the optional parameters
    # @option opts [String] :_expand The object expansion to perform on the result.
    # @return [OrdersResponse]
    def get_orders_batch(order_batch, opts = {})
      data, _status_code, _headers = get_orders_batch_with_http_info(order_batch, opts)
      data
    end

    # Retrieve order batch
    # Retrieves a group of orders from the account based on an array of order ids.  If more than 500 order ids are specified, the API call will fail with a bad request error. 
    # @param order_batch Order batch
    # @param [Hash] opts the optional parameters
    # @option opts [String] :_expand The object expansion to perform on the result.
    # @return [Array<(OrdersResponse, Fixnum, Hash)>] OrdersResponse data, response status code and response headers
    def get_orders_batch_with_http_info(order_batch, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: OrderApi.get_orders_batch ...'
      end
      # verify the required parameter 'order_batch' is set
      if @api_client.config.client_side_validation && order_batch.nil?
        fail ArgumentError, "Missing the required parameter 'order_batch' when calling OrderApi.get_orders_batch"
      end
      # resource path
      local_var_path = '/order/orders/batch'

      # query parameters
      query_params = {}
      query_params[:'_expand'] = opts[:'_expand'] if !opts[:'_expand'].nil?

      # header parameters
      header_params = {}
      header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
      # 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(order_batch)
      auth_names = ['ultraCartOauth', 'ultraCartSimpleApiKey']
      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 => 'OrdersResponse')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: OrderApi#get_orders_batch\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end
    # Retrieve orders by query
    # Retrieves a group of orders from the account based on a query object.  If no parameters are specified, the API call will fail with a bad request error.  Always specify some parameters to limit the scope of the orders returned to ones you are truly interested in.  You will need to make multiple API calls in order to retrieve the entire result set since this API performs result set pagination. 
    # @param order_query Order query
    # @param [Hash] opts the optional parameters
    # @option opts [Integer] :_limit The maximum number of records to return on this one API call. (Maximum 200) (default to 100)
    # @option opts [Integer] :_offset Pagination of the record set.  Offset is a zero based index. (default to 0)
    # @option opts [String] :_sort The sort order of the orders.  See Sorting documentation for examples of using multiple values and sorting by ascending and descending.
    # @option opts [String] :_expand The object expansion to perform on the result.
    # @return [OrdersResponse]
    def get_orders_by_query(order_query, opts = {})
      data, _status_code, _headers = get_orders_by_query_with_http_info(order_query, opts)
      data
    end

    # Retrieve orders by query
    # Retrieves a group of orders from the account based on a query object.  If no parameters are specified, the API call will fail with a bad request error.  Always specify some parameters to limit the scope of the orders returned to ones you are truly interested in.  You will need to make multiple API calls in order to retrieve the entire result set since this API performs result set pagination. 
    # @param order_query Order query
    # @param [Hash] opts the optional parameters
    # @option opts [Integer] :_limit The maximum number of records to return on this one API call. (Maximum 200)
    # @option opts [Integer] :_offset Pagination of the record set.  Offset is a zero based index.
    # @option opts [String] :_sort The sort order of the orders.  See Sorting documentation for examples of using multiple values and sorting by ascending and descending.
    # @option opts [String] :_expand The object expansion to perform on the result.
    # @return [Array<(OrdersResponse, Fixnum, Hash)>] OrdersResponse data, response status code and response headers
    def get_orders_by_query_with_http_info(order_query, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: OrderApi.get_orders_by_query ...'
      end
      # verify the required parameter 'order_query' is set
      if @api_client.config.client_side_validation && order_query.nil?
        fail ArgumentError, "Missing the required parameter 'order_query' when calling OrderApi.get_orders_by_query"
      end
      # resource path
      local_var_path = '/order/orders/query'

      # query parameters
      query_params = {}
      query_params[:'_limit'] = opts[:'_limit'] if !opts[:'_limit'].nil?
      query_params[:'_offset'] = opts[:'_offset'] if !opts[:'_offset'].nil?
      query_params[:'_sort'] = opts[:'_sort'] if !opts[:'_sort'].nil?
      query_params[:'_expand'] = opts[:'_expand'] if !opts[:'_expand'].nil?

      # header parameters
      header_params = {}
      header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
      # 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(order_query)
      auth_names = ['ultraCartOauth', 'ultraCartSimpleApiKey']
      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 => 'OrdersResponse')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: OrderApi#get_orders_by_query\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end
    # Insert an order
    # Inserts a new order on the UltraCart account.  This is probably NOT the method you want.  This is for channel orders.  For regular orders the customer is entering, use the CheckoutApi.  It has many, many more features, checks, and validations. 
    # @param order Order to insert
    # @param [Hash] opts the optional parameters
    # @option opts [String] :_expand The object expansion to perform on the result.  See documentation for examples
    # @return [OrderResponse]
    def insert_order(order, opts = {})
      data, _status_code, _headers = insert_order_with_http_info(order, opts)
      data
    end

    # Insert an order
    # Inserts a new order on the UltraCart account.  This is probably NOT the method you want.  This is for channel orders.  For regular orders the customer is entering, use the CheckoutApi.  It has many, many more features, checks, and validations. 
    # @param order Order to insert
    # @param [Hash] opts the optional parameters
    # @option opts [String] :_expand The object expansion to perform on the result.  See documentation for examples
    # @return [Array<(OrderResponse, Fixnum, Hash)>] OrderResponse data, response status code and response headers
    def insert_order_with_http_info(order, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: OrderApi.insert_order ...'
      end
      # verify the required parameter 'order' is set
      if @api_client.config.client_side_validation && order.nil?
        fail ArgumentError, "Missing the required parameter 'order' when calling OrderApi.insert_order"
      end
      # resource path
      local_var_path = '/order/orders'

      # query parameters
      query_params = {}
      query_params[:'_expand'] = opts[:'_expand'] if !opts[:'_expand'].nil?

      # header parameters
      header_params = {}
      header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
      # 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; charset=UTF-8'])

      # form parameters
      form_params = {}

      # http body (model)
      post_body = @api_client.object_to_http_body(order)
      auth_names = ['ultraCartOauth', 'ultraCartSimpleApiKey']
      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 => 'OrderResponse')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: OrderApi#insert_order\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end
    # Process payment
    # Process payment on order 
    # @param order_id The order id to process payment on
    # @param process_payment_request Process payment parameters
    # @param [Hash] opts the optional parameters
    # @return [OrderProcessPaymentResponse]
    def process_payment(order_id, process_payment_request, opts = {})
      data, _status_code, _headers = process_payment_with_http_info(order_id, process_payment_request, opts)
      data
    end

    # Process payment
    # Process payment on order 
    # @param order_id The order id to process payment on
    # @param process_payment_request Process payment parameters
    # @param [Hash] opts the optional parameters
    # @return [Array<(OrderProcessPaymentResponse, Fixnum, Hash)>] OrderProcessPaymentResponse data, response status code and response headers
    def process_payment_with_http_info(order_id, process_payment_request, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: OrderApi.process_payment ...'
      end
      # verify the required parameter 'order_id' is set
      if @api_client.config.client_side_validation && order_id.nil?
        fail ArgumentError, "Missing the required parameter 'order_id' when calling OrderApi.process_payment"
      end
      # verify the required parameter 'process_payment_request' is set
      if @api_client.config.client_side_validation && process_payment_request.nil?
        fail ArgumentError, "Missing the required parameter 'process_payment_request' when calling OrderApi.process_payment"
      end
      # resource path
      local_var_path = '/order/orders/{order_id}/process_payment'.sub('{' + 'order_id' + '}', order_id.to_s)

      # query parameters
      query_params = {}

      # header parameters
      header_params = {}
      header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
      # 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(process_payment_request)
      auth_names = ['ultraCartOauth', 'ultraCartSimpleApiKey']
      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 => 'OrderProcessPaymentResponse')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: OrderApi#process_payment\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end
    # Refund an order
    # Perform a refund operation on an order and then update the order if successful 
    # @param order Order to refund
    # @param order_id The order id to refund.
    # @param [Hash] opts the optional parameters
    # @option opts [BOOLEAN] :reject_after_refund Reject order after refund (default to false)
    # @option opts [BOOLEAN] :skip_customer_notification Skip customer email notification (default to false)
    # @option opts [BOOLEAN] :auto_order_cancel Cancel associated auto orders (default to false)
    # @option opts [BOOLEAN] :manual_refund Consider a manual refund done externally (default to false)
    # @option opts [BOOLEAN] :reverse_affiliate_transactions Reverse affiliate transactions (default to true)
    # @option opts [String] :_expand The object expansion to perform on the result.  See documentation for examples
    # @return [OrderResponse]
    def refund_order(order, order_id, opts = {})
      data, _status_code, _headers = refund_order_with_http_info(order, order_id, opts)
      data
    end

    # Refund an order
    # Perform a refund operation on an order and then update the order if successful 
    # @param order Order to refund
    # @param order_id The order id to refund.
    # @param [Hash] opts the optional parameters
    # @option opts [BOOLEAN] :reject_after_refund Reject order after refund
    # @option opts [BOOLEAN] :skip_customer_notification Skip customer email notification
    # @option opts [BOOLEAN] :auto_order_cancel Cancel associated auto orders
    # @option opts [BOOLEAN] :manual_refund Consider a manual refund done externally
    # @option opts [BOOLEAN] :reverse_affiliate_transactions Reverse affiliate transactions
    # @option opts [String] :_expand The object expansion to perform on the result.  See documentation for examples
    # @return [Array<(OrderResponse, Fixnum, Hash)>] OrderResponse data, response status code and response headers
    def refund_order_with_http_info(order, order_id, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: OrderApi.refund_order ...'
      end
      # verify the required parameter 'order' is set
      if @api_client.config.client_side_validation && order.nil?
        fail ArgumentError, "Missing the required parameter 'order' when calling OrderApi.refund_order"
      end
      # verify the required parameter 'order_id' is set
      if @api_client.config.client_side_validation && order_id.nil?
        fail ArgumentError, "Missing the required parameter 'order_id' when calling OrderApi.refund_order"
      end
      # resource path
      local_var_path = '/order/orders/{order_id}/refund'.sub('{' + 'order_id' + '}', order_id.to_s)

      # query parameters
      query_params = {}
      query_params[:'reject_after_refund'] = opts[:'reject_after_refund'] if !opts[:'reject_after_refund'].nil?
      query_params[:'skip_customer_notification'] = opts[:'skip_customer_notification'] if !opts[:'skip_customer_notification'].nil?
      query_params[:'auto_order_cancel'] = opts[:'auto_order_cancel'] if !opts[:'auto_order_cancel'].nil?
      query_params[:'manual_refund'] = opts[:'manual_refund'] if !opts[:'manual_refund'].nil?
      query_params[:'reverse_affiliate_transactions'] = opts[:'reverse_affiliate_transactions'] if !opts[:'reverse_affiliate_transactions'].nil?
      query_params[:'_expand'] = opts[:'_expand'] if !opts[:'_expand'].nil?

      # header parameters
      header_params = {}
      header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
      # 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; charset=UTF-8'])

      # form parameters
      form_params = {}

      # http body (model)
      post_body = @api_client.object_to_http_body(order)
      auth_names = ['ultraCartOauth', 'ultraCartSimpleApiKey']
      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,
        :return_type => 'OrderResponse')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: OrderApi#refund_order\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end
    # Replacement order
    # Create a replacement order based upon a previous order 
    # @param order_id The order id to generate a replacement for.
    # @param replacement Replacement order details
    # @param [Hash] opts the optional parameters
    # @return [OrderReplacementResponse]
    def replacement(order_id, replacement, opts = {})
      data, _status_code, _headers = replacement_with_http_info(order_id, replacement, opts)
      data
    end

    # Replacement order
    # Create a replacement order based upon a previous order 
    # @param order_id The order id to generate a replacement for.
    # @param replacement Replacement order details
    # @param [Hash] opts the optional parameters
    # @return [Array<(OrderReplacementResponse, Fixnum, Hash)>] OrderReplacementResponse data, response status code and response headers
    def replacement_with_http_info(order_id, replacement, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: OrderApi.replacement ...'
      end
      # verify the required parameter 'order_id' is set
      if @api_client.config.client_side_validation && order_id.nil?
        fail ArgumentError, "Missing the required parameter 'order_id' when calling OrderApi.replacement"
      end
      # verify the required parameter 'replacement' is set
      if @api_client.config.client_side_validation && replacement.nil?
        fail ArgumentError, "Missing the required parameter 'replacement' when calling OrderApi.replacement"
      end
      # resource path
      local_var_path = '/order/orders/{order_id}/replacement'.sub('{' + 'order_id' + '}', order_id.to_s)

      # query parameters
      query_params = {}

      # header parameters
      header_params = {}
      header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
      # 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(replacement)
      auth_names = ['ultraCartOauth', 'ultraCartSimpleApiKey']
      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 => 'OrderReplacementResponse')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: OrderApi#replacement\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end
    # Resend receipt
    # Resend the receipt for an order on the UltraCart account. 
    # @param order_id The order id to resend the receipt for.
    # @param [Hash] opts the optional parameters
    # @return [BaseResponse]
    def resend_receipt(order_id, opts = {})
      data, _status_code, _headers = resend_receipt_with_http_info(order_id, opts)
      data
    end

    # Resend receipt
    # Resend the receipt for an order on the UltraCart account. 
    # @param order_id The order id to resend the receipt for.
    # @param [Hash] opts the optional parameters
    # @return [Array<(BaseResponse, Fixnum, Hash)>] BaseResponse data, response status code and response headers
    def resend_receipt_with_http_info(order_id, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: OrderApi.resend_receipt ...'
      end
      # verify the required parameter 'order_id' is set
      if @api_client.config.client_side_validation && order_id.nil?
        fail ArgumentError, "Missing the required parameter 'order_id' when calling OrderApi.resend_receipt"
      end
      # resource path
      local_var_path = '/order/orders/{order_id}/resend_receipt'.sub('{' + 'order_id' + '}', order_id.to_s)

      # query parameters
      query_params = {}

      # header parameters
      header_params = {}
      header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
      # 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 = ['ultraCartOauth', 'ultraCartSimpleApiKey']
      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 => 'BaseResponse')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: OrderApi#resend_receipt\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end
    # Resend shipment confirmation
    # Resend shipment confirmation for an order on the UltraCart account. 
    # @param order_id The order id to resend the shipment notification for.
    # @param [Hash] opts the optional parameters
    # @return [BaseResponse]
    def resend_shipment_confirmation(order_id, opts = {})
      data, _status_code, _headers = resend_shipment_confirmation_with_http_info(order_id, opts)
      data
    end

    # Resend shipment confirmation
    # Resend shipment confirmation for an order on the UltraCart account. 
    # @param order_id The order id to resend the shipment notification for.
    # @param [Hash] opts the optional parameters
    # @return [Array<(BaseResponse, Fixnum, Hash)>] BaseResponse data, response status code and response headers
    def resend_shipment_confirmation_with_http_info(order_id, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: OrderApi.resend_shipment_confirmation ...'
      end
      # verify the required parameter 'order_id' is set
      if @api_client.config.client_side_validation && order_id.nil?
        fail ArgumentError, "Missing the required parameter 'order_id' when calling OrderApi.resend_shipment_confirmation"
      end
      # resource path
      local_var_path = '/order/orders/{order_id}/resend_shipment_confirmation'.sub('{' + 'order_id' + '}', order_id.to_s)

      # query parameters
      query_params = {}

      # header parameters
      header_params = {}
      header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
      # 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 = ['ultraCartOauth', 'ultraCartSimpleApiKey']
      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 => 'BaseResponse')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: OrderApi#resend_shipment_confirmation\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end
    # Update A/R Retry Configuration
    # Update A/R Retry Configuration.  This is primarily an internal API call.  It is doubtful you would ever need to use it. 
    # @param retry_config AccountsReceivableRetryConfig object
    # @param [Hash] opts the optional parameters
    # @return [BaseResponse]
    def update_accounts_receivable_retry_config(retry_config, opts = {})
      data, _status_code, _headers = update_accounts_receivable_retry_config_with_http_info(retry_config, opts)
      data
    end

    # Update A/R Retry Configuration
    # Update A/R Retry Configuration.  This is primarily an internal API call.  It is doubtful you would ever need to use it. 
    # @param retry_config AccountsReceivableRetryConfig object
    # @param [Hash] opts the optional parameters
    # @return [Array<(BaseResponse, Fixnum, Hash)>] BaseResponse data, response status code and response headers
    def update_accounts_receivable_retry_config_with_http_info(retry_config, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: OrderApi.update_accounts_receivable_retry_config ...'
      end
      # verify the required parameter 'retry_config' is set
      if @api_client.config.client_side_validation && retry_config.nil?
        fail ArgumentError, "Missing the required parameter 'retry_config' when calling OrderApi.update_accounts_receivable_retry_config"
      end
      # resource path
      local_var_path = '/order/accountsReceivableRetryConfig'

      # query parameters
      query_params = {}

      # header parameters
      header_params = {}
      header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
      # 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(retry_config)
      auth_names = ['ultraCartOauth', 'ultraCartSimpleApiKey']
      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 => 'BaseResponse')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: OrderApi#update_accounts_receivable_retry_config\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end
    # Update an order
    # Update a new order on the UltraCart account.  This is probably NOT the method you want.  It is rare to update a completed order.  This will not trigger charges, emails, or any other automation. 
    # @param order Order to update
    # @param order_id The order id to update.
    # @param [Hash] opts the optional parameters
    # @option opts [String] :_expand The object expansion to perform on the result.  See documentation for examples
    # @return [OrderResponse]
    def update_order(order, order_id, opts = {})
      data, _status_code, _headers = update_order_with_http_info(order, order_id, opts)
      data
    end

    # Update an order
    # Update a new order on the UltraCart account.  This is probably NOT the method you want.  It is rare to update a completed order.  This will not trigger charges, emails, or any other automation. 
    # @param order Order to update
    # @param order_id The order id to update.
    # @param [Hash] opts the optional parameters
    # @option opts [String] :_expand The object expansion to perform on the result.  See documentation for examples
    # @return [Array<(OrderResponse, Fixnum, Hash)>] OrderResponse data, response status code and response headers
    def update_order_with_http_info(order, order_id, opts = {})
      if @api_client.config.debugging
        @api_client.config.logger.debug 'Calling API: OrderApi.update_order ...'
      end
      # verify the required parameter 'order' is set
      if @api_client.config.client_side_validation && order.nil?
        fail ArgumentError, "Missing the required parameter 'order' when calling OrderApi.update_order"
      end
      # verify the required parameter 'order_id' is set
      if @api_client.config.client_side_validation && order_id.nil?
        fail ArgumentError, "Missing the required parameter 'order_id' when calling OrderApi.update_order"
      end
      # resource path
      local_var_path = '/order/orders/{order_id}'.sub('{' + 'order_id' + '}', order_id.to_s)

      # query parameters
      query_params = {}
      query_params[:'_expand'] = opts[:'_expand'] if !opts[:'_expand'].nil?

      # header parameters
      header_params = {}
      header_params['X-UltraCart-Api-Version'] = @api_client.select_header_api_version()
      # 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; charset=UTF-8'])

      # form parameters
      form_params = {}

      # http body (model)
      post_body = @api_client.object_to_http_body(order)
      auth_names = ['ultraCartOauth', 'ultraCartSimpleApiKey']
      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,
        :return_type => 'OrderResponse')
      if @api_client.config.debugging
        @api_client.config.logger.debug "API called: OrderApi#update_order\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
      end
      return data, status_code, headers
    end
  end
end
