square.rb 3.20190814.0 → 3.20190925.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -2
- data/lib/square.rb +53 -52
- data/lib/square/api/apple_pay_api.rb +55 -55
- data/lib/square/api/base_api.rb +48 -45
- data/lib/square/api/catalog_api.rb +461 -461
- data/lib/square/api/checkout_api.rb +54 -54
- data/lib/square/api/customers_api.rb +335 -335
- data/lib/square/api/employees_api.rb +91 -91
- data/lib/square/api/inventory_api.rb +300 -300
- data/lib/square/api/labor_api.rb +558 -558
- data/lib/square/api/locations_api.rb +117 -45
- data/lib/square/api/merchants_api.rb +46 -0
- data/lib/square/api/mobile_authorization_api.rb +56 -56
- data/lib/square/api/o_auth_api.rb +168 -168
- data/lib/square/api/orders_api.rb +271 -269
- data/lib/square/api/payments_api.rb +282 -282
- data/lib/square/api/refunds_api.rb +149 -149
- data/lib/square/api/reporting_api.rb +145 -143
- data/lib/square/api/transactions_api.rb +379 -379
- 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_transactions_api.rb +574 -574
- data/lib/square/api_helper.rb +281 -281
- data/lib/square/client.rb +155 -139
- data/lib/square/configuration.rb +98 -88
- 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/test/api/test_labor_api.rb +74 -0
- metadata +4 -3
- data/lib/square/api/v1_locations_api.rbe +0 -67
@@ -1,379 +1,379 @@
|
|
1
|
-
# square
|
2
|
-
#
|
3
|
-
# This file was automatically generated by APIMATIC v2.0
|
4
|
-
# ( https://apimatic.io ).
|
5
|
-
|
6
|
-
module Square
|
7
|
-
# TransactionsApi
|
8
|
-
class TransactionsApi < BaseApi
|
9
|
-
def initialize(config, http_call_back: nil)
|
10
|
-
super(config, http_call_back: http_call_back)
|
11
|
-
end
|
12
|
-
|
13
|
-
# Lists refunds for one of a business's locations.
|
14
|
-
# Deprecated - recommend using [SearchOrders](#endpoint-orders-searchorders)
|
15
|
-
# In addition to full or partial tender refunds processed through Square
|
16
|
-
# APIs,
|
17
|
-
# refunds may result from itemized returns or exchanges through Square's
|
18
|
-
# Point of Sale applications.
|
19
|
-
# Refunds with a `status` of `PENDING` are not currently included in this
|
20
|
-
# endpoint's response.
|
21
|
-
# Max results per [page](#paginatingresults): 50
|
22
|
-
# @param [String] location_id Required parameter: The ID of the location to
|
23
|
-
# list refunds for.
|
24
|
-
# @param [String] begin_time Optional parameter: The beginning of the
|
25
|
-
# requested reporting period, in RFC 3339 format. See [Date
|
26
|
-
# ranges](#dateranges) for details on date inclusivity/exclusivity. Default
|
27
|
-
# value: The current time minus one year.
|
28
|
-
# @param [String] end_time Optional parameter: The end of the requested
|
29
|
-
# reporting period, in RFC 3339 format. See [Date ranges](#dateranges) for
|
30
|
-
# details on date inclusivity/exclusivity. Default value: The current
|
31
|
-
# time.
|
32
|
-
# @param [SortOrder] sort_order Optional parameter: The order in which
|
33
|
-
# results are listed in the response (`ASC` for oldest first, `DESC` for
|
34
|
-
# newest first). Default value: `DESC`
|
35
|
-
# @param [String] cursor Optional parameter: A pagination cursor returned by
|
36
|
-
# a previous call to this endpoint. Provide this to retrieve the next set of
|
37
|
-
# results for your original query. See
|
38
|
-
# [Pagination](https://developer.squareup.com/docs/basics/api101/pagination)
|
39
|
-
# for more information.
|
40
|
-
# @return [ListRefundsResponse Hash] response from the API call
|
41
|
-
def list_refunds(location_id:,
|
42
|
-
begin_time: nil,
|
43
|
-
end_time: nil,
|
44
|
-
sort_order: nil,
|
45
|
-
cursor: nil)
|
46
|
-
warn 'Endpoint list_refunds in TransactionsApi is deprecated'
|
47
|
-
# Prepare query url.
|
48
|
-
_query_builder = config.get_base_uri
|
49
|
-
_query_builder << '/v2/locations/{location_id}/refunds'
|
50
|
-
_query_builder = APIHelper.append_url_with_template_parameters(
|
51
|
-
_query_builder,
|
52
|
-
'location_id' => location_id
|
53
|
-
)
|
54
|
-
_query_builder = APIHelper.append_url_with_query_parameters(
|
55
|
-
_query_builder,
|
56
|
-
'begin_time' => begin_time,
|
57
|
-
'end_time' => end_time,
|
58
|
-
'sort_order' => sort_order,
|
59
|
-
'cursor' => cursor
|
60
|
-
)
|
61
|
-
_query_url = APIHelper.clean_url _query_builder
|
62
|
-
|
63
|
-
# Prepare headers.
|
64
|
-
_headers = {
|
65
|
-
'accept' => 'application/json'
|
66
|
-
}
|
67
|
-
|
68
|
-
# Prepare and execute HttpRequest.
|
69
|
-
_request = config.http_client.get(
|
70
|
-
_query_url,
|
71
|
-
headers: _headers
|
72
|
-
)
|
73
|
-
OAuth2.apply(config, _request)
|
74
|
-
_response = execute_request(_request)
|
75
|
-
|
76
|
-
# Return appropriate response type.
|
77
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
78
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
79
|
-
ApiResponse.new(_response, data: decoded, errors: _errors)
|
80
|
-
end
|
81
|
-
|
82
|
-
# Lists transactions for a particular location.
|
83
|
-
# Deprecated - recommend using [SearchOrders](#endpoint-orders-searchorders)
|
84
|
-
# Transactions include payment information from sales and exchanges and
|
85
|
-
# refund
|
86
|
-
# information from returns and exchanges.
|
87
|
-
# Max results per [page](#paginatingresults): 50
|
88
|
-
# @param [String] location_id Required parameter: The ID of the location to
|
89
|
-
# list transactions for.
|
90
|
-
# @param [String] begin_time Optional parameter: The beginning of the
|
91
|
-
# requested reporting period, in RFC 3339 format. See [Date
|
92
|
-
# ranges](#dateranges) for details on date inclusivity/exclusivity. Default
|
93
|
-
# value: The current time minus one year.
|
94
|
-
# @param [String] end_time Optional parameter: The end of the requested
|
95
|
-
# reporting period, in RFC 3339 format. See [Date ranges](#dateranges) for
|
96
|
-
# details on date inclusivity/exclusivity. Default value: The current
|
97
|
-
# time.
|
98
|
-
# @param [SortOrder] sort_order Optional parameter: The order in which
|
99
|
-
# results are listed in the response (`ASC` for oldest first, `DESC` for
|
100
|
-
# newest first). Default value: `DESC`
|
101
|
-
# @param [String] cursor Optional parameter: A pagination cursor returned by
|
102
|
-
# a previous call to this endpoint. Provide this to retrieve the next set of
|
103
|
-
# results for your original query. See
|
104
|
-
# [Pagination](https://developer.squareup.com/docs/basics/api101/pagination)
|
105
|
-
# for more information.
|
106
|
-
# @return [ListTransactionsResponse Hash] response from the API call
|
107
|
-
def list_transactions(location_id:,
|
108
|
-
begin_time: nil,
|
109
|
-
end_time: nil,
|
110
|
-
sort_order: nil,
|
111
|
-
cursor: nil)
|
112
|
-
warn 'Endpoint list_transactions in TransactionsApi is deprecated'
|
113
|
-
# Prepare query url.
|
114
|
-
_query_builder = config.get_base_uri
|
115
|
-
_query_builder << '/v2/locations/{location_id}/transactions'
|
116
|
-
_query_builder = APIHelper.append_url_with_template_parameters(
|
117
|
-
_query_builder,
|
118
|
-
'location_id' => location_id
|
119
|
-
)
|
120
|
-
_query_builder = APIHelper.append_url_with_query_parameters(
|
121
|
-
_query_builder,
|
122
|
-
'begin_time' => begin_time,
|
123
|
-
'end_time' => end_time,
|
124
|
-
'sort_order' => sort_order,
|
125
|
-
'cursor' => cursor
|
126
|
-
)
|
127
|
-
_query_url = APIHelper.clean_url _query_builder
|
128
|
-
|
129
|
-
# Prepare headers.
|
130
|
-
_headers = {
|
131
|
-
'accept' => 'application/json'
|
132
|
-
}
|
133
|
-
|
134
|
-
# Prepare and execute HttpRequest.
|
135
|
-
_request = config.http_client.get(
|
136
|
-
_query_url,
|
137
|
-
headers: _headers
|
138
|
-
)
|
139
|
-
OAuth2.apply(config, _request)
|
140
|
-
_response = execute_request(_request)
|
141
|
-
|
142
|
-
# Return appropriate response type.
|
143
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
144
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
145
|
-
ApiResponse.new(_response, data: decoded, errors: _errors)
|
146
|
-
end
|
147
|
-
|
148
|
-
# Charges a card represented by a card nonce or a customer's card on file.
|
149
|
-
# Deprecated - recommend using
|
150
|
-
# [CreatePayment](#endpoint-payments-createpayment)
|
151
|
-
# Your request to this endpoint must include _either_:
|
152
|
-
# - A value for the `card_nonce` parameter (to charge a card nonce generated
|
153
|
-
# with the `SqPaymentForm`)
|
154
|
-
# - Values for the `customer_card_id` and `customer_id` parameters (to
|
155
|
-
# charge
|
156
|
-
# a customer's card on file)
|
157
|
-
# When this response is returned, the amount of Square's processing fee
|
158
|
-
# might not yet be
|
159
|
-
# calculated. To obtain the processing fee, wait about ten seconds and call
|
160
|
-
# [RetrieveTransaction](#endpoint-transactions-retrievetransaction). See the
|
161
|
-
# `processing_fee_money`
|
162
|
-
# field of each [Tender included](#type-tender) in the transaction.
|
163
|
-
# @param [String] location_id Required parameter: The ID of the location to
|
164
|
-
# associate the created transaction with.
|
165
|
-
# @param [ChargeRequest] body Required parameter: An object containing the
|
166
|
-
# fields to POST for the request. See the corresponding object definition
|
167
|
-
# for field details.
|
168
|
-
# @return [ChargeResponse Hash] response from the API call
|
169
|
-
def charge(location_id:,
|
170
|
-
body:)
|
171
|
-
warn 'Endpoint charge in TransactionsApi is deprecated'
|
172
|
-
# Prepare query url.
|
173
|
-
_query_builder = config.get_base_uri
|
174
|
-
_query_builder << '/v2/locations/{location_id}/transactions'
|
175
|
-
_query_builder = APIHelper.append_url_with_template_parameters(
|
176
|
-
_query_builder,
|
177
|
-
'location_id' => location_id
|
178
|
-
)
|
179
|
-
_query_url = APIHelper.clean_url _query_builder
|
180
|
-
|
181
|
-
# Prepare headers.
|
182
|
-
_headers = {
|
183
|
-
'accept' => 'application/json',
|
184
|
-
'content-type' => 'application/json; charset=utf-8'
|
185
|
-
}
|
186
|
-
|
187
|
-
# Prepare and execute HttpRequest.
|
188
|
-
_request = config.http_client.post(
|
189
|
-
_query_url,
|
190
|
-
headers: _headers,
|
191
|
-
parameters: body.to_json
|
192
|
-
)
|
193
|
-
OAuth2.apply(config, _request)
|
194
|
-
_response = execute_request(_request)
|
195
|
-
|
196
|
-
# Return appropriate response type.
|
197
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
198
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
199
|
-
ApiResponse.new(_response, data: decoded, errors: _errors)
|
200
|
-
end
|
201
|
-
|
202
|
-
# Retrieves details for a single transaction.
|
203
|
-
# Deprecated - recommend using
|
204
|
-
# [BatchRetrieveOrders](#endpoint-batchretrieveorders)
|
205
|
-
# @param [String] location_id Required parameter: The ID of the
|
206
|
-
# transaction's associated location.
|
207
|
-
# @param [String] transaction_id Required parameter: The ID of the
|
208
|
-
# transaction to retrieve.
|
209
|
-
# @return [RetrieveTransactionResponse Hash] response from the API call
|
210
|
-
def retrieve_transaction(location_id:,
|
211
|
-
transaction_id:)
|
212
|
-
warn 'Endpoint retrieve_transaction in TransactionsApi is deprecated'
|
213
|
-
# Prepare query url.
|
214
|
-
_query_builder = config.get_base_uri
|
215
|
-
_query_builder << '/v2/locations/{location_id}/transactions/{transaction_id}'
|
216
|
-
_query_builder = APIHelper.append_url_with_template_parameters(
|
217
|
-
_query_builder,
|
218
|
-
'location_id' => location_id,
|
219
|
-
'transaction_id' => transaction_id
|
220
|
-
)
|
221
|
-
_query_url = APIHelper.clean_url _query_builder
|
222
|
-
|
223
|
-
# Prepare headers.
|
224
|
-
_headers = {
|
225
|
-
'accept' => 'application/json'
|
226
|
-
}
|
227
|
-
|
228
|
-
# Prepare and execute HttpRequest.
|
229
|
-
_request = config.http_client.get(
|
230
|
-
_query_url,
|
231
|
-
headers: _headers
|
232
|
-
)
|
233
|
-
OAuth2.apply(config, _request)
|
234
|
-
_response = execute_request(_request)
|
235
|
-
|
236
|
-
# Return appropriate response type.
|
237
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
238
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
239
|
-
ApiResponse.new(_response, data: decoded, errors: _errors)
|
240
|
-
end
|
241
|
-
|
242
|
-
# Captures a transaction that was created with the
|
243
|
-
# [Charge](#endpoint-transactions-charge)
|
244
|
-
# endpoint with a `delay_capture` value of `true`.
|
245
|
-
# See the [Delay Capture of
|
246
|
-
# Funds](https://developer.squareup.com/docs/transactions-api/cookbook/delay
|
247
|
-
# -capture)
|
248
|
-
# recipe for more information.
|
249
|
-
# @param [String] location_id Required parameter: Example:
|
250
|
-
# @param [String] transaction_id Required parameter: Example:
|
251
|
-
# @return [CaptureTransactionResponse Hash] response from the API call
|
252
|
-
def capture_transaction(location_id:,
|
253
|
-
transaction_id:)
|
254
|
-
warn 'Endpoint capture_transaction in TransactionsApi is deprecated'
|
255
|
-
# Prepare query url.
|
256
|
-
_query_builder = config.get_base_uri
|
257
|
-
_query_builder << '/v2/locations/{location_id}/transactions/{transaction_id}/capture'
|
258
|
-
_query_builder = APIHelper.append_url_with_template_parameters(
|
259
|
-
_query_builder,
|
260
|
-
'location_id' => location_id,
|
261
|
-
'transaction_id' => transaction_id
|
262
|
-
)
|
263
|
-
_query_url = APIHelper.clean_url _query_builder
|
264
|
-
|
265
|
-
# Prepare headers.
|
266
|
-
_headers = {
|
267
|
-
'accept' => 'application/json'
|
268
|
-
}
|
269
|
-
|
270
|
-
# Prepare and execute HttpRequest.
|
271
|
-
_request = config.http_client.post(
|
272
|
-
_query_url,
|
273
|
-
headers: _headers
|
274
|
-
)
|
275
|
-
OAuth2.apply(config, _request)
|
276
|
-
_response = execute_request(_request)
|
277
|
-
|
278
|
-
# Return appropriate response type.
|
279
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
280
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
281
|
-
ApiResponse.new(_response, data: decoded, errors: _errors)
|
282
|
-
end
|
283
|
-
|
284
|
-
# Initiates a refund for a previously charged tender.
|
285
|
-
# Deprecated - recommend using
|
286
|
-
# [RefundPayment](#endpoint-refunds-refundpayment)
|
287
|
-
# You must issue a refund within 120 days of the associated payment. See
|
288
|
-
# [this article](https://squareup.com/help/us/en/article/5060) for more
|
289
|
-
# information
|
290
|
-
# on refund behavior.
|
291
|
-
# NOTE: Card-present transactions with Interac credit cards **cannot be
|
292
|
-
# refunded using the Connect API**. Interac transactions must refunded
|
293
|
-
# in-person (e.g., dipping the card using POS app).
|
294
|
-
# @param [String] location_id Required parameter: The ID of the original
|
295
|
-
# transaction's associated location.
|
296
|
-
# @param [String] transaction_id Required parameter: The ID of the original
|
297
|
-
# transaction that includes the tender to refund.
|
298
|
-
# @param [CreateRefundRequest] body Required parameter: An object containing
|
299
|
-
# the fields to POST for the request. See the corresponding object
|
300
|
-
# definition for field details.
|
301
|
-
# @return [CreateRefundResponse Hash] response from the API call
|
302
|
-
def create_refund(location_id:,
|
303
|
-
transaction_id:,
|
304
|
-
body:)
|
305
|
-
warn 'Endpoint create_refund in TransactionsApi is deprecated'
|
306
|
-
# Prepare query url.
|
307
|
-
_query_builder = config.get_base_uri
|
308
|
-
_query_builder << '/v2/locations/{location_id}/transactions/{transaction_id}/refund'
|
309
|
-
_query_builder = APIHelper.append_url_with_template_parameters(
|
310
|
-
_query_builder,
|
311
|
-
'location_id' => location_id,
|
312
|
-
'transaction_id' => transaction_id
|
313
|
-
)
|
314
|
-
_query_url = APIHelper.clean_url _query_builder
|
315
|
-
|
316
|
-
# Prepare headers.
|
317
|
-
_headers = {
|
318
|
-
'accept' => 'application/json',
|
319
|
-
'content-type' => 'application/json; charset=utf-8'
|
320
|
-
}
|
321
|
-
|
322
|
-
# Prepare and execute HttpRequest.
|
323
|
-
_request = config.http_client.post(
|
324
|
-
_query_url,
|
325
|
-
headers: _headers,
|
326
|
-
parameters: body.to_json
|
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
|
-
# Cancels a transaction that was created with the
|
338
|
-
# [Charge](#endpoint-transactions-charge)
|
339
|
-
# endpoint with a `delay_capture` value of `true`.
|
340
|
-
# See the [Delay Capture of
|
341
|
-
# Funds](https://developer.squareup.com/docs/transactions-api/cookbook/delay
|
342
|
-
# -capture)
|
343
|
-
# recipe for more information.
|
344
|
-
# @param [String] location_id Required parameter: Example:
|
345
|
-
# @param [String] transaction_id Required parameter: Example:
|
346
|
-
# @return [VoidTransactionResponse Hash] response from the API call
|
347
|
-
def void_transaction(location_id:,
|
348
|
-
transaction_id:)
|
349
|
-
warn 'Endpoint void_transaction in TransactionsApi is deprecated'
|
350
|
-
# Prepare query url.
|
351
|
-
_query_builder = config.get_base_uri
|
352
|
-
_query_builder << '/v2/locations/{location_id}/transactions/{transaction_id}/void'
|
353
|
-
_query_builder = APIHelper.append_url_with_template_parameters(
|
354
|
-
_query_builder,
|
355
|
-
'location_id' => location_id,
|
356
|
-
'transaction_id' => transaction_id
|
357
|
-
)
|
358
|
-
_query_url = APIHelper.clean_url _query_builder
|
359
|
-
|
360
|
-
# Prepare headers.
|
361
|
-
_headers = {
|
362
|
-
'accept' => 'application/json'
|
363
|
-
}
|
364
|
-
|
365
|
-
# Prepare and execute HttpRequest.
|
366
|
-
_request = config.http_client.post(
|
367
|
-
_query_url,
|
368
|
-
headers: _headers
|
369
|
-
)
|
370
|
-
OAuth2.apply(config, _request)
|
371
|
-
_response = execute_request(_request)
|
372
|
-
|
373
|
-
# Return appropriate response type.
|
374
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
375
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
376
|
-
ApiResponse.new(_response, data: decoded, errors: _errors)
|
377
|
-
end
|
378
|
-
end
|
379
|
-
end
|
1
|
+
# square
|
2
|
+
#
|
3
|
+
# This file was automatically generated by APIMATIC v2.0
|
4
|
+
# ( https://apimatic.io ).
|
5
|
+
|
6
|
+
module Square
|
7
|
+
# TransactionsApi
|
8
|
+
class TransactionsApi < BaseApi
|
9
|
+
def initialize(config, http_call_back: nil)
|
10
|
+
super(config, http_call_back: http_call_back)
|
11
|
+
end
|
12
|
+
|
13
|
+
# Lists refunds for one of a business's locations.
|
14
|
+
# Deprecated - recommend using [SearchOrders](#endpoint-orders-searchorders)
|
15
|
+
# In addition to full or partial tender refunds processed through Square
|
16
|
+
# APIs,
|
17
|
+
# refunds may result from itemized returns or exchanges through Square's
|
18
|
+
# Point of Sale applications.
|
19
|
+
# Refunds with a `status` of `PENDING` are not currently included in this
|
20
|
+
# endpoint's response.
|
21
|
+
# Max results per [page](#paginatingresults): 50
|
22
|
+
# @param [String] location_id Required parameter: The ID of the location to
|
23
|
+
# list refunds for.
|
24
|
+
# @param [String] begin_time Optional parameter: The beginning of the
|
25
|
+
# requested reporting period, in RFC 3339 format. See [Date
|
26
|
+
# ranges](#dateranges) for details on date inclusivity/exclusivity. Default
|
27
|
+
# value: The current time minus one year.
|
28
|
+
# @param [String] end_time Optional parameter: The end of the requested
|
29
|
+
# reporting period, in RFC 3339 format. See [Date ranges](#dateranges) for
|
30
|
+
# details on date inclusivity/exclusivity. Default value: The current
|
31
|
+
# time.
|
32
|
+
# @param [SortOrder] sort_order Optional parameter: The order in which
|
33
|
+
# results are listed in the response (`ASC` for oldest first, `DESC` for
|
34
|
+
# newest first). Default value: `DESC`
|
35
|
+
# @param [String] cursor Optional parameter: A pagination cursor returned by
|
36
|
+
# a previous call to this endpoint. Provide this to retrieve the next set of
|
37
|
+
# results for your original query. See
|
38
|
+
# [Pagination](https://developer.squareup.com/docs/basics/api101/pagination)
|
39
|
+
# for more information.
|
40
|
+
# @return [ListRefundsResponse Hash] response from the API call
|
41
|
+
def list_refunds(location_id:,
|
42
|
+
begin_time: nil,
|
43
|
+
end_time: nil,
|
44
|
+
sort_order: nil,
|
45
|
+
cursor: nil)
|
46
|
+
warn 'Endpoint list_refunds in TransactionsApi is deprecated'
|
47
|
+
# Prepare query url.
|
48
|
+
_query_builder = config.get_base_uri
|
49
|
+
_query_builder << '/v2/locations/{location_id}/refunds'
|
50
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
51
|
+
_query_builder,
|
52
|
+
'location_id' => location_id
|
53
|
+
)
|
54
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
55
|
+
_query_builder,
|
56
|
+
'begin_time' => begin_time,
|
57
|
+
'end_time' => end_time,
|
58
|
+
'sort_order' => sort_order,
|
59
|
+
'cursor' => cursor
|
60
|
+
)
|
61
|
+
_query_url = APIHelper.clean_url _query_builder
|
62
|
+
|
63
|
+
# Prepare headers.
|
64
|
+
_headers = {
|
65
|
+
'accept' => 'application/json'
|
66
|
+
}
|
67
|
+
|
68
|
+
# Prepare and execute HttpRequest.
|
69
|
+
_request = config.http_client.get(
|
70
|
+
_query_url,
|
71
|
+
headers: _headers
|
72
|
+
)
|
73
|
+
OAuth2.apply(config, _request)
|
74
|
+
_response = execute_request(_request)
|
75
|
+
|
76
|
+
# Return appropriate response type.
|
77
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
78
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
79
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
80
|
+
end
|
81
|
+
|
82
|
+
# Lists transactions for a particular location.
|
83
|
+
# Deprecated - recommend using [SearchOrders](#endpoint-orders-searchorders)
|
84
|
+
# Transactions include payment information from sales and exchanges and
|
85
|
+
# refund
|
86
|
+
# information from returns and exchanges.
|
87
|
+
# Max results per [page](#paginatingresults): 50
|
88
|
+
# @param [String] location_id Required parameter: The ID of the location to
|
89
|
+
# list transactions for.
|
90
|
+
# @param [String] begin_time Optional parameter: The beginning of the
|
91
|
+
# requested reporting period, in RFC 3339 format. See [Date
|
92
|
+
# ranges](#dateranges) for details on date inclusivity/exclusivity. Default
|
93
|
+
# value: The current time minus one year.
|
94
|
+
# @param [String] end_time Optional parameter: The end of the requested
|
95
|
+
# reporting period, in RFC 3339 format. See [Date ranges](#dateranges) for
|
96
|
+
# details on date inclusivity/exclusivity. Default value: The current
|
97
|
+
# time.
|
98
|
+
# @param [SortOrder] sort_order Optional parameter: The order in which
|
99
|
+
# results are listed in the response (`ASC` for oldest first, `DESC` for
|
100
|
+
# newest first). Default value: `DESC`
|
101
|
+
# @param [String] cursor Optional parameter: A pagination cursor returned by
|
102
|
+
# a previous call to this endpoint. Provide this to retrieve the next set of
|
103
|
+
# results for your original query. See
|
104
|
+
# [Pagination](https://developer.squareup.com/docs/basics/api101/pagination)
|
105
|
+
# for more information.
|
106
|
+
# @return [ListTransactionsResponse Hash] response from the API call
|
107
|
+
def list_transactions(location_id:,
|
108
|
+
begin_time: nil,
|
109
|
+
end_time: nil,
|
110
|
+
sort_order: nil,
|
111
|
+
cursor: nil)
|
112
|
+
warn 'Endpoint list_transactions in TransactionsApi is deprecated'
|
113
|
+
# Prepare query url.
|
114
|
+
_query_builder = config.get_base_uri
|
115
|
+
_query_builder << '/v2/locations/{location_id}/transactions'
|
116
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
117
|
+
_query_builder,
|
118
|
+
'location_id' => location_id
|
119
|
+
)
|
120
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
121
|
+
_query_builder,
|
122
|
+
'begin_time' => begin_time,
|
123
|
+
'end_time' => end_time,
|
124
|
+
'sort_order' => sort_order,
|
125
|
+
'cursor' => cursor
|
126
|
+
)
|
127
|
+
_query_url = APIHelper.clean_url _query_builder
|
128
|
+
|
129
|
+
# Prepare headers.
|
130
|
+
_headers = {
|
131
|
+
'accept' => 'application/json'
|
132
|
+
}
|
133
|
+
|
134
|
+
# Prepare and execute HttpRequest.
|
135
|
+
_request = config.http_client.get(
|
136
|
+
_query_url,
|
137
|
+
headers: _headers
|
138
|
+
)
|
139
|
+
OAuth2.apply(config, _request)
|
140
|
+
_response = execute_request(_request)
|
141
|
+
|
142
|
+
# Return appropriate response type.
|
143
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
144
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
145
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
146
|
+
end
|
147
|
+
|
148
|
+
# Charges a card represented by a card nonce or a customer's card on file.
|
149
|
+
# Deprecated - recommend using
|
150
|
+
# [CreatePayment](#endpoint-payments-createpayment)
|
151
|
+
# Your request to this endpoint must include _either_:
|
152
|
+
# - A value for the `card_nonce` parameter (to charge a card nonce generated
|
153
|
+
# with the `SqPaymentForm`)
|
154
|
+
# - Values for the `customer_card_id` and `customer_id` parameters (to
|
155
|
+
# charge
|
156
|
+
# a customer's card on file)
|
157
|
+
# When this response is returned, the amount of Square's processing fee
|
158
|
+
# might not yet be
|
159
|
+
# calculated. To obtain the processing fee, wait about ten seconds and call
|
160
|
+
# [RetrieveTransaction](#endpoint-transactions-retrievetransaction). See the
|
161
|
+
# `processing_fee_money`
|
162
|
+
# field of each [Tender included](#type-tender) in the transaction.
|
163
|
+
# @param [String] location_id Required parameter: The ID of the location to
|
164
|
+
# associate the created transaction with.
|
165
|
+
# @param [ChargeRequest] body Required parameter: An object containing the
|
166
|
+
# fields to POST for the request. See the corresponding object definition
|
167
|
+
# for field details.
|
168
|
+
# @return [ChargeResponse Hash] response from the API call
|
169
|
+
def charge(location_id:,
|
170
|
+
body:)
|
171
|
+
warn 'Endpoint charge in TransactionsApi is deprecated'
|
172
|
+
# Prepare query url.
|
173
|
+
_query_builder = config.get_base_uri
|
174
|
+
_query_builder << '/v2/locations/{location_id}/transactions'
|
175
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
176
|
+
_query_builder,
|
177
|
+
'location_id' => location_id
|
178
|
+
)
|
179
|
+
_query_url = APIHelper.clean_url _query_builder
|
180
|
+
|
181
|
+
# Prepare headers.
|
182
|
+
_headers = {
|
183
|
+
'accept' => 'application/json',
|
184
|
+
'content-type' => 'application/json; charset=utf-8'
|
185
|
+
}
|
186
|
+
|
187
|
+
# Prepare and execute HttpRequest.
|
188
|
+
_request = config.http_client.post(
|
189
|
+
_query_url,
|
190
|
+
headers: _headers,
|
191
|
+
parameters: body.to_json
|
192
|
+
)
|
193
|
+
OAuth2.apply(config, _request)
|
194
|
+
_response = execute_request(_request)
|
195
|
+
|
196
|
+
# Return appropriate response type.
|
197
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
198
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
199
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
200
|
+
end
|
201
|
+
|
202
|
+
# Retrieves details for a single transaction.
|
203
|
+
# Deprecated - recommend using
|
204
|
+
# [BatchRetrieveOrders](#endpoint-batchretrieveorders)
|
205
|
+
# @param [String] location_id Required parameter: The ID of the
|
206
|
+
# transaction's associated location.
|
207
|
+
# @param [String] transaction_id Required parameter: The ID of the
|
208
|
+
# transaction to retrieve.
|
209
|
+
# @return [RetrieveTransactionResponse Hash] response from the API call
|
210
|
+
def retrieve_transaction(location_id:,
|
211
|
+
transaction_id:)
|
212
|
+
warn 'Endpoint retrieve_transaction in TransactionsApi is deprecated'
|
213
|
+
# Prepare query url.
|
214
|
+
_query_builder = config.get_base_uri
|
215
|
+
_query_builder << '/v2/locations/{location_id}/transactions/{transaction_id}'
|
216
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
217
|
+
_query_builder,
|
218
|
+
'location_id' => location_id,
|
219
|
+
'transaction_id' => transaction_id
|
220
|
+
)
|
221
|
+
_query_url = APIHelper.clean_url _query_builder
|
222
|
+
|
223
|
+
# Prepare headers.
|
224
|
+
_headers = {
|
225
|
+
'accept' => 'application/json'
|
226
|
+
}
|
227
|
+
|
228
|
+
# Prepare and execute HttpRequest.
|
229
|
+
_request = config.http_client.get(
|
230
|
+
_query_url,
|
231
|
+
headers: _headers
|
232
|
+
)
|
233
|
+
OAuth2.apply(config, _request)
|
234
|
+
_response = execute_request(_request)
|
235
|
+
|
236
|
+
# Return appropriate response type.
|
237
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
238
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
239
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
240
|
+
end
|
241
|
+
|
242
|
+
# Captures a transaction that was created with the
|
243
|
+
# [Charge](#endpoint-transactions-charge)
|
244
|
+
# endpoint with a `delay_capture` value of `true`.
|
245
|
+
# See the [Delay Capture of
|
246
|
+
# Funds](https://developer.squareup.com/docs/transactions-api/cookbook/delay
|
247
|
+
# -capture)
|
248
|
+
# recipe for more information.
|
249
|
+
# @param [String] location_id Required parameter: Example:
|
250
|
+
# @param [String] transaction_id Required parameter: Example:
|
251
|
+
# @return [CaptureTransactionResponse Hash] response from the API call
|
252
|
+
def capture_transaction(location_id:,
|
253
|
+
transaction_id:)
|
254
|
+
warn 'Endpoint capture_transaction in TransactionsApi is deprecated'
|
255
|
+
# Prepare query url.
|
256
|
+
_query_builder = config.get_base_uri
|
257
|
+
_query_builder << '/v2/locations/{location_id}/transactions/{transaction_id}/capture'
|
258
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
259
|
+
_query_builder,
|
260
|
+
'location_id' => location_id,
|
261
|
+
'transaction_id' => transaction_id
|
262
|
+
)
|
263
|
+
_query_url = APIHelper.clean_url _query_builder
|
264
|
+
|
265
|
+
# Prepare headers.
|
266
|
+
_headers = {
|
267
|
+
'accept' => 'application/json'
|
268
|
+
}
|
269
|
+
|
270
|
+
# Prepare and execute HttpRequest.
|
271
|
+
_request = config.http_client.post(
|
272
|
+
_query_url,
|
273
|
+
headers: _headers
|
274
|
+
)
|
275
|
+
OAuth2.apply(config, _request)
|
276
|
+
_response = execute_request(_request)
|
277
|
+
|
278
|
+
# Return appropriate response type.
|
279
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
280
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
281
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
282
|
+
end
|
283
|
+
|
284
|
+
# Initiates a refund for a previously charged tender.
|
285
|
+
# Deprecated - recommend using
|
286
|
+
# [RefundPayment](#endpoint-refunds-refundpayment)
|
287
|
+
# You must issue a refund within 120 days of the associated payment. See
|
288
|
+
# [this article](https://squareup.com/help/us/en/article/5060) for more
|
289
|
+
# information
|
290
|
+
# on refund behavior.
|
291
|
+
# NOTE: Card-present transactions with Interac credit cards **cannot be
|
292
|
+
# refunded using the Connect API**. Interac transactions must refunded
|
293
|
+
# in-person (e.g., dipping the card using POS app).
|
294
|
+
# @param [String] location_id Required parameter: The ID of the original
|
295
|
+
# transaction's associated location.
|
296
|
+
# @param [String] transaction_id Required parameter: The ID of the original
|
297
|
+
# transaction that includes the tender to refund.
|
298
|
+
# @param [CreateRefundRequest] body Required parameter: An object containing
|
299
|
+
# the fields to POST for the request. See the corresponding object
|
300
|
+
# definition for field details.
|
301
|
+
# @return [CreateRefundResponse Hash] response from the API call
|
302
|
+
def create_refund(location_id:,
|
303
|
+
transaction_id:,
|
304
|
+
body:)
|
305
|
+
warn 'Endpoint create_refund in TransactionsApi is deprecated'
|
306
|
+
# Prepare query url.
|
307
|
+
_query_builder = config.get_base_uri
|
308
|
+
_query_builder << '/v2/locations/{location_id}/transactions/{transaction_id}/refund'
|
309
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
310
|
+
_query_builder,
|
311
|
+
'location_id' => location_id,
|
312
|
+
'transaction_id' => transaction_id
|
313
|
+
)
|
314
|
+
_query_url = APIHelper.clean_url _query_builder
|
315
|
+
|
316
|
+
# Prepare headers.
|
317
|
+
_headers = {
|
318
|
+
'accept' => 'application/json',
|
319
|
+
'content-type' => 'application/json; charset=utf-8'
|
320
|
+
}
|
321
|
+
|
322
|
+
# Prepare and execute HttpRequest.
|
323
|
+
_request = config.http_client.post(
|
324
|
+
_query_url,
|
325
|
+
headers: _headers,
|
326
|
+
parameters: body.to_json
|
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
|
+
# Cancels a transaction that was created with the
|
338
|
+
# [Charge](#endpoint-transactions-charge)
|
339
|
+
# endpoint with a `delay_capture` value of `true`.
|
340
|
+
# See the [Delay Capture of
|
341
|
+
# Funds](https://developer.squareup.com/docs/transactions-api/cookbook/delay
|
342
|
+
# -capture)
|
343
|
+
# recipe for more information.
|
344
|
+
# @param [String] location_id Required parameter: Example:
|
345
|
+
# @param [String] transaction_id Required parameter: Example:
|
346
|
+
# @return [VoidTransactionResponse Hash] response from the API call
|
347
|
+
def void_transaction(location_id:,
|
348
|
+
transaction_id:)
|
349
|
+
warn 'Endpoint void_transaction in TransactionsApi is deprecated'
|
350
|
+
# Prepare query url.
|
351
|
+
_query_builder = config.get_base_uri
|
352
|
+
_query_builder << '/v2/locations/{location_id}/transactions/{transaction_id}/void'
|
353
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
354
|
+
_query_builder,
|
355
|
+
'location_id' => location_id,
|
356
|
+
'transaction_id' => transaction_id
|
357
|
+
)
|
358
|
+
_query_url = APIHelper.clean_url _query_builder
|
359
|
+
|
360
|
+
# Prepare headers.
|
361
|
+
_headers = {
|
362
|
+
'accept' => 'application/json'
|
363
|
+
}
|
364
|
+
|
365
|
+
# Prepare and execute HttpRequest.
|
366
|
+
_request = config.http_client.post(
|
367
|
+
_query_url,
|
368
|
+
headers: _headers
|
369
|
+
)
|
370
|
+
OAuth2.apply(config, _request)
|
371
|
+
_response = execute_request(_request)
|
372
|
+
|
373
|
+
# Return appropriate response type.
|
374
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
375
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
376
|
+
ApiResponse.new(_response, data: decoded, errors: _errors)
|
377
|
+
end
|
378
|
+
end
|
379
|
+
end
|