square.rb 3.20190624.0 → 3.20190814.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +10 -28
  3. data/README.md +281 -17235
  4. data/lib/square/api/apple_pay_api.rb +55 -54
  5. data/lib/square/api/base_api.rb +45 -45
  6. data/lib/square/api/catalog_api.rb +461 -460
  7. data/lib/square/api/checkout_api.rb +54 -54
  8. data/lib/square/api/customers_api.rb +335 -334
  9. data/lib/square/api/employees_api.rb +91 -91
  10. data/lib/square/api/inventory_api.rb +300 -298
  11. data/lib/square/api/labor_api.rb +558 -558
  12. data/lib/square/api/locations_api.rb +45 -45
  13. data/lib/square/api/mobile_authorization_api.rb +56 -56
  14. data/lib/square/api/o_auth_api.rb +168 -164
  15. data/lib/square/api/orders_api.rb +269 -151
  16. data/lib/square/api/payments_api.rb +282 -0
  17. data/lib/square/api/refunds_api.rb +149 -0
  18. data/lib/square/api/reporting_api.rb +143 -139
  19. data/lib/square/api/transactions_api.rb +379 -360
  20. data/lib/square/api/v1_employees_api.rb +720 -720
  21. data/lib/square/api/v1_items_api.rb +1651 -1651
  22. data/lib/square/api/v1_locations_api.rb +67 -67
  23. data/lib/square/api/v1_locations_api.rbe +67 -0
  24. data/lib/square/api/v1_transactions_api.rb +574 -574
  25. data/lib/square/api_helper.rb +281 -277
  26. data/lib/square/client.rb +139 -127
  27. data/lib/square/configuration.rb +88 -85
  28. data/lib/square/exceptions/api_exception.rb +20 -20
  29. data/lib/square/http/api_response.rb +50 -50
  30. data/lib/square/http/auth/o_auth2.rb +17 -17
  31. data/lib/square/http/faraday_client.rb +64 -64
  32. data/lib/square/http/http_call_back.rb +24 -24
  33. data/lib/square/http/http_client.rb +104 -104
  34. data/lib/square/http/http_method_enum.rb +13 -13
  35. data/lib/square/http/http_request.rb +50 -50
  36. data/lib/square/http/http_response.rb +29 -29
  37. data/lib/square.rb +52 -50
  38. data/spec/user_journey_spec.rb +4 -1
  39. data/test/api/api_test_base.rb +2 -1
  40. data/test/api/test_catalog_api.rb +59 -0
  41. data/test/api/test_employees_api.rb +36 -0
  42. data/test/api/test_locations_api.rb +35 -0
  43. data/test/api/test_payments_api.rb +42 -0
  44. data/test/api/test_refunds_api.rb +41 -0
  45. metadata +19 -11
