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