Class: SquareConnect::OrdersApi

Inherits:
Object
  • Object
show all
Defined in:
lib/square_connect/api/orders_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ OrdersApi

Returns a new instance of OrdersApi.



16
17
18
# File 'lib/square_connect/api/orders_api.rb', line 16

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

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



14
15
16
# File 'lib/square_connect/api/orders_api.rb', line 14

def api_client
  @api_client
end

Instance Method Details

#batch_retrieve_orders(location_id, body, opts = {}) ⇒ BatchRetrieveOrdersResponse

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.

Parameters:

  • location_id

    The ID of the orders' associated location.

  • body

    An object containing the fields to POST for the request. See the corresponding object definition for field details.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



26
27
28
29
# 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 = {}) ⇒ Array<(BatchRetrieveOrdersResponse, Fixnum, Hash)>

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.

Parameters:

  • location_id

    The ID of the orders&#39; associated location.

  • body

    An object containing the fields to POST for the request. See the corresponding object definition for field details.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# 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 = {}) ⇒ CreateOrderResponse

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).

Parameters:

  • location_id

    The ID of the business location to associate the order with.

  • body

    An object containing the fields to POST for the request. See the corresponding object definition for field details.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



85
86
87
88
# 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 = {}) ⇒ Array<(CreateOrderResponse, Fixnum, Hash)>

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).

Parameters:

  • location_id

    The ID of the business location to associate the order with.

  • body

    An object containing the fields to POST for the request. See the corresponding object definition for field details.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(CreateOrderResponse, Fixnum, Hash)>)

    CreateOrderResponse data, response status code and response headers



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# 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 = {}) ⇒ SearchOrdersResponse

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.

Parameters:

  • body

    An object containing the fields to POST for the request. See the corresponding object definition for field details.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



143
144
145
146
# 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 = {}) ⇒ Array<(SearchOrdersResponse, Fixnum, Hash)>

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.

Parameters:

  • body

    An object containing the fields to POST for the request. See the corresponding object definition for field details.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(SearchOrdersResponse, Fixnum, Hash)>)

    SearchOrdersResponse data, response status code and response headers



153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# 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