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.
- checksums.yaml +4 -4
- data/LICENSE +10 -28
- data/README.md +281 -17235
- data/lib/square/api/apple_pay_api.rb +55 -54
- data/lib/square/api/base_api.rb +45 -45
- data/lib/square/api/catalog_api.rb +461 -460
- data/lib/square/api/checkout_api.rb +54 -54
- data/lib/square/api/customers_api.rb +335 -334
- data/lib/square/api/employees_api.rb +91 -91
- data/lib/square/api/inventory_api.rb +300 -298
- data/lib/square/api/labor_api.rb +558 -558
- data/lib/square/api/locations_api.rb +45 -45
- data/lib/square/api/mobile_authorization_api.rb +56 -56
- data/lib/square/api/o_auth_api.rb +168 -164
- data/lib/square/api/orders_api.rb +269 -151
- data/lib/square/api/payments_api.rb +282 -0
- data/lib/square/api/refunds_api.rb +149 -0
- data/lib/square/api/reporting_api.rb +143 -139
- data/lib/square/api/transactions_api.rb +379 -360
- data/lib/square/api/v1_employees_api.rb +720 -720
- data/lib/square/api/v1_items_api.rb +1651 -1651
- data/lib/square/api/v1_locations_api.rb +67 -67
- data/lib/square/api/v1_locations_api.rbe +67 -0
- data/lib/square/api/v1_transactions_api.rb +574 -574
- data/lib/square/api_helper.rb +281 -277
- data/lib/square/client.rb +139 -127
- data/lib/square/configuration.rb +88 -85
- data/lib/square/exceptions/api_exception.rb +20 -20
- data/lib/square/http/api_response.rb +50 -50
- data/lib/square/http/auth/o_auth2.rb +17 -17
- data/lib/square/http/faraday_client.rb +64 -64
- data/lib/square/http/http_call_back.rb +24 -24
- data/lib/square/http/http_client.rb +104 -104
- data/lib/square/http/http_method_enum.rb +13 -13
- data/lib/square/http/http_request.rb +50 -50
- data/lib/square/http/http_response.rb +29 -29
- data/lib/square.rb +52 -50
- data/spec/user_journey_spec.rb +4 -1
- data/test/api/api_test_base.rb +2 -1
- data/test/api/test_catalog_api.rb +59 -0
- data/test/api/test_employees_api.rb +36 -0
- data/test/api/test_locations_api.rb +35 -0
- data/test/api/test_payments_api.rb +42 -0
- data/test/api/test_refunds_api.rb +41 -0
- metadata +19 -11
@@ -1,574 +1,574 @@
|
|
1
|
-
# square
|
2
|
-
#
|
3
|
-
# This file was automatically generated by APIMATIC v2.0
|
4
|
-
# ( https://apimatic.io ).
|
5
|
-
|
6
|
-
module Square
|
7
|
-
# V1TransactionsApi
|
8
|
-
class V1TransactionsApi < BaseApi
|
9
|
-
def initialize(config, http_call_back: nil)
|
10
|
-
super(config, http_call_back: http_call_back)
|
11
|
-
end
|
12
|
-
|
13
|
-
# Provides non-confidential details for all of a location's associated bank
|
14
|
-
# accounts. This endpoint does not provide full bank account numbers, and
|
15
|
-
# there is no way to obtain a full bank account number with the Connect API.
|
16
|
-
# @param [String] location_id Required parameter: The ID of the location to
|
17
|
-
# list bank accounts for.
|
18
|
-
# @return [List of V1BankAccount Hash] response from the API call
|
19
|
-
def list_bank_accounts(location_id:)
|
20
|
-
# Prepare query url.
|
21
|
-
_query_builder = config.get_base_uri
|
22
|
-
_query_builder << '/v1/{location_id}/bank-accounts'
|
23
|
-
_query_builder = APIHelper.append_url_with_template_parameters(
|
24
|
-
_query_builder,
|
25
|
-
'location_id' => location_id
|
26
|
-
)
|
27
|
-
_query_url = APIHelper.clean_url _query_builder
|
28
|
-
|
29
|
-
# Prepare headers.
|
30
|
-
_headers = {
|
31
|
-
'accept' => 'application/json'
|
32
|
-
}
|
33
|
-
|
34
|
-
# Prepare and execute HttpRequest.
|
35
|
-
_request = config.http_client.get(
|
36
|
-
_query_url,
|
37
|
-
headers: _headers
|
38
|
-
)
|
39
|
-
OAuth2.apply(config, _request)
|
40
|
-
_response = execute_request(_request)
|
41
|
-
|
42
|
-
# Return appropriate response type.
|
43
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
44
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
45
|
-
ApiResponse.new(_response, data: decoded, errors: _errors)
|
46
|
-
end
|
47
|
-
|
48
|
-
# Provides non-confidential details for a merchant's associated bank
|
49
|
-
# account. This endpoint does not provide full bank account numbers, and
|
50
|
-
# there is no way to obtain a full bank account number with the Connect API.
|
51
|
-
# @param [String] location_id Required parameter: The ID of the bank
|
52
|
-
# account's associated location.
|
53
|
-
# @param [String] bank_account_id Required parameter: The bank account's
|
54
|
-
# Square-issued ID. You obtain this value from Settlement objects
|
55
|
-
# returned.
|
56
|
-
# @return [V1BankAccount Hash] response from the API call
|
57
|
-
def retrieve_bank_account(location_id:,
|
58
|
-
bank_account_id:)
|
59
|
-
# Prepare query url.
|
60
|
-
_query_builder = config.get_base_uri
|
61
|
-
_query_builder << '/v1/{location_id}/bank-accounts/{bank_account_id}'
|
62
|
-
_query_builder = APIHelper.append_url_with_template_parameters(
|
63
|
-
_query_builder,
|
64
|
-
'location_id' => location_id,
|
65
|
-
'bank_account_id' => bank_account_id
|
66
|
-
)
|
67
|
-
_query_url = APIHelper.clean_url _query_builder
|
68
|
-
|
69
|
-
# Prepare headers.
|
70
|
-
_headers = {
|
71
|
-
'accept' => 'application/json'
|
72
|
-
}
|
73
|
-
|
74
|
-
# Prepare and execute HttpRequest.
|
75
|
-
_request = config.http_client.get(
|
76
|
-
_query_url,
|
77
|
-
headers: _headers
|
78
|
-
)
|
79
|
-
OAuth2.apply(config, _request)
|
80
|
-
_response = execute_request(_request)
|
81
|
-
|
82
|
-
# Return appropriate response type.
|
83
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
84
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
85
|
-
ApiResponse.new(_response, data: decoded, errors: _errors)
|
86
|
-
end
|
87
|
-
|
88
|
-
# Provides summary information for a merchant's online store orders.
|
89
|
-
# @param [String] location_id Required parameter: The ID of the location to
|
90
|
-
# list online store orders for.
|
91
|
-
# @param [SortOrder] order Optional parameter: TThe order in which payments
|
92
|
-
# are listed in the response.
|
93
|
-
# @param [Integer] limit Optional parameter: The maximum number of payments
|
94
|
-
# to return in a single response. This value cannot exceed 200.
|
95
|
-
# @param [String] batch_token Optional parameter: A pagination cursor to
|
96
|
-
# retrieve the next set of results for your original query to the
|
97
|
-
# endpoint.
|
98
|
-
# @return [List of V1Order Hash] response from the API call
|
99
|
-
def list_orders(location_id:,
|
100
|
-
order: nil,
|
101
|
-
limit: nil,
|
102
|
-
batch_token: nil)
|
103
|
-
# Prepare query url.
|
104
|
-
_query_builder = config.get_base_uri
|
105
|
-
_query_builder << '/v1/{location_id}/orders'
|
106
|
-
_query_builder = APIHelper.append_url_with_template_parameters(
|
107
|
-
_query_builder,
|
108
|
-
'location_id' => location_id
|
109
|
-
)
|
110
|
-
_query_builder = APIHelper.append_url_with_query_parameters(
|
111
|
-
_query_builder,
|
112
|
-
'order' => order,
|
113
|
-
'limit' => limit,
|
114
|
-
'batch_token' => batch_token
|
115
|
-
)
|
116
|
-
_query_url = APIHelper.clean_url _query_builder
|
117
|
-
|
118
|
-
# Prepare headers.
|
119
|
-
_headers = {
|
120
|
-
'accept' => 'application/json'
|
121
|
-
}
|
122
|
-
|
123
|
-
# Prepare and execute HttpRequest.
|
124
|
-
_request = config.http_client.get(
|
125
|
-
_query_url,
|
126
|
-
headers: _headers
|
127
|
-
)
|
128
|
-
OAuth2.apply(config, _request)
|
129
|
-
_response = execute_request(_request)
|
130
|
-
|
131
|
-
# Return appropriate response type.
|
132
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
133
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
134
|
-
ApiResponse.new(_response, data: decoded, errors: _errors)
|
135
|
-
end
|
136
|
-
|
137
|
-
# Provides comprehensive information for a single online store order,
|
138
|
-
# including the order's history.
|
139
|
-
# @param [String] location_id Required parameter: The ID of the order's
|
140
|
-
# associated location.
|
141
|
-
# @param [String] order_id Required parameter: The order's Square-issued ID.
|
142
|
-
# You obtain this value from Order objects returned by the List Orders
|
143
|
-
# endpoint
|
144
|
-
# @return [V1Order Hash] response from the API call
|
145
|
-
def retrieve_order(location_id:,
|
146
|
-
order_id:)
|
147
|
-
# Prepare query url.
|
148
|
-
_query_builder = config.get_base_uri
|
149
|
-
_query_builder << '/v1/{location_id}/orders/{order_id}'
|
150
|
-
_query_builder = APIHelper.append_url_with_template_parameters(
|
151
|
-
_query_builder,
|
152
|
-
'location_id' => location_id,
|
153
|
-
'order_id' => order_id
|
154
|
-
)
|
155
|
-
_query_url = APIHelper.clean_url _query_builder
|
156
|
-
|
157
|
-
# Prepare headers.
|
158
|
-
_headers = {
|
159
|
-
'accept' => 'application/json'
|
160
|
-
}
|
161
|
-
|
162
|
-
# Prepare and execute HttpRequest.
|
163
|
-
_request = config.http_client.get(
|
164
|
-
_query_url,
|
165
|
-
headers: _headers
|
166
|
-
)
|
167
|
-
OAuth2.apply(config, _request)
|
168
|
-
_response = execute_request(_request)
|
169
|
-
|
170
|
-
# Return appropriate response type.
|
171
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
172
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
173
|
-
ApiResponse.new(_response, data: decoded, errors: _errors)
|
174
|
-
end
|
175
|
-
|
176
|
-
# Updates the details of an online store order. Every update you perform on
|
177
|
-
# an order corresponds to one of three actions:
|
178
|
-
# @param [String] location_id Required parameter: The ID of the order's
|
179
|
-
# associated location.
|
180
|
-
# @param [String] order_id Required parameter: The order's Square-issued ID.
|
181
|
-
# You obtain this value from Order objects returned by the List Orders
|
182
|
-
# endpoint
|
183
|
-
# @param [V1UpdateOrderRequest] body Required parameter: An object
|
184
|
-
# containing the fields to POST for the request. See the corresponding
|
185
|
-
# object definition for field details.
|
186
|
-
# @return [V1Order Hash] response from the API call
|
187
|
-
def update_order(location_id:,
|
188
|
-
order_id:,
|
189
|
-
body:)
|
190
|
-
# Prepare query url.
|
191
|
-
_query_builder = config.get_base_uri
|
192
|
-
_query_builder << '/v1/{location_id}/orders/{order_id}'
|
193
|
-
_query_builder = APIHelper.append_url_with_template_parameters(
|
194
|
-
_query_builder,
|
195
|
-
'location_id' => location_id,
|
196
|
-
'order_id' => order_id
|
197
|
-
)
|
198
|
-
_query_url = APIHelper.clean_url _query_builder
|
199
|
-
|
200
|
-
# Prepare headers.
|
201
|
-
_headers = {
|
202
|
-
'accept' => 'application/json',
|
203
|
-
'content-type' => 'application/json; charset=utf-8'
|
204
|
-
}
|
205
|
-
|
206
|
-
# Prepare and execute HttpRequest.
|
207
|
-
_request = config.http_client.put(
|
208
|
-
_query_url,
|
209
|
-
headers: _headers,
|
210
|
-
parameters: body.to_json
|
211
|
-
)
|
212
|
-
OAuth2.apply(config, _request)
|
213
|
-
_response = execute_request(_request)
|
214
|
-
|
215
|
-
# Return appropriate response type.
|
216
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
217
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
218
|
-
ApiResponse.new(_response, data: decoded, errors: _errors)
|
219
|
-
end
|
220
|
-
|
221
|
-
# Provides summary information for all payments taken for a given
|
222
|
-
# Square account during a date range. Date ranges cannot exceed 1 year in
|
223
|
-
# length. See Date ranges for details of inclusive and exclusive dates.
|
224
|
-
# *Note**: Details for payments processed with Square Point of Sale while
|
225
|
-
# in offline mode may not be transmitted to Square for up to 72 hours.
|
226
|
-
# Offline payments have a `created_at` value that reflects the time the
|
227
|
-
# payment was originally processed, not the time it was subsequently
|
228
|
-
# transmitted to Square. Consequently, the ListPayments endpoint might
|
229
|
-
# list an offline payment chronologically between online payments that
|
230
|
-
# were seen in a previous request.
|
231
|
-
# @param [String] location_id Required parameter: The ID of the location to
|
232
|
-
# list payments for. If you specify me, this endpoint returns payments
|
233
|
-
# aggregated from all of the business's locations.
|
234
|
-
# @param [SortOrder] order Optional parameter: The order in which payments
|
235
|
-
# are listed in the response.
|
236
|
-
# @param [String] begin_time Optional parameter: The beginning of the
|
237
|
-
# requested reporting period, in ISO 8601 format. If this value is before
|
238
|
-
# January 1, 2013 (2013-01-01T00:00:00Z), this endpoint returns an error.
|
239
|
-
# Default value: The current time minus one year.
|
240
|
-
# @param [String] end_time Optional parameter: The end of the requested
|
241
|
-
# reporting period, in ISO 8601 format. If this value is more than one year
|
242
|
-
# greater than begin_time, this endpoint returns an error. Default value:
|
243
|
-
# The current time.
|
244
|
-
# @param [Integer] limit Optional parameter: The maximum number of payments
|
245
|
-
# to return in a single response. This value cannot exceed 200.
|
246
|
-
# @param [String] batch_token Optional parameter: A pagination cursor to
|
247
|
-
# retrieve the next set of results for your original query to the
|
248
|
-
# endpoint.
|
249
|
-
# @param [Boolean] include_partial Optional parameter: Indicates whether or
|
250
|
-
# not to include partial payments in the response. Partial payments will
|
251
|
-
# have the tenders collected so far, but the itemizations will be empty
|
252
|
-
# until the payment is completed.
|
253
|
-
# @return [List of V1Payment Hash] response from the API call
|
254
|
-
def list_payments(location_id:,
|
255
|
-
order: nil,
|
256
|
-
begin_time: nil,
|
257
|
-
end_time: nil,
|
258
|
-
limit: nil,
|
259
|
-
batch_token: nil,
|
260
|
-
include_partial: nil)
|
261
|
-
# Prepare query url.
|
262
|
-
_query_builder = config.get_base_uri
|
263
|
-
_query_builder << '/v1/{location_id}/payments'
|
264
|
-
_query_builder = APIHelper.append_url_with_template_parameters(
|
265
|
-
_query_builder,
|
266
|
-
'location_id' => location_id
|
267
|
-
)
|
268
|
-
_query_builder = APIHelper.append_url_with_query_parameters(
|
269
|
-
_query_builder,
|
270
|
-
'order' => order,
|
271
|
-
'begin_time' => begin_time,
|
272
|
-
'end_time' => end_time,
|
273
|
-
'limit' => limit,
|
274
|
-
'batch_token' => batch_token,
|
275
|
-
'include_partial' => include_partial
|
276
|
-
)
|
277
|
-
_query_url = APIHelper.clean_url _query_builder
|
278
|
-
|
279
|
-
# Prepare headers.
|
280
|
-
_headers = {
|
281
|
-
'accept' => 'application/json'
|
282
|
-
}
|
283
|
-
|
284
|
-
# Prepare and execute HttpRequest.
|
285
|
-
_request = config.http_client.get(
|
286
|
-
_query_url,
|
287
|
-
headers: _headers
|
288
|
-
)
|
289
|
-
OAuth2.apply(config, _request)
|
290
|
-
_response = execute_request(_request)
|
291
|
-
|
292
|
-
# Return appropriate response type.
|
293
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
294
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
295
|
-
ApiResponse.new(_response, data: decoded, errors: _errors)
|
296
|
-
end
|
297
|
-
|
298
|
-
# Provides comprehensive information for a single payment.
|
299
|
-
# @param [String] location_id Required parameter: The ID of the payment's
|
300
|
-
# associated location.
|
301
|
-
# @param [String] payment_id Required parameter: The Square-issued payment
|
302
|
-
# ID. payment_id comes from Payment objects returned by the List Payments
|
303
|
-
# endpoint, Settlement objects returned by the List Settlements endpoint, or
|
304
|
-
# Refund objects returned by the List Refunds endpoint.
|
305
|
-
# @return [V1Payment Hash] response from the API call
|
306
|
-
def retrieve_payment(location_id:,
|
307
|
-
payment_id:)
|
308
|
-
# Prepare query url.
|
309
|
-
_query_builder = config.get_base_uri
|
310
|
-
_query_builder << '/v1/{location_id}/payments/{payment_id}'
|
311
|
-
_query_builder = APIHelper.append_url_with_template_parameters(
|
312
|
-
_query_builder,
|
313
|
-
'location_id' => location_id,
|
314
|
-
'payment_id' => payment_id
|
315
|
-
)
|
316
|
-
_query_url = APIHelper.clean_url _query_builder
|
317
|
-
|
318
|
-
# Prepare headers.
|
319
|
-
_headers = {
|
320
|
-
'accept' => 'application/json'
|
321
|
-
}
|
322
|
-
|
323
|
-
# Prepare and execute HttpRequest.
|
324
|
-
_request = config.http_client.get(
|
325
|
-
_query_url,
|
326
|
-
headers: _headers
|
327
|
-
)
|
328
|
-
OAuth2.apply(config, _request)
|
329
|
-
_response = execute_request(_request)
|
330
|
-
|
331
|
-
# Return appropriate response type.
|
332
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
333
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
334
|
-
ApiResponse.new(_response, data: decoded, errors: _errors)
|
335
|
-
end
|
336
|
-
|
337
|
-
# Provides the details for all refunds initiated by a merchant or any of the
|
338
|
-
# merchant's mobile staff during a date range. Date ranges cannot exceed one
|
339
|
-
# year in length.
|
340
|
-
# @param [String] location_id Required parameter: The ID of the location to
|
341
|
-
# list refunds for.
|
342
|
-
# @param [SortOrder] order Optional parameter: TThe order in which payments
|
343
|
-
# are listed in the response.
|
344
|
-
# @param [String] begin_time Optional parameter: The beginning of the
|
345
|
-
# requested reporting period, in ISO 8601 format. If this value is before
|
346
|
-
# January 1, 2013 (2013-01-01T00:00:00Z), this endpoint returns an error.
|
347
|
-
# Default value: The current time minus one year.
|
348
|
-
# @param [String] end_time Optional parameter: The end of the requested
|
349
|
-
# reporting period, in ISO 8601 format. If this value is more than one year
|
350
|
-
# greater than begin_time, this endpoint returns an error. Default value:
|
351
|
-
# The current time.
|
352
|
-
# @param [Integer] limit Optional parameter: The approximate number of
|
353
|
-
# refunds to return in a single response. Default: 100. Max: 200. Response
|
354
|
-
# may contain more results than the prescribed limit when refunds are made
|
355
|
-
# simultaneously to multiple tenders in a payment or when refunds are
|
356
|
-
# generated in an exchange to account for the value of returned goods.
|
357
|
-
# @param [String] batch_token Optional parameter: A pagination cursor to
|
358
|
-
# retrieve the next set of results for your original query to the
|
359
|
-
# endpoint.
|
360
|
-
# @return [List of V1Refund Hash] response from the API call
|
361
|
-
def list_refunds(location_id:,
|
362
|
-
order: nil,
|
363
|
-
begin_time: nil,
|
364
|
-
end_time: nil,
|
365
|
-
limit: nil,
|
366
|
-
batch_token: nil)
|
367
|
-
# Prepare query url.
|
368
|
-
_query_builder = config.get_base_uri
|
369
|
-
_query_builder << '/v1/{location_id}/refunds'
|
370
|
-
_query_builder = APIHelper.append_url_with_template_parameters(
|
371
|
-
_query_builder,
|
372
|
-
'location_id' => location_id
|
373
|
-
)
|
374
|
-
_query_builder = APIHelper.append_url_with_query_parameters(
|
375
|
-
_query_builder,
|
376
|
-
'order' => order,
|
377
|
-
'begin_time' => begin_time,
|
378
|
-
'end_time' => end_time,
|
379
|
-
'limit' => limit,
|
380
|
-
'batch_token' => batch_token
|
381
|
-
)
|
382
|
-
_query_url = APIHelper.clean_url _query_builder
|
383
|
-
|
384
|
-
# Prepare headers.
|
385
|
-
_headers = {
|
386
|
-
'accept' => 'application/json'
|
387
|
-
}
|
388
|
-
|
389
|
-
# Prepare and execute HttpRequest.
|
390
|
-
_request = config.http_client.get(
|
391
|
-
_query_url,
|
392
|
-
headers: _headers
|
393
|
-
)
|
394
|
-
OAuth2.apply(config, _request)
|
395
|
-
_response = execute_request(_request)
|
396
|
-
|
397
|
-
# Return appropriate response type.
|
398
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
399
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
400
|
-
ApiResponse.new(_response, data: decoded, errors: _errors)
|
401
|
-
end
|
402
|
-
|
403
|
-
# Issues a refund for a previously processed payment. You must issue
|
404
|
-
# a refund within 60 days of the associated payment.
|
405
|
-
# You cannot issue a partial refund for a split tender payment. You must
|
406
|
-
# instead issue a full or partial refund for a particular tender, by
|
407
|
-
# providing the applicable tender id to the V1CreateRefund endpoint.
|
408
|
-
# Issuing a full refund for a split tender payment refunds all tenders
|
409
|
-
# associated with the payment.
|
410
|
-
# Issuing a refund for a card payment is not reversible. For development
|
411
|
-
# purposes, you can create fake cash payments in Square Point of Sale and
|
412
|
-
# refund them.
|
413
|
-
# @param [String] location_id Required parameter: The ID of the original
|
414
|
-
# payment's associated location.
|
415
|
-
# @param [V1CreateRefundRequest] body Required parameter: An object
|
416
|
-
# containing the fields to POST for the request. See the corresponding
|
417
|
-
# object definition for field details.
|
418
|
-
# @return [V1Refund Hash] response from the API call
|
419
|
-
def create_refund(location_id:,
|
420
|
-
body:)
|
421
|
-
# Prepare query url.
|
422
|
-
_query_builder = config.get_base_uri
|
423
|
-
_query_builder << '/v1/{location_id}/refunds'
|
424
|
-
_query_builder = APIHelper.append_url_with_template_parameters(
|
425
|
-
_query_builder,
|
426
|
-
'location_id' => location_id
|
427
|
-
)
|
428
|
-
_query_url = APIHelper.clean_url _query_builder
|
429
|
-
|
430
|
-
# Prepare headers.
|
431
|
-
_headers = {
|
432
|
-
'accept' => 'application/json',
|
433
|
-
'content-type' => 'application/json; charset=utf-8'
|
434
|
-
}
|
435
|
-
|
436
|
-
# Prepare and execute HttpRequest.
|
437
|
-
_request = config.http_client.post(
|
438
|
-
_query_url,
|
439
|
-
headers: _headers,
|
440
|
-
parameters: body.to_json
|
441
|
-
)
|
442
|
-
OAuth2.apply(config, _request)
|
443
|
-
_response = execute_request(_request)
|
444
|
-
|
445
|
-
# Return appropriate response type.
|
446
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
447
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
448
|
-
ApiResponse.new(_response, data: decoded, errors: _errors)
|
449
|
-
end
|
450
|
-
|
451
|
-
# Provides summary information for all deposits and withdrawals
|
452
|
-
# initiated by Square to a linked bank account during a date range. Date
|
453
|
-
# ranges cannot exceed one year in length.
|
454
|
-
# *Note**: the ListSettlements endpoint does not provide entry
|
455
|
-
# information.
|
456
|
-
# @param [String] location_id Required parameter: The ID of the location to
|
457
|
-
# list settlements for. If you specify me, this endpoint returns payments
|
458
|
-
# aggregated from all of the business's locations.
|
459
|
-
# @param [SortOrder] order Optional parameter: TThe order in which payments
|
460
|
-
# are listed in the response.
|
461
|
-
# @param [String] begin_time Optional parameter: The beginning of the
|
462
|
-
# requested reporting period, in ISO 8601 format. If this value is before
|
463
|
-
# January 1, 2013 (2013-01-01T00:00:00Z), this endpoint returns an error.
|
464
|
-
# Default value: The current time minus one year.
|
465
|
-
# @param [String] end_time Optional parameter: The end of the requested
|
466
|
-
# reporting period, in ISO 8601 format. If this value is more than one year
|
467
|
-
# greater than begin_time, this endpoint returns an error. Default value:
|
468
|
-
# The current time.
|
469
|
-
# @param [Integer] limit Optional parameter: The maximum number of payments
|
470
|
-
# to return in a single response. This value cannot exceed 200.
|
471
|
-
# @param [V1ListSettlementsRequestStatus] status Optional parameter: Provide
|
472
|
-
# this parameter to retrieve only settlements with a particular status (SENT
|
473
|
-
# or FAILED).
|
474
|
-
# @param [String] batch_token Optional parameter: A pagination cursor to
|
475
|
-
# retrieve the next set of results for your original query to the
|
476
|
-
# endpoint.
|
477
|
-
# @return [List of V1Settlement Hash] response from the API call
|
478
|
-
def list_settlements(location_id:,
|
479
|
-
order: nil,
|
480
|
-
begin_time: nil,
|
481
|
-
end_time: nil,
|
482
|
-
limit: nil,
|
483
|
-
status: nil,
|
484
|
-
batch_token: nil)
|
485
|
-
# Prepare query url.
|
486
|
-
_query_builder = config.get_base_uri
|
487
|
-
_query_builder << '/v1/{location_id}/settlements'
|
488
|
-
_query_builder = APIHelper.append_url_with_template_parameters(
|
489
|
-
_query_builder,
|
490
|
-
'location_id' => location_id
|
491
|
-
)
|
492
|
-
_query_builder = APIHelper.append_url_with_query_parameters(
|
493
|
-
_query_builder,
|
494
|
-
'order' => order,
|
495
|
-
'begin_time' => begin_time,
|
496
|
-
'end_time' => end_time,
|
497
|
-
'limit' => limit,
|
498
|
-
'status' => status,
|
499
|
-
'batch_token' => batch_token
|
500
|
-
)
|
501
|
-
_query_url = APIHelper.clean_url _query_builder
|
502
|
-
|
503
|
-
# Prepare headers.
|
504
|
-
_headers = {
|
505
|
-
'accept' => 'application/json'
|
506
|
-
}
|
507
|
-
|
508
|
-
# Prepare and execute HttpRequest.
|
509
|
-
_request = config.http_client.get(
|
510
|
-
_query_url,
|
511
|
-
headers: _headers
|
512
|
-
)
|
513
|
-
OAuth2.apply(config, _request)
|
514
|
-
_response = execute_request(_request)
|
515
|
-
|
516
|
-
# Return appropriate response type.
|
517
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
518
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
519
|
-
ApiResponse.new(_response, data: decoded, errors: _errors)
|
520
|
-
end
|
521
|
-
|
522
|
-
# Provides comprehensive information for a single settlement.
|
523
|
-
# The returned `Settlement` objects include an `entries` field that lists
|
524
|
-
# the transactions that contribute to the settlement total. Most
|
525
|
-
# settlement entries correspond to a payment payout, but settlement
|
526
|
-
# entries are also generated for less common events, like refunds, manual
|
527
|
-
# adjustments, or chargeback holds.
|
528
|
-
# Square initiates its regular deposits as indicated in the
|
529
|
-
# [Deposit Options with
|
530
|
-
# Square](https://squareup.com/help/us/en/article/3807)
|
531
|
-
# help article. Details for a regular deposit are usually not available
|
532
|
-
# from Connect API endpoints before 10 p.m. PST the same day.
|
533
|
-
# Square does not know when an initiated settlement **completes**, only
|
534
|
-
# whether it has failed. A completed settlement is typically reflected in
|
535
|
-
# a bank account within 3 business days, but in exceptional cases it may
|
536
|
-
# take longer.
|
537
|
-
# @param [String] location_id Required parameter: The ID of the
|
538
|
-
# settlements's associated location.
|
539
|
-
# @param [String] settlement_id Required parameter: The settlement's
|
540
|
-
# Square-issued ID. You obtain this value from Settlement objects returned
|
541
|
-
# by the List Settlements endpoint.
|
542
|
-
# @return [V1Settlement Hash] response from the API call
|
543
|
-
def retrieve_settlement(location_id:,
|
544
|
-
settlement_id:)
|
545
|
-
# Prepare query url.
|
546
|
-
_query_builder = config.get_base_uri
|
547
|
-
_query_builder << '/v1/{location_id}/settlements/{settlement_id}'
|
548
|
-
_query_builder = APIHelper.append_url_with_template_parameters(
|
549
|
-
_query_builder,
|
550
|
-
'location_id' => location_id,
|
551
|
-
'settlement_id' => settlement_id
|
552
|
-
)
|
553
|
-
_query_url = APIHelper.clean_url _query_builder
|
554
|
-
|
555
|
-
# Prepare headers.
|
556
|
-
_headers = {
|
557
|
-
'accept' => 'application/json'
|
558
|
-
}
|
559
|
-
|
560
|
-
# Prepare and execute HttpRequest.
|
561
|
-
_request = config.http_client.get(
|
562
|
-
_query_url,
|
563
|
-
headers: _headers
|
564
|
-
)
|
565
|
-
OAuth2.apply(config, _request)
|
566
|
-
_response = execute_request(_request)
|
567
|
-
|
568
|
-
# Return appropriate response type.
|
569
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
570
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
571
|
-
ApiResponse.new(_response, data: decoded, errors: _errors)
|
572
|
-
end
|
573
|
-
end
|
574
|
-
end
|
1
|
+
# square
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module Square
|
7
|
+
# V1TransactionsApi
|
8
|
+
class V1TransactionsApi < BaseApi
|
9
|
+
def initialize(config, http_call_back: nil)
|
10
|
+
super(config, http_call_back: http_call_back)
|
11
|
+
end
|
12
|
+
|
13
|
+
# Provides non-confidential details for all of a location's associated bank
|
14
|
+
# accounts. This endpoint does not provide full bank account numbers, and
|
15
|
+
# there is no way to obtain a full bank account number with the Connect API.
|
16
|
+
# @param [String] location_id Required parameter: The ID of the location to
|
17
|
+
# list bank accounts for.
|
18
|
+
# @return [List of V1BankAccount Hash] response from the API call
|
19
|
+
def list_bank_accounts(location_id:)
|
20
|
+
# Prepare query url.
|
21
|
+
_query_builder = config.get_base_uri
|
22
|
+
_query_builder << '/v1/{location_id}/bank-accounts'
|
23
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
24
|
+
_query_builder,
|
25
|
+
'location_id' => location_id
|
26
|
+
)
|
27
|
+
_query_url = APIHelper.clean_url _query_builder
|
28
|
+
|
29
|
+
# Prepare headers.
|
30
|
+
_headers = {
|
31
|
+
'accept' => 'application/json'
|
32
|
+
}
|
33
|
+
|
34
|
+
# Prepare and execute HttpRequest.
|
35
|
+
_request = config.http_client.get(
|
36
|
+
_query_url,
|
37
|
+
headers: _headers
|
38
|
+
)
|
39
|
+
OAuth2.apply(config, _request)
|
40
|
+
_response = execute_request(_request)
|
41
|
+
|
42
|
+
# Return appropriate response type.
|
43
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
44
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
45
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
46
|
+
end
|
47
|
+
|
48
|
+
# Provides non-confidential details for a merchant's associated bank
|
49
|
+
# account. This endpoint does not provide full bank account numbers, and
|
50
|
+
# there is no way to obtain a full bank account number with the Connect API.
|
51
|
+
# @param [String] location_id Required parameter: The ID of the bank
|
52
|
+
# account's associated location.
|
53
|
+
# @param [String] bank_account_id Required parameter: The bank account's
|
54
|
+
# Square-issued ID. You obtain this value from Settlement objects
|
55
|
+
# returned.
|
56
|
+
# @return [V1BankAccount Hash] response from the API call
|
57
|
+
def retrieve_bank_account(location_id:,
|
58
|
+
bank_account_id:)
|
59
|
+
# Prepare query url.
|
60
|
+
_query_builder = config.get_base_uri
|
61
|
+
_query_builder << '/v1/{location_id}/bank-accounts/{bank_account_id}'
|
62
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
63
|
+
_query_builder,
|
64
|
+
'location_id' => location_id,
|
65
|
+
'bank_account_id' => bank_account_id
|
66
|
+
)
|
67
|
+
_query_url = APIHelper.clean_url _query_builder
|
68
|
+
|
69
|
+
# Prepare headers.
|
70
|
+
_headers = {
|
71
|
+
'accept' => 'application/json'
|
72
|
+
}
|
73
|
+
|
74
|
+
# Prepare and execute HttpRequest.
|
75
|
+
_request = config.http_client.get(
|
76
|
+
_query_url,
|
77
|
+
headers: _headers
|
78
|
+
)
|
79
|
+
OAuth2.apply(config, _request)
|
80
|
+
_response = execute_request(_request)
|
81
|
+
|
82
|
+
# Return appropriate response type.
|
83
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
84
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
85
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
86
|
+
end
|
87
|
+
|
88
|
+
# Provides summary information for a merchant's online store orders.
|
89
|
+
# @param [String] location_id Required parameter: The ID of the location to
|
90
|
+
# list online store orders for.
|
91
|
+
# @param [SortOrder] order Optional parameter: TThe order in which payments
|
92
|
+
# are listed in the response.
|
93
|
+
# @param [Integer] limit Optional parameter: The maximum number of payments
|
94
|
+
# to return in a single response. This value cannot exceed 200.
|
95
|
+
# @param [String] batch_token Optional parameter: A pagination cursor to
|
96
|
+
# retrieve the next set of results for your original query to the
|
97
|
+
# endpoint.
|
98
|
+
# @return [List of V1Order Hash] response from the API call
|
99
|
+
def list_orders(location_id:,
|
100
|
+
order: nil,
|
101
|
+
limit: nil,
|
102
|
+
batch_token: nil)
|
103
|
+
# Prepare query url.
|
104
|
+
_query_builder = config.get_base_uri
|
105
|
+
_query_builder << '/v1/{location_id}/orders'
|
106
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
107
|
+
_query_builder,
|
108
|
+
'location_id' => location_id
|
109
|
+
)
|
110
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
111
|
+
_query_builder,
|
112
|
+
'order' => order,
|
113
|
+
'limit' => limit,
|
114
|
+
'batch_token' => batch_token
|
115
|
+
)
|
116
|
+
_query_url = APIHelper.clean_url _query_builder
|
117
|
+
|
118
|
+
# Prepare headers.
|
119
|
+
_headers = {
|
120
|
+
'accept' => 'application/json'
|
121
|
+
}
|
122
|
+
|
123
|
+
# Prepare and execute HttpRequest.
|
124
|
+
_request = config.http_client.get(
|
125
|
+
_query_url,
|
126
|
+
headers: _headers
|
127
|
+
)
|
128
|
+
OAuth2.apply(config, _request)
|
129
|
+
_response = execute_request(_request)
|
130
|
+
|
131
|
+
# Return appropriate response type.
|
132
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
133
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
134
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
135
|
+
end
|
136
|
+
|
137
|
+
# Provides comprehensive information for a single online store order,
|
138
|
+
# including the order's history.
|
139
|
+
# @param [String] location_id Required parameter: The ID of the order's
|
140
|
+
# associated location.
|
141
|
+
# @param [String] order_id Required parameter: The order's Square-issued ID.
|
142
|
+
# You obtain this value from Order objects returned by the List Orders
|
143
|
+
# endpoint
|
144
|
+
# @return [V1Order Hash] response from the API call
|
145
|
+
def retrieve_order(location_id:,
|
146
|
+
order_id:)
|
147
|
+
# Prepare query url.
|
148
|
+
_query_builder = config.get_base_uri
|
149
|
+
_query_builder << '/v1/{location_id}/orders/{order_id}'
|
150
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
151
|
+
_query_builder,
|
152
|
+
'location_id' => location_id,
|
153
|
+
'order_id' => order_id
|
154
|
+
)
|
155
|
+
_query_url = APIHelper.clean_url _query_builder
|
156
|
+
|
157
|
+
# Prepare headers.
|
158
|
+
_headers = {
|
159
|
+
'accept' => 'application/json'
|
160
|
+
}
|
161
|
+
|
162
|
+
# Prepare and execute HttpRequest.
|
163
|
+
_request = config.http_client.get(
|
164
|
+
_query_url,
|
165
|
+
headers: _headers
|
166
|
+
)
|
167
|
+
OAuth2.apply(config, _request)
|
168
|
+
_response = execute_request(_request)
|
169
|
+
|
170
|
+
# Return appropriate response type.
|
171
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
172
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
173
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
174
|
+
end
|
175
|
+
|
176
|
+
# Updates the details of an online store order. Every update you perform on
|
177
|
+
# an order corresponds to one of three actions:
|
178
|
+
# @param [String] location_id Required parameter: The ID of the order's
|
179
|
+
# associated location.
|
180
|
+
# @param [String] order_id Required parameter: The order's Square-issued ID.
|
181
|
+
# You obtain this value from Order objects returned by the List Orders
|
182
|
+
# endpoint
|
183
|
+
# @param [V1UpdateOrderRequest] body Required parameter: An object
|
184
|
+
# containing the fields to POST for the request. See the corresponding
|
185
|
+
# object definition for field details.
|
186
|
+
# @return [V1Order Hash] response from the API call
|
187
|
+
def update_order(location_id:,
|
188
|
+
order_id:,
|
189
|
+
body:)
|
190
|
+
# Prepare query url.
|
191
|
+
_query_builder = config.get_base_uri
|
192
|
+
_query_builder << '/v1/{location_id}/orders/{order_id}'
|
193
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
194
|
+
_query_builder,
|
195
|
+
'location_id' => location_id,
|
196
|
+
'order_id' => order_id
|
197
|
+
)
|
198
|
+
_query_url = APIHelper.clean_url _query_builder
|
199
|
+
|
200
|
+
# Prepare headers.
|
201
|
+
_headers = {
|
202
|
+
'accept' => 'application/json',
|
203
|
+
'content-type' => 'application/json; charset=utf-8'
|
204
|
+
}
|
205
|
+
|
206
|
+
# Prepare and execute HttpRequest.
|
207
|
+
_request = config.http_client.put(
|
208
|
+
_query_url,
|
209
|
+
headers: _headers,
|
210
|
+
parameters: body.to_json
|
211
|
+
)
|
212
|
+
OAuth2.apply(config, _request)
|
213
|
+
_response = execute_request(_request)
|
214
|
+
|
215
|
+
# Return appropriate response type.
|
216
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
217
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
218
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
219
|
+
end
|
220
|
+
|
221
|
+
# Provides summary information for all payments taken for a given
|
222
|
+
# Square account during a date range. Date ranges cannot exceed 1 year in
|
223
|
+
# length. See Date ranges for details of inclusive and exclusive dates.
|
224
|
+
# *Note**: Details for payments processed with Square Point of Sale while
|
225
|
+
# in offline mode may not be transmitted to Square for up to 72 hours.
|
226
|
+
# Offline payments have a `created_at` value that reflects the time the
|
227
|
+
# payment was originally processed, not the time it was subsequently
|
228
|
+
# transmitted to Square. Consequently, the ListPayments endpoint might
|
229
|
+
# list an offline payment chronologically between online payments that
|
230
|
+
# were seen in a previous request.
|
231
|
+
# @param [String] location_id Required parameter: The ID of the location to
|
232
|
+
# list payments for. If you specify me, this endpoint returns payments
|
233
|
+
# aggregated from all of the business's locations.
|
234
|
+
# @param [SortOrder] order Optional parameter: The order in which payments
|
235
|
+
# are listed in the response.
|
236
|
+
# @param [String] begin_time Optional parameter: The beginning of the
|
237
|
+
# requested reporting period, in ISO 8601 format. If this value is before
|
238
|
+
# January 1, 2013 (2013-01-01T00:00:00Z), this endpoint returns an error.
|
239
|
+
# Default value: The current time minus one year.
|
240
|
+
# @param [String] end_time Optional parameter: The end of the requested
|
241
|
+
# reporting period, in ISO 8601 format. If this value is more than one year
|
242
|
+
# greater than begin_time, this endpoint returns an error. Default value:
|
243
|
+
# The current time.
|
244
|
+
# @param [Integer] limit Optional parameter: The maximum number of payments
|
245
|
+
# to return in a single response. This value cannot exceed 200.
|
246
|
+
# @param [String] batch_token Optional parameter: A pagination cursor to
|
247
|
+
# retrieve the next set of results for your original query to the
|
248
|
+
# endpoint.
|
249
|
+
# @param [Boolean] include_partial Optional parameter: Indicates whether or
|
250
|
+
# not to include partial payments in the response. Partial payments will
|
251
|
+
# have the tenders collected so far, but the itemizations will be empty
|
252
|
+
# until the payment is completed.
|
253
|
+
# @return [List of V1Payment Hash] response from the API call
|
254
|
+
def list_payments(location_id:,
|
255
|
+
order: nil,
|
256
|
+
begin_time: nil,
|
257
|
+
end_time: nil,
|
258
|
+
limit: nil,
|
259
|
+
batch_token: nil,
|
260
|
+
include_partial: nil)
|
261
|
+
# Prepare query url.
|
262
|
+
_query_builder = config.get_base_uri
|
263
|
+
_query_builder << '/v1/{location_id}/payments'
|
264
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
265
|
+
_query_builder,
|
266
|
+
'location_id' => location_id
|
267
|
+
)
|
268
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
269
|
+
_query_builder,
|
270
|
+
'order' => order,
|
271
|
+
'begin_time' => begin_time,
|
272
|
+
'end_time' => end_time,
|
273
|
+
'limit' => limit,
|
274
|
+
'batch_token' => batch_token,
|
275
|
+
'include_partial' => include_partial
|
276
|
+
)
|
277
|
+
_query_url = APIHelper.clean_url _query_builder
|
278
|
+
|
279
|
+
# Prepare headers.
|
280
|
+
_headers = {
|
281
|
+
'accept' => 'application/json'
|
282
|
+
}
|
283
|
+
|
284
|
+
# Prepare and execute HttpRequest.
|
285
|
+
_request = config.http_client.get(
|
286
|
+
_query_url,
|
287
|
+
headers: _headers
|
288
|
+
)
|
289
|
+
OAuth2.apply(config, _request)
|
290
|
+
_response = execute_request(_request)
|
291
|
+
|
292
|
+
# Return appropriate response type.
|
293
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
294
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
295
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
296
|
+
end
|
297
|
+
|
298
|
+
# Provides comprehensive information for a single payment.
|
299
|
+
# @param [String] location_id Required parameter: The ID of the payment's
|
300
|
+
# associated location.
|
301
|
+
# @param [String] payment_id Required parameter: The Square-issued payment
|
302
|
+
# ID. payment_id comes from Payment objects returned by the List Payments
|
303
|
+
# endpoint, Settlement objects returned by the List Settlements endpoint, or
|
304
|
+
# Refund objects returned by the List Refunds endpoint.
|
305
|
+
# @return [V1Payment Hash] response from the API call
|
306
|
+
def retrieve_payment(location_id:,
|
307
|
+
payment_id:)
|
308
|
+
# Prepare query url.
|
309
|
+
_query_builder = config.get_base_uri
|
310
|
+
_query_builder << '/v1/{location_id}/payments/{payment_id}'
|
311
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
312
|
+
_query_builder,
|
313
|
+
'location_id' => location_id,
|
314
|
+
'payment_id' => payment_id
|
315
|
+
)
|
316
|
+
_query_url = APIHelper.clean_url _query_builder
|
317
|
+
|
318
|
+
# Prepare headers.
|
319
|
+
_headers = {
|
320
|
+
'accept' => 'application/json'
|
321
|
+
}
|
322
|
+
|
323
|
+
# Prepare and execute HttpRequest.
|
324
|
+
_request = config.http_client.get(
|
325
|
+
_query_url,
|
326
|
+
headers: _headers
|
327
|
+
)
|
328
|
+
OAuth2.apply(config, _request)
|
329
|
+
_response = execute_request(_request)
|
330
|
+
|
331
|
+
# Return appropriate response type.
|
332
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
333
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
334
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
335
|
+
end
|
336
|
+
|
337
|
+
# Provides the details for all refunds initiated by a merchant or any of the
|
338
|
+
# merchant's mobile staff during a date range. Date ranges cannot exceed one
|
339
|
+
# year in length.
|
340
|
+
# @param [String] location_id Required parameter: The ID of the location to
|
341
|
+
# list refunds for.
|
342
|
+
# @param [SortOrder] order Optional parameter: TThe order in which payments
|
343
|
+
# are listed in the response.
|
344
|
+
# @param [String] begin_time Optional parameter: The beginning of the
|
345
|
+
# requested reporting period, in ISO 8601 format. If this value is before
|
346
|
+
# January 1, 2013 (2013-01-01T00:00:00Z), this endpoint returns an error.
|
347
|
+
# Default value: The current time minus one year.
|
348
|
+
# @param [String] end_time Optional parameter: The end of the requested
|
349
|
+
# reporting period, in ISO 8601 format. If this value is more than one year
|
350
|
+
# greater than begin_time, this endpoint returns an error. Default value:
|
351
|
+
# The current time.
|
352
|
+
# @param [Integer] limit Optional parameter: The approximate number of
|
353
|
+
# refunds to return in a single response. Default: 100. Max: 200. Response
|
354
|
+
# may contain more results than the prescribed limit when refunds are made
|
355
|
+
# simultaneously to multiple tenders in a payment or when refunds are
|
356
|
+
# generated in an exchange to account for the value of returned goods.
|
357
|
+
# @param [String] batch_token Optional parameter: A pagination cursor to
|
358
|
+
# retrieve the next set of results for your original query to the
|
359
|
+
# endpoint.
|
360
|
+
# @return [List of V1Refund Hash] response from the API call
|
361
|
+
def list_refunds(location_id:,
|
362
|
+
order: nil,
|
363
|
+
begin_time: nil,
|
364
|
+
end_time: nil,
|
365
|
+
limit: nil,
|
366
|
+
batch_token: nil)
|
367
|
+
# Prepare query url.
|
368
|
+
_query_builder = config.get_base_uri
|
369
|
+
_query_builder << '/v1/{location_id}/refunds'
|
370
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
371
|
+
_query_builder,
|
372
|
+
'location_id' => location_id
|
373
|
+
)
|
374
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
375
|
+
_query_builder,
|
376
|
+
'order' => order,
|
377
|
+
'begin_time' => begin_time,
|
378
|
+
'end_time' => end_time,
|
379
|
+
'limit' => limit,
|
380
|
+
'batch_token' => batch_token
|
381
|
+
)
|
382
|
+
_query_url = APIHelper.clean_url _query_builder
|
383
|
+
|
384
|
+
# Prepare headers.
|
385
|
+
_headers = {
|
386
|
+
'accept' => 'application/json'
|
387
|
+
}
|
388
|
+
|
389
|
+
# Prepare and execute HttpRequest.
|
390
|
+
_request = config.http_client.get(
|
391
|
+
_query_url,
|
392
|
+
headers: _headers
|
393
|
+
)
|
394
|
+
OAuth2.apply(config, _request)
|
395
|
+
_response = execute_request(_request)
|
396
|
+
|
397
|
+
# Return appropriate response type.
|
398
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
399
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
400
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
401
|
+
end
|
402
|
+
|
403
|
+
# Issues a refund for a previously processed payment. You must issue
|
404
|
+
# a refund within 60 days of the associated payment.
|
405
|
+
# You cannot issue a partial refund for a split tender payment. You must
|
406
|
+
# instead issue a full or partial refund for a particular tender, by
|
407
|
+
# providing the applicable tender id to the V1CreateRefund endpoint.
|
408
|
+
# Issuing a full refund for a split tender payment refunds all tenders
|
409
|
+
# associated with the payment.
|
410
|
+
# Issuing a refund for a card payment is not reversible. For development
|
411
|
+
# purposes, you can create fake cash payments in Square Point of Sale and
|
412
|
+
# refund them.
|
413
|
+
# @param [String] location_id Required parameter: The ID of the original
|
414
|
+
# payment's associated location.
|
415
|
+
# @param [V1CreateRefundRequest] body Required parameter: An object
|
416
|
+
# containing the fields to POST for the request. See the corresponding
|
417
|
+
# object definition for field details.
|
418
|
+
# @return [V1Refund Hash] response from the API call
|
419
|
+
def create_refund(location_id:,
|
420
|
+
body:)
|
421
|
+
# Prepare query url.
|
422
|
+
_query_builder = config.get_base_uri
|
423
|
+
_query_builder << '/v1/{location_id}/refunds'
|
424
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
425
|
+
_query_builder,
|
426
|
+
'location_id' => location_id
|
427
|
+
)
|
428
|
+
_query_url = APIHelper.clean_url _query_builder
|
429
|
+
|
430
|
+
# Prepare headers.
|
431
|
+
_headers = {
|
432
|
+
'accept' => 'application/json',
|
433
|
+
'content-type' => 'application/json; charset=utf-8'
|
434
|
+
}
|
435
|
+
|
436
|
+
# Prepare and execute HttpRequest.
|
437
|
+
_request = config.http_client.post(
|
438
|
+
_query_url,
|
439
|
+
headers: _headers,
|
440
|
+
parameters: body.to_json
|
441
|
+
)
|
442
|
+
OAuth2.apply(config, _request)
|
443
|
+
_response = execute_request(_request)
|
444
|
+
|
445
|
+
# Return appropriate response type.
|
446
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
447
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
448
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
449
|
+
end
|
450
|
+
|
451
|
+
# Provides summary information for all deposits and withdrawals
|
452
|
+
# initiated by Square to a linked bank account during a date range. Date
|
453
|
+
# ranges cannot exceed one year in length.
|
454
|
+
# *Note**: the ListSettlements endpoint does not provide entry
|
455
|
+
# information.
|
456
|
+
# @param [String] location_id Required parameter: The ID of the location to
|
457
|
+
# list settlements for. If you specify me, this endpoint returns payments
|
458
|
+
# aggregated from all of the business's locations.
|
459
|
+
# @param [SortOrder] order Optional parameter: TThe order in which payments
|
460
|
+
# are listed in the response.
|
461
|
+
# @param [String] begin_time Optional parameter: The beginning of the
|
462
|
+
# requested reporting period, in ISO 8601 format. If this value is before
|
463
|
+
# January 1, 2013 (2013-01-01T00:00:00Z), this endpoint returns an error.
|
464
|
+
# Default value: The current time minus one year.
|
465
|
+
# @param [String] end_time Optional parameter: The end of the requested
|
466
|
+
# reporting period, in ISO 8601 format. If this value is more than one year
|
467
|
+
# greater than begin_time, this endpoint returns an error. Default value:
|
468
|
+
# The current time.
|
469
|
+
# @param [Integer] limit Optional parameter: The maximum number of payments
|
470
|
+
# to return in a single response. This value cannot exceed 200.
|
471
|
+
# @param [V1ListSettlementsRequestStatus] status Optional parameter: Provide
|
472
|
+
# this parameter to retrieve only settlements with a particular status (SENT
|
473
|
+
# or FAILED).
|
474
|
+
# @param [String] batch_token Optional parameter: A pagination cursor to
|
475
|
+
# retrieve the next set of results for your original query to the
|
476
|
+
# endpoint.
|
477
|
+
# @return [List of V1Settlement Hash] response from the API call
|
478
|
+
def list_settlements(location_id:,
|
479
|
+
order: nil,
|
480
|
+
begin_time: nil,
|
481
|
+
end_time: nil,
|
482
|
+
limit: nil,
|
483
|
+
status: nil,
|
484
|
+
batch_token: nil)
|
485
|
+
# Prepare query url.
|
486
|
+
_query_builder = config.get_base_uri
|
487
|
+
_query_builder << '/v1/{location_id}/settlements'
|
488
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
489
|
+
_query_builder,
|
490
|
+
'location_id' => location_id
|
491
|
+
)
|
492
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
493
|
+
_query_builder,
|
494
|
+
'order' => order,
|
495
|
+
'begin_time' => begin_time,
|
496
|
+
'end_time' => end_time,
|
497
|
+
'limit' => limit,
|
498
|
+
'status' => status,
|
499
|
+
'batch_token' => batch_token
|
500
|
+
)
|
501
|
+
_query_url = APIHelper.clean_url _query_builder
|
502
|
+
|
503
|
+
# Prepare headers.
|
504
|
+
_headers = {
|
505
|
+
'accept' => 'application/json'
|
506
|
+
}
|
507
|
+
|
508
|
+
# Prepare and execute HttpRequest.
|
509
|
+
_request = config.http_client.get(
|
510
|
+
_query_url,
|
511
|
+
headers: _headers
|
512
|
+
)
|
513
|
+
OAuth2.apply(config, _request)
|
514
|
+
_response = execute_request(_request)
|
515
|
+
|
516
|
+
# Return appropriate response type.
|
517
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
518
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
519
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
520
|
+
end
|
521
|
+
|
522
|
+
# Provides comprehensive information for a single settlement.
|
523
|
+
# The returned `Settlement` objects include an `entries` field that lists
|
524
|
+
# the transactions that contribute to the settlement total. Most
|
525
|
+
# settlement entries correspond to a payment payout, but settlement
|
526
|
+
# entries are also generated for less common events, like refunds, manual
|
527
|
+
# adjustments, or chargeback holds.
|
528
|
+
# Square initiates its regular deposits as indicated in the
|
529
|
+
# [Deposit Options with
|
530
|
+
# Square](https://squareup.com/help/us/en/article/3807)
|
531
|
+
# help article. Details for a regular deposit are usually not available
|
532
|
+
# from Connect API endpoints before 10 p.m. PST the same day.
|
533
|
+
# Square does not know when an initiated settlement **completes**, only
|
534
|
+
# whether it has failed. A completed settlement is typically reflected in
|
535
|
+
# a bank account within 3 business days, but in exceptional cases it may
|
536
|
+
# take longer.
|
537
|
+
# @param [String] location_id Required parameter: The ID of the
|
538
|
+
# settlements's associated location.
|
539
|
+
# @param [String] settlement_id Required parameter: The settlement's
|
540
|
+
# Square-issued ID. You obtain this value from Settlement objects returned
|
541
|
+
# by the List Settlements endpoint.
|
542
|
+
# @return [V1Settlement Hash] response from the API call
|
543
|
+
def retrieve_settlement(location_id:,
|
544
|
+
settlement_id:)
|
545
|
+
# Prepare query url.
|
546
|
+
_query_builder = config.get_base_uri
|
547
|
+
_query_builder << '/v1/{location_id}/settlements/{settlement_id}'
|
548
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
549
|
+
_query_builder,
|
550
|
+
'location_id' => location_id,
|
551
|
+
'settlement_id' => settlement_id
|
552
|
+
)
|
553
|
+
_query_url = APIHelper.clean_url _query_builder
|
554
|
+
|
555
|
+
# Prepare headers.
|
556
|
+
_headers = {
|
557
|
+
'accept' => 'application/json'
|
558
|
+
}
|
559
|
+
|
560
|
+
# Prepare and execute HttpRequest.
|
561
|
+
_request = config.http_client.get(
|
562
|
+
_query_url,
|
563
|
+
headers: _headers
|
564
|
+
)
|
565
|
+
OAuth2.apply(config, _request)
|
566
|
+
_response = execute_request(_request)
|
567
|
+
|
568
|
+
# Return appropriate response type.
|
569
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
570
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
571
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
572
|
+
end
|
573
|
+
end
|
574
|
+
end
|