class SquareConnect::OrdersApi

Attributes

api_client[RW]

Public Class Methods

new(api_client = ApiClient.default) click to toggle source
# File lib/square_connect/api/orders_api.rb, line 16
def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Public Instance Methods

batch_retrieve_orders(location_id, body, opts = {}) click to toggle source

BatchRetrieveOrders Retrieves a set of [Order](type-order)s by their IDs. If a given Order ID does not exist, the ID is ignored instead of generating an error. @param location_id The ID of the orders' associated location. @param body An object containing the fields to POST for the request. See the corresponding object definition for field details. @param [Hash] opts the optional parameters @return [BatchRetrieveOrdersResponse]

# File lib/square_connect/api/orders_api.rb, line 26
def batch_retrieve_orders(location_id, body, opts = {})
  data, _status_code, _headers = batch_retrieve_orders_with_http_info(location_id, body, opts)
  return data
end
batch_retrieve_orders_with_http_info(location_id, body, opts = {}) click to toggle source

BatchRetrieveOrders Retrieves a set of [Order](type-order)s by their IDs. If a given Order ID does not exist, the ID is ignored instead of generating an error. @param location_id The ID of the orders&#39; associated location. @param body An object containing the fields to POST for the request. See the corresponding object definition for field details. @param [Hash] opts the optional parameters @return [Array<(BatchRetrieveOrdersResponse, Fixnum, Hash)>] BatchRetrieveOrdersResponse data, response status code and response headers

# File lib/square_connect/api/orders_api.rb, line 37
def batch_retrieve_orders_with_http_info(location_id, body, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: OrdersApi.batch_retrieve_orders ..."
  end
  # verify the required parameter 'location_id' is set
  fail ArgumentError, "Missing the required parameter 'location_id' when calling OrdersApi.batch_retrieve_orders" if location_id.nil?
  # verify the required parameter 'body' is set
  fail ArgumentError, "Missing the required parameter 'body' when calling OrdersApi.batch_retrieve_orders" if body.nil?
  # resource path
  local_var_path = "/v2/locations/{location_id}/orders/batch-retrieve".sub('{format}','json').sub('{' + 'location_id' + '}', location_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'])
  
  header_params['Square-Version'] = "2019-06-12"

  # form parameters
  form_params = {}

  # http body (model)
  post_body = @api_client.object_to_http_body(body)
  auth_names = ['oauth2']
  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 => 'BatchRetrieveOrdersResponse')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: OrdersApi#batch_retrieve_orders\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end
create_order(location_id, body, opts = {}) click to toggle source

CreateOrder Creates an [Order](type-order) that can then be referenced as `order_id` in a request to the [Charge](endpoint-charge) endpoint. Orders specify products for purchase, along with discounts, taxes, and other settings to apply to the purchase. To associate a created order with a request to the Charge endpoint, provide the order's `id` in the `order_id` field of your request. You cannot modify an order after you create it. If you need to modify an order, instead create a new order with modified details. To learn more about the Orders API, see the [Orders API Overview](/products/orders/overview). @param location_id The ID of the business location to associate the order with. @param body An object containing the fields to POST for the request. See the corresponding object definition for field details. @param [Hash] opts the optional parameters @return [CreateOrderResponse]

# File lib/square_connect/api/orders_api.rb, line 85
def create_order(location_id, body, opts = {})
  data, _status_code, _headers = create_order_with_http_info(location_id, body, opts)
  return data
end
create_order_with_http_info(location_id, body, opts = {}) click to toggle source

CreateOrder Creates an [Order](type-order) that can then be referenced as &#x60;order_id&#x60; in a request to the [Charge](endpoint-charge) endpoint. Orders specify products for purchase, along with discounts, taxes, and other settings to apply to the purchase. To associate a created order with a request to the Charge endpoint, provide the order&#39;s &#x60;id&#x60; in the &#x60;order_id&#x60; field of your request. You cannot modify an order after you create it. If you need to modify an order, instead create a new order with modified details. To learn more about the Orders API, see the [Orders API Overview](/products/orders/overview). @param location_id The ID of the business location to associate the order with. @param body An object containing the fields to POST for the request. See the corresponding object definition for field details. @param [Hash] opts the optional parameters @return [Array<(CreateOrderResponse, Fixnum, Hash)>] CreateOrderResponse data, response status code and response headers

# File lib/square_connect/api/orders_api.rb, line 96
def create_order_with_http_info(location_id, body, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: OrdersApi.create_order ..."
  end
  # verify the required parameter 'location_id' is set
  fail ArgumentError, "Missing the required parameter 'location_id' when calling OrdersApi.create_order" if location_id.nil?
  # verify the required parameter 'body' is set
  fail ArgumentError, "Missing the required parameter 'body' when calling OrdersApi.create_order" if body.nil?
  # resource path
  local_var_path = "/v2/locations/{location_id}/orders".sub('{format}','json').sub('{' + 'location_id' + '}', location_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'])
  
  header_params['Square-Version'] = "2019-06-12"

  # form parameters
  form_params = {}

  # http body (model)
  post_body = @api_client.object_to_http_body(body)
  auth_names = ['oauth2']
  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 => 'CreateOrderResponse')
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: OrdersApi#create_order\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end
search_orders(body, opts = {}) click to toggle source

SearchOrders Search all Orders for a merchant and return either [Orders](type-order) or [OrderEntries](type-orderentry). Note that details for orders processed with Square Point of Sale while in offline mode may not be transmitted to Square for up to 72 hours. Offline orders have a `created_at` value that reflects the time the order was originally processed, not the time it was subsequently transmitted to Square. Consequently, the SearchOrder endpoint might list an offline Order chronologically between online Orders that were seen in a previous request. When fetching additional pages using a `cursor`, the `query` must be equal to the `query` used to fetch the first page of results. @param body An object containing the fields to POST for the request. See the corresponding object definition for field details. @param [Hash] opts the optional parameters @return [SearchOrdersResponse]

# File lib/square_connect/api/orders_api.rb, line 143
def search_orders(body, opts = {})
  data, _status_code, _headers = search_orders_with_http_info(body, opts)
  return data
end
search_orders_with_http_info(body, opts = {}) click to toggle source

SearchOrders Search all Orders for a merchant and return either [Orders](type-order) or [OrderEntries](type-orderentry). Note that details for orders processed with Square Point of Sale while in offline mode may not be transmitted to Square for up to 72 hours. Offline orders have a &#x60;created_at&#x60; value that reflects the time the order was originally processed, not the time it was subsequently transmitted to Square. Consequently, the SearchOrder endpoint might list an offline Order chronologically between online Orders that were seen in a previous request. When fetching additional pages using a &#x60;cursor&#x60;, the &#x60;query&#x60; must be equal to the &#x60;query&#x60; used to fetch the first page of results. @param body An object containing the fields to POST for the request. See the corresponding object definition for field details. @param [Hash] opts the optional parameters @return [Array<(SearchOrdersResponse, Fixnum, Hash)>] SearchOrdersResponse data, response status code and response headers

# File lib/square_connect/api/orders_api.rb, line 153
def search_orders_with_http_info(body, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug "Calling API: OrdersApi.search_orders ..."
  end
  # verify the required parameter 'body' is set
  fail ArgumentError, "Missing the required parameter 'body' when calling OrdersApi.search_orders" if body.nil?
  # resource path
  local_var_path = "/v2/orders/search".sub('{format}','json')

  # 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'])
  
  header_params['Square-Version'] = "2019-06-12"

  # form parameters
  form_params = {}

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