@@ -1,151 +1,269 @@
1
- # square
2
- #
3
- # This file was automatically generated by APIMATIC v2.0
4
- # ( https://apimatic.io ).
5
-
6
- module Square
7
- # OrdersApi
8
- class OrdersApi < BaseApi
9
- def initialize(config, http_call_back: nil)
10
- super(config, http_call_back: http_call_back)
11
- end
12
-
13
- # Creates an [Order](#type-order) that can then be referenced as `order_id`
14
- # in a
15
- # request to the [Charge](#endpoint-charge) endpoint. Orders specify
16
- # products for
17
- # purchase, along with discounts, taxes, and other settings to apply to the
18
- # purchase.
19
- # To associate a created order with a request to the Charge endpoint,
20
- # provide the
21
- # order's `id` in the `order_id` field of your request.
22
- # You cannot modify an order after you create it. If you need to modify an
23
- # order,
24
- # instead create a new order with modified details.
25
- # To learn more about the Orders API, see the
26
- # [Orders API Overview](/products/orders/overview).
27
- # @param [String] location_id Required parameter: The ID of the business
28
- # location to associate the order with.
29
- # @param [CreateOrderRequest] body Required parameter: An object containing
30
- # the fields to POST for the request. See the corresponding object
31
- # definition for field details.
32
- # @return [CreateOrderResponse Hash] response from the API call
33
- def create_order(location_id:,
34
- body:)
35
- # Prepare query url.
36
- _query_builder = config.get_base_uri
37
- _query_builder << '/v2/locations/{location_id}/orders'
38
- _query_builder = APIHelper.append_url_with_template_parameters(
39
- _query_builder,
40
- 'location_id' => location_id
41
- )
42
- _query_url = APIHelper.clean_url _query_builder
43
-
44
- # Prepare headers.
45
- _headers = {
46
- 'accept' => 'application/json',
47
- 'content-type' => 'application/json; charset=utf-8'
48
- }
49
-
50
- # Prepare and execute HttpRequest.
51
- _request = config.http_client.post(
52
- _query_url,
53
- headers: _headers,
54
- parameters: body.to_json
55
- )
56
- OAuth2.apply(config, _request)
57
- _response = execute_request(_request)
58
-
59
- # Return appropriate response type.
60
- decoded = APIHelper.json_deserialize(_response.raw_body)
61
- _errors = APIHelper.map_response(decoded, ['errors'])
62
- ApiResponse.new(_response, data: decoded, errors: _errors)
63
- end
64
-
65
- # Retrieves a set of [Order](#type-order)s by their IDs.
66
- # If a given Order ID does not exist, the ID is ignored instead of
67
- # generating an error.
68
- # @param [String] location_id Required parameter: The ID of the orders'
69
- # associated location.
70
- # @param [BatchRetrieveOrdersRequest] body Required parameter: An object
71
- # containing the fields to POST for the request. See the corresponding
72
- # object definition for field details.
73
- # @return [BatchRetrieveOrdersResponse Hash] response from the API call
74
- def batch_retrieve_orders(location_id:,
75
- body:)
76
- # Prepare query url.
77
- _query_builder = config.get_base_uri
78
- _query_builder << '/v2/locations/{location_id}/orders/batch-retrieve'
79
- _query_builder = APIHelper.append_url_with_template_parameters(
80
- _query_builder,
81
- 'location_id' => location_id
82
- )
83
- _query_url = APIHelper.clean_url _query_builder
84
-
85
- # Prepare headers.
86
- _headers = {
87
- 'accept' => 'application/json',
88
- 'content-type' => 'application/json; charset=utf-8'
89
- }
90
-
91
- # Prepare and execute HttpRequest.
92
- _request = config.http_client.post(
93
- _query_url,
94
- headers: _headers,
95
- parameters: body.to_json
96
- )
97
- OAuth2.apply(config, _request)
98
- _response = execute_request(_request)
99
-
100
- # Return appropriate response type.
101
- decoded = APIHelper.json_deserialize(_response.raw_body)
102
- _errors = APIHelper.map_response(decoded, ['errors'])
103
- ApiResponse.new(_response, data: decoded, errors: _errors)
104
- end
105
-
106
- # Search all Orders for a merchant and return either [Orders](#type-order)
107
- # or
108
- # [OrderEntries](#type-orderentry).
109
- # Note that details for orders processed with Square Point of Sale while in
110
- # offline mode may not be
111
- # transmitted to Square for up to 72 hours. Offline orders have a
112
- # `created_at` value that reflects
113
- # the time the order was originally processed, not the time it was
114
- # subsequently transmitted to
115
- # Square. Consequently, the SearchOrder endpoint might list an offline Order
116
- # chronologically
117
- # between online Orders that were seen in a previous request.
118
- # When fetching additional pages using a `cursor`, the `query` must be equal
119
- # to the `query` used to fetch the first page of results.
120
- # @param [SearchOrdersRequest] body Required parameter: An object containing
121
- # the fields to POST for the request. See the corresponding object
122
- # definition for field details.
123
- # @return [SearchOrdersResponse Hash] response from the API call
124
- def search_orders(body:)
125
- # Prepare query url.
126
- _query_builder = config.get_base_uri
127
- _query_builder << '/v2/orders/search'
128
- _query_url = APIHelper.clean_url _query_builder
129
-
130
- # Prepare headers.
131
- _headers = {
132
- 'accept' => 'application/json',
133
- 'content-type' => 'application/json; charset=utf-8'
134
- }
135
-
136
- # Prepare and execute HttpRequest.
137
- _request = config.http_client.post(
138
- _query_url,
139
- headers: _headers,
140
- parameters: body.to_json
141
- )
142
- OAuth2.apply(config, _request)
143
- _response = execute_request(_request)
144
-
145
- # Return appropriate response type.
146
- decoded = APIHelper.json_deserialize(_response.raw_body)
147
- _errors = APIHelper.map_response(decoded, ['errors'])
148
- ApiResponse.new(_response, data: decoded, errors: _errors)
149
- end
150
- end
151
- end
1
+ # square
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module Square
7
+ # OrdersApi
8
+ class OrdersApi < BaseApi
9
+ def initialize(config, http_call_back: nil)
10
+ super(config, http_call_back: http_call_back)
11
+ end
12
+
13
+ # Creates a new [Order](#type-order) which can include information on
14
+ # products for
15
+ # purchase and settings to apply to the purchase.
16
+ # To pay for a created order, please refer to the [Pay for
17
+ # Orders](https://developer.squareup.com/docs/orders-api/pay-for-orders)
18
+ # guide.
19
+ # You can modify open orders using the
20
+ # [UpdateOrder](#endpoint-orders-updateorder) endpoint.
21
+ # To learn more about the Orders API, see the
22
+ # [Orders API
23
+ # Overview](https://developer.squareup.com/docs/orders-api/what-it-does).
24
+ # @param [String] location_id Required parameter: The ID of the business
25
+ # location to associate the order with.
26
+ # @param [CreateOrderRequest] body Required parameter: An object containing
27
+ # the fields to POST for the request. See the corresponding object
28
+ # definition for field details.
29
+ # @return [CreateOrderResponse Hash] response from the API call
30
+ def create_order(location_id:,
31
+ body:)
32
+ # Prepare query url.
33
+ _query_builder = config.get_base_uri
34
+ _query_builder << '/v2/locations/{location_id}/orders'
35
+ _query_builder = APIHelper.append_url_with_template_parameters(
36
+ _query_builder,
37
+ 'location_id' => location_id
38
+ )
39
+ _query_url = APIHelper.clean_url _query_builder
40
+
41
+ # Prepare headers.
42
+ _headers = {
43
+ 'accept' => 'application/json',
44
+ 'content-type' => 'application/json; charset=utf-8'
45
+ }
46
+
47
+ # Prepare and execute HttpRequest.
48
+ _request = config.http_client.post(
49
+ _query_url,
50
+ headers: _headers,
51
+ parameters: body.to_json
52
+ )
53
+ OAuth2.apply(config, _request)
54
+ _response = execute_request(_request)
55
+
56
+ # Return appropriate response type.
57
+ decoded = APIHelper.json_deserialize(_response.raw_body)
58
+ _errors = APIHelper.map_response(decoded, ['errors'])
59
+ ApiResponse.new(_response, data: decoded, errors: _errors)
60
+ end
61
+
62
+ # Retrieves a set of [Order](#type-order)s by their IDs.
63
+ # If a given Order ID does not exist, the ID is ignored instead of
64
+ # generating an error.
65
+ # @param [String] location_id Required parameter: The ID of the orders'
66
+ # associated location.
67
+ # @param [BatchRetrieveOrdersRequest] body Required parameter: An object
68
+ # containing the fields to POST for the request. See the corresponding
69
+ # object definition for field details.
70
+ # @return [BatchRetrieveOrdersResponse Hash] response from the API call
71
+ def batch_retrieve_orders(location_id:,
72
+ body:)
73
+ # Prepare query url.
74
+ _query_builder = config.get_base_uri
75
+ _query_builder << '/v2/locations/{location_id}/orders/batch-retrieve'
76
+ _query_builder = APIHelper.append_url_with_template_parameters(
77
+ _query_builder,
78
+ 'location_id' => location_id
79
+ )
80
+ _query_url = APIHelper.clean_url _query_builder
81
+
82
+ # Prepare headers.
83
+ _headers = {
84
+ 'accept' => 'application/json',
85
+ 'content-type' => 'application/json; charset=utf-8'
86
+ }
87
+
88
+ # Prepare and execute HttpRequest.
89
+ _request = config.http_client.post(
90
+ _query_url,
91
+ headers: _headers,
92
+ parameters: body.to_json
93
+ )
94
+ OAuth2.apply(config, _request)
95
+ _response = execute_request(_request)
96
+
97
+ # Return appropriate response type.
98
+ decoded = APIHelper.json_deserialize(_response.raw_body)
99
+ _errors = APIHelper.map_response(decoded, ['errors'])
100
+ ApiResponse.new(_response, data: decoded, errors: _errors)
101
+ end
102
+
103
+ # Updates an open [Order](#type-order) by adding, replacing, or deleting
104
+ # fields. Orders with a `COMPLETED` or `CANCELED` state cannot be updated.
105
+ # An UpdateOrder request requires the following:
106
+ # - The `order_id` in the endpoint path, identifying the order to update.
107
+ # - The latest `version` of the order to update.
108
+ # - The [sparse
109
+ # order](https://developer.squareup.com/docs/orders-api/manage-orders#sparse
110
+ # -order-objects)
111
+ # containing only the fields to update and the version the update is
112
+ # being applied to.
113
+ # - If deleting fields, the [dot notation
114
+ # paths](https://developer.squareup.com/docs/orders-api/manage-orders#on-dot
115
+ # -notation)
116
+ # identifying fields to clear.
117
+ # To pay for an order, please refer to the [Pay for
118
+ # Orders](https://developer.squareup.com/docs/orders-api/pay-for-orders)
119
+ # guide.
120
+ # To learn more about the Orders API, see the
121
+ # [Orders API
122
+ # Overview](https://developer.squareup.com/docs/orders-api/what-it-does).
123
+ # @param [UpdateOrderRequest] body Required parameter: An object containing
124
+ # the fields to POST for the request. See the corresponding object
125
+ # definition for field details.
126
+ # @param [String] location_id Required parameter: Example:
127
+ # @param [String] order_id Required parameter: Example:
128
+ # @return [UpdateOrderResponse Hash] response from the API call
129
+ def update_order(body:,
130
+ location_id:,
131
+ order_id:)
132
+ # Prepare query url.
133
+ _query_builder = config.get_base_uri
134
+ _query_builder << '/v2/locations/{location_id}/orders/{order_id}'
135
+ _query_builder = APIHelper.append_url_with_template_parameters(
136
+ _query_builder,
137
+ 'location_id' => location_id,
138
+ 'order_id' => order_id
139
+ )
140
+ _query_url = APIHelper.clean_url _query_builder
141
+
142
+ # Prepare headers.
143
+ _headers = {
144
+ 'accept' => 'application/json',
145
+ 'content-type' => 'application/json; charset=utf-8'
146
+ }
147
+
148
+ # Prepare and execute HttpRequest.
149
+ _request = config.http_client.put(
150
+ _query_url,
151
+ headers: _headers,
152
+ parameters: body.to_json
153
+ )
154
+ OAuth2.apply(config, _request)
155
+ _response = execute_request(_request)
156
+
157
+ # Return appropriate response type.
158
+ decoded = APIHelper.json_deserialize(_response.raw_body)
159
+ _errors = APIHelper.map_response(decoded, ['errors'])
160
+ ApiResponse.new(_response, data: decoded, errors: _errors)
161
+ end
162
+
163
+ # Search all orders for one or more locations. Orders include all sales,
164
+ # returns, and exchanges regardless of how or when they entered the Square
165
+ # Ecosystem (e.g. Point of Sale, Invoices, Connect APIs, etc).
166
+ # SearchOrders requests need to specify which locations to search and define
167
+ # a
168
+ # [`SearchOrdersQuery`](#type-searchordersquery) object which controls
169
+ # how to sort or filter the results. Your SearchOrdersQuery can:
170
+ # Set filter criteria.
171
+ # Set sort order.
172
+ # Determine whether to return results as complete Order objects, or as
173
+ # [OrderEntry](#type-orderentry) objects.
174
+ # Note that details for orders processed with Square Point of Sale while in
175
+ # offline mode may not be transmitted to Square for up to 72 hours. Offline
176
+ # orders have a `created_at` value that reflects the time the order was
177
+ # created,
178
+ # not the time it was subsequently transmitted to Square.
179
+ # @param [SearchOrdersRequest] body Required parameter: An object containing
180
+ # the fields to POST for the request. See the corresponding object
181
+ # definition for field details.
182
+ # @return [SearchOrdersResponse Hash] response from the API call
183
+ def search_orders(body:)
184
+ # Prepare query url.
185
+ _query_builder = config.get_base_uri
186
+ _query_builder << '/v2/orders/search'
187
+ _query_url = APIHelper.clean_url _query_builder
188
+
189
+ # Prepare headers.
190
+ _headers = {
191
+ 'accept' => 'application/json',
192
+ 'content-type' => 'application/json; charset=utf-8'
193
+ }
194
+
195
+ # Prepare and execute HttpRequest.
196
+ _request = config.http_client.post(
197
+ _query_url,
198
+ headers: _headers,
199
+ parameters: body.to_json
200
+ )
201
+ OAuth2.apply(config, _request)
202
+ _response = execute_request(_request)
203
+
204
+ # Return appropriate response type.
205
+ decoded = APIHelper.json_deserialize(_response.raw_body)
206
+ _errors = APIHelper.map_response(decoded, ['errors'])
207
+ ApiResponse.new(_response, data: decoded, errors: _errors)
208
+ end
209
+
210
+ # Pay for an [order](#type-order) using one or more approved
211
+ # [payments](#type-payment),
212
+ # or settle an order with a total of `0`.
213
+ # The total of the `payment_ids` listed in the request must be equal to the
214
+ # order
215
+ # total. Orders with a total amount of `0` can be marked as paid by
216
+ # specifying an empty
217
+ # array of `payment_ids` in the request.
218
+ # To be used with PayOrder, a payment must:
219
+ # - Reference the order by specifying the `order_id` when [creating the
220
+ # payment](#endpoint-payments-createpayment).
221
+ # Any approved payments that reference the same `order_id` not specified in
222
+ # the
223
+ # `payment_ids` will be canceled.
224
+ # - Be approved with [delayed
225
+ # capture](https://developer.squareup.com/docs/payments-api/take-payments#de
226
+ # layed-capture).
227
+ # Using a delayed capture payment with PayOrder will complete the approved
228
+ # payment.
229
+ # Learn how to [pay for orders with a single payment using the Payments
230
+ # API](https://developer.squareup.com/docs/orders-api/pay-for-orders).
231
+ # @param [String] order_id Required parameter: The ID of the order being
232
+ # paid.
233
+ # @param [PayOrderRequest] body Required parameter: An object containing the
234
+ # fields to POST for the request. See the corresponding object definition
235
+ # for field details.
236
+ # @return [PayOrderResponse Hash] response from the API call
237
+ def pay_order(order_id:,
238
+ body:)
239
+ # Prepare query url.
240
+ _query_builder = config.get_base_uri
241
+ _query_builder << '/v2/orders/{order_id}/pay'
242
+ _query_builder = APIHelper.append_url_with_template_parameters(
243
+ _query_builder,
244
+ 'order_id' => order_id
245
+ )
246
+ _query_url = APIHelper.clean_url _query_builder
247
+
248
+ # Prepare headers.
249
+ _headers = {
250
+ 'accept' => 'application/json',
251
+ 'content-type' => 'application/json; charset=utf-8'
252
+ }
253
+
254
+ # Prepare and execute HttpRequest.
255
+ _request = config.http_client.post(
256
+ _query_url,
257
+ headers: _headers,
258
+ parameters: body.to_json
259
+ )
260
+ OAuth2.apply(config, _request)
261
+ _response = execute_request(_request)
262
+
263
+ # Return appropriate response type.
264
+ decoded = APIHelper.json_deserialize(_response.raw_body)
265
+ _errors = APIHelper.map_response(decoded, ['errors'])
266
+ ApiResponse.new(_response, data: decoded, errors: _errors)
267
+ end
268
+ end
269
+ end