square.rb 26.1.0.20230119 → 26.2.0.20230315
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/square/api/apple_pay_api.rb +14 -30
- data/lib/square/api/bank_accounts_api.rb +40 -90
- data/lib/square/api/base_api.rb +42 -42
- data/lib/square/api/booking_custom_attributes_api.rb +164 -329
- data/lib/square/api/bookings_api.rb +135 -260
- data/lib/square/api/cards_api.rb +56 -118
- data/lib/square/api/cash_drawers_api.rb +47 -103
- data/lib/square/api/catalog_api.rb +197 -423
- data/lib/square/api/checkout_api.rb +85 -175
- data/lib/square/api/customer_custom_attributes_api.rb +150 -303
- data/lib/square/api/customer_groups_api.rb +69 -145
- data/lib/square/api/customer_segments_api.rb +26 -61
- data/lib/square/api/customers_api.rb +147 -294
- data/lib/square/api/devices_api.rb +42 -89
- data/lib/square/api/disputes_api.rb +130 -288
- data/lib/square/api/employees_api.rb +28 -63
- data/lib/square/api/gift_card_activities_api.rb +33 -65
- data/lib/square/api/gift_cards_api.rb +103 -202
- data/lib/square/api/inventory_api.rb +179 -366
- data/lib/square/api/invoices_api.rb +118 -237
- data/lib/square/api/labor_api.rb +223 -459
- data/lib/square/api/location_custom_attributes_api.rb +166 -331
- data/lib/square/api/locations_api.rb +54 -112
- data/lib/square/api/loyalty_api.rb +259 -512
- data/lib/square/api/merchants_api.rb +25 -60
- data/lib/square/api/mobile_authorization_api.rb +14 -30
- data/lib/square/api/o_auth_api.rb +54 -109
- data/lib/square/api/order_custom_attributes_api.rb +168 -333
- data/lib/square/api/orders_api.rb +115 -222
- data/lib/square/api/payments_api.rb +106 -208
- data/lib/square/api/payouts_api.rb +47 -100
- data/lib/square/api/refunds_api.rb +46 -93
- data/lib/square/api/sites_api.rb +11 -28
- data/lib/square/api/snippets_api.rb +42 -90
- data/lib/square/api/subscriptions_api.rb +150 -299
- data/lib/square/api/team_api.rb +114 -224
- data/lib/square/api/terminal_api.rb +162 -328
- data/lib/square/api/transactions_api.rb +62 -126
- data/lib/square/api/v1_transactions_api.rb +155 -296
- data/lib/square/api/vendors_api.rb +99 -192
- data/lib/square/api/webhook_subscriptions_api.rb +115 -235
- data/lib/square/api_helper.rb +1 -437
- data/lib/square/client.rb +77 -47
- data/lib/square/configuration.rb +28 -53
- data/lib/square/exceptions/api_exception.rb +1 -11
- data/lib/square/http/api_response.rb +13 -19
- data/lib/square/http/auth/o_auth2.rb +14 -7
- data/lib/square/http/http_call_back.rb +1 -15
- data/lib/square/http/http_method_enum.rb +1 -4
- data/lib/square/http/http_request.rb +1 -45
- data/lib/square/http/http_response.rb +1 -20
- data/lib/square/utilities/date_time_helper.rb +1 -146
- data/lib/square/utilities/file_wrapper.rb +5 -5
- data/lib/square.rb +6 -6
- data/spec/user_journey_spec.rb +2 -2
- data/test/api/api_test_base.rb +13 -5
- data/test/api/test_catalog_api.rb +5 -4
- data/test/api/test_customers_api.rb +3 -2
- data/test/api/test_employees_api.rb +4 -3
- data/test/api/test_labor_api.rb +6 -5
- data/test/api/test_locations_api.rb +3 -2
- data/test/api/test_merchants_api.rb +4 -3
- data/test/api/test_payments_api.rb +4 -3
- data/test/api/test_refunds_api.rb +4 -3
- metadata +11 -111
- data/lib/square/exceptions/validation_exception.rb +0 -13
- data/lib/square/http/faraday_client.rb +0 -93
- data/lib/square/http/http_client.rb +0 -118
- data/test/test_helper.rb +0 -89
@@ -1,10 +1,6 @@
|
|
1
1
|
module Square
|
2
2
|
# OrdersApi
|
3
3
|
class OrdersApi < BaseApi
|
4
|
-
def initialize(config, http_call_back: nil)
|
5
|
-
super(config, http_call_back: http_call_back)
|
6
|
-
end
|
7
|
-
|
8
4
|
# Creates a new [order]($m/Order) that can include information about
|
9
5
|
# products for
|
10
6
|
# purchase and settings to apply to the purchase.
|
@@ -18,32 +14,20 @@ module Square
|
|
18
14
|
# definition for field details.
|
19
15
|
# @return [CreateOrderResponse Hash] response from the API call
|
20
16
|
def create_order(body:)
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
headers: _headers,
|
36
|
-
parameters: body.to_json
|
37
|
-
)
|
38
|
-
OAuth2.apply(config, _request)
|
39
|
-
_response = execute_request(_request)
|
40
|
-
|
41
|
-
# Return appropriate response type.
|
42
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
43
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
44
|
-
ApiResponse.new(
|
45
|
-
_response, data: decoded, errors: _errors
|
46
|
-
)
|
17
|
+
new_api_call_builder
|
18
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
19
|
+
'/v2/orders',
|
20
|
+
'default')
|
21
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
22
|
+
.body_param(new_parameter(body))
|
23
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
24
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
25
|
+
.auth(Single.new('global')))
|
26
|
+
.response(new_response_handler
|
27
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
28
|
+
.is_api_response(true)
|
29
|
+
.convertor(ApiResponse.method(:create)))
|
30
|
+
.execute
|
47
31
|
end
|
48
32
|
|
49
33
|
# Retrieves a set of [orders]($m/Order) by their IDs.
|
@@ -54,32 +38,20 @@ module Square
|
|
54
38
|
# object definition for field details.
|
55
39
|
# @return [BatchRetrieveOrdersResponse Hash] response from the API call
|
56
40
|
def batch_retrieve_orders(body:)
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
headers: _headers,
|
72
|
-
parameters: body.to_json
|
73
|
-
)
|
74
|
-
OAuth2.apply(config, _request)
|
75
|
-
_response = execute_request(_request)
|
76
|
-
|
77
|
-
# Return appropriate response type.
|
78
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
79
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
80
|
-
ApiResponse.new(
|
81
|
-
_response, data: decoded, errors: _errors
|
82
|
-
)
|
41
|
+
new_api_call_builder
|
42
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
43
|
+
'/v2/orders/batch-retrieve',
|
44
|
+
'default')
|
45
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
46
|
+
.body_param(new_parameter(body))
|
47
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
48
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
49
|
+
.auth(Single.new('global')))
|
50
|
+
.response(new_response_handler
|
51
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
52
|
+
.is_api_response(true)
|
53
|
+
.convertor(ApiResponse.method(:create)))
|
54
|
+
.execute
|
83
55
|
end
|
84
56
|
|
85
57
|
# Enables applications to preview order pricing without creating an order.
|
@@ -88,32 +60,20 @@ module Square
|
|
88
60
|
# object definition for field details.
|
89
61
|
# @return [CalculateOrderResponse Hash] response from the API call
|
90
62
|
def calculate_order(body:)
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
headers: _headers,
|
106
|
-
parameters: body.to_json
|
107
|
-
)
|
108
|
-
OAuth2.apply(config, _request)
|
109
|
-
_response = execute_request(_request)
|
110
|
-
|
111
|
-
# Return appropriate response type.
|
112
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
113
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
114
|
-
ApiResponse.new(
|
115
|
-
_response, data: decoded, errors: _errors
|
116
|
-
)
|
63
|
+
new_api_call_builder
|
64
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
65
|
+
'/v2/orders/calculate',
|
66
|
+
'default')
|
67
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
68
|
+
.body_param(new_parameter(body))
|
69
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
70
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
71
|
+
.auth(Single.new('global')))
|
72
|
+
.response(new_response_handler
|
73
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
74
|
+
.is_api_response(true)
|
75
|
+
.convertor(ApiResponse.method(:create)))
|
76
|
+
.execute
|
117
77
|
end
|
118
78
|
|
119
79
|
# Creates a new order, in the `DRAFT` state, by duplicating an existing
|
@@ -125,32 +85,20 @@ module Square
|
|
125
85
|
# definition for field details.
|
126
86
|
# @return [CloneOrderResponse Hash] response from the API call
|
127
87
|
def clone_order(body:)
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
headers: _headers,
|
143
|
-
parameters: body.to_json
|
144
|
-
)
|
145
|
-
OAuth2.apply(config, _request)
|
146
|
-
_response = execute_request(_request)
|
147
|
-
|
148
|
-
# Return appropriate response type.
|
149
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
150
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
151
|
-
ApiResponse.new(
|
152
|
-
_response, data: decoded, errors: _errors
|
153
|
-
)
|
88
|
+
new_api_call_builder
|
89
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
90
|
+
'/v2/orders/clone',
|
91
|
+
'default')
|
92
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
93
|
+
.body_param(new_parameter(body))
|
94
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
95
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
96
|
+
.auth(Single.new('global')))
|
97
|
+
.response(new_response_handler
|
98
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
99
|
+
.is_api_response(true)
|
100
|
+
.convertor(ApiResponse.method(:create)))
|
101
|
+
.execute
|
154
102
|
end
|
155
103
|
|
156
104
|
# Search all orders for one or more locations. Orders include all sales,
|
@@ -175,32 +123,20 @@ module Square
|
|
175
123
|
# definition for field details.
|
176
124
|
# @return [SearchOrdersResponse Hash] response from the API call
|
177
125
|
def search_orders(body:)
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
headers: _headers,
|
193
|
-
parameters: body.to_json
|
194
|
-
)
|
195
|
-
OAuth2.apply(config, _request)
|
196
|
-
_response = execute_request(_request)
|
197
|
-
|
198
|
-
# Return appropriate response type.
|
199
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
200
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
201
|
-
ApiResponse.new(
|
202
|
-
_response, data: decoded, errors: _errors
|
203
|
-
)
|
126
|
+
new_api_call_builder
|
127
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
128
|
+
'/v2/orders/search',
|
129
|
+
'default')
|
130
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
131
|
+
.body_param(new_parameter(body))
|
132
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
133
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
134
|
+
.auth(Single.new('global')))
|
135
|
+
.response(new_response_handler
|
136
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
137
|
+
.is_api_response(true)
|
138
|
+
.convertor(ApiResponse.method(:create)))
|
139
|
+
.execute
|
204
140
|
end
|
205
141
|
|
206
142
|
# Retrieves an [Order]($m/Order) by ID.
|
@@ -208,34 +144,19 @@ module Square
|
|
208
144
|
# retrieve.
|
209
145
|
# @return [RetrieveOrderResponse Hash] response from the API call
|
210
146
|
def retrieve_order(order_id:)
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
# Prepare and execute HttpRequest.
|
226
|
-
_request = config.http_client.get(
|
227
|
-
_query_url,
|
228
|
-
headers: _headers
|
229
|
-
)
|
230
|
-
OAuth2.apply(config, _request)
|
231
|
-
_response = execute_request(_request)
|
232
|
-
|
233
|
-
# Return appropriate response type.
|
234
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
235
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
236
|
-
ApiResponse.new(
|
237
|
-
_response, data: decoded, errors: _errors
|
238
|
-
)
|
147
|
+
new_api_call_builder
|
148
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
149
|
+
'/v2/orders/{order_id}',
|
150
|
+
'default')
|
151
|
+
.template_param(new_parameter(order_id, key: 'order_id')
|
152
|
+
.should_encode(true))
|
153
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
154
|
+
.auth(Single.new('global')))
|
155
|
+
.response(new_response_handler
|
156
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
157
|
+
.is_api_response(true)
|
158
|
+
.convertor(ApiResponse.method(:create)))
|
159
|
+
.execute
|
239
160
|
end
|
240
161
|
|
241
162
|
# Updates an open [order]($m/Order) by adding, replacing, or deleting
|
@@ -264,36 +185,22 @@ module Square
|
|
264
185
|
# @return [UpdateOrderResponse Hash] response from the API call
|
265
186
|
def update_order(order_id:,
|
266
187
|
body:)
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
_request = config.http_client.put(
|
284
|
-
_query_url,
|
285
|
-
headers: _headers,
|
286
|
-
parameters: body.to_json
|
287
|
-
)
|
288
|
-
OAuth2.apply(config, _request)
|
289
|
-
_response = execute_request(_request)
|
290
|
-
|
291
|
-
# Return appropriate response type.
|
292
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
293
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
294
|
-
ApiResponse.new(
|
295
|
-
_response, data: decoded, errors: _errors
|
296
|
-
)
|
188
|
+
new_api_call_builder
|
189
|
+
.request(new_request_builder(HttpMethodEnum::PUT,
|
190
|
+
'/v2/orders/{order_id}',
|
191
|
+
'default')
|
192
|
+
.template_param(new_parameter(order_id, key: 'order_id')
|
193
|
+
.should_encode(true))
|
194
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
195
|
+
.body_param(new_parameter(body))
|
196
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
197
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
198
|
+
.auth(Single.new('global')))
|
199
|
+
.response(new_response_handler
|
200
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
201
|
+
.is_api_response(true)
|
202
|
+
.convertor(ApiResponse.method(:create)))
|
203
|
+
.execute
|
297
204
|
end
|
298
205
|
|
299
206
|
# Pay for an [order]($m/Order) using one or more approved
|
@@ -323,36 +230,22 @@ module Square
|
|
323
230
|
# @return [PayOrderResponse Hash] response from the API call
|
324
231
|
def pay_order(order_id:,
|
325
232
|
body:)
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
_request = config.http_client.post(
|
343
|
-
_query_url,
|
344
|
-
headers: _headers,
|
345
|
-
parameters: body.to_json
|
346
|
-
)
|
347
|
-
OAuth2.apply(config, _request)
|
348
|
-
_response = execute_request(_request)
|
349
|
-
|
350
|
-
# Return appropriate response type.
|
351
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
352
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
353
|
-
ApiResponse.new(
|
354
|
-
_response, data: decoded, errors: _errors
|
355
|
-
)
|
233
|
+
new_api_call_builder
|
234
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
235
|
+
'/v2/orders/{order_id}/pay',
|
236
|
+
'default')
|
237
|
+
.template_param(new_parameter(order_id, key: 'order_id')
|
238
|
+
.should_encode(true))
|
239
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
240
|
+
.body_param(new_parameter(body))
|
241
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
242
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
243
|
+
.auth(Single.new('global')))
|
244
|
+
.response(new_response_handler
|
245
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
246
|
+
.is_api_response(true)
|
247
|
+
.convertor(ApiResponse.method(:create)))
|
248
|
+
.execute
|
356
249
|
end
|
357
250
|
end
|
358
251
|
end
|