square.rb 26.1.0.20230119 → 27.0.0.20230419
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -0
- data/lib/square/api/apple_pay_api.rb +14 -30
- data/lib/square/api/bank_accounts_api.rb +40 -90
- data/lib/square/api/base_api.rb +42 -42
- data/lib/square/api/booking_custom_attributes_api.rb +171 -336
- data/lib/square/api/bookings_api.rb +140 -263
- data/lib/square/api/cards_api.rb +58 -120
- data/lib/square/api/cash_drawers_api.rb +47 -103
- data/lib/square/api/catalog_api.rb +200 -426
- data/lib/square/api/checkout_api.rb +86 -176
- data/lib/square/api/customer_custom_attributes_api.rb +157 -310
- data/lib/square/api/customer_groups_api.rb +69 -145
- data/lib/square/api/customer_segments_api.rb +26 -61
- data/lib/square/api/customers_api.rb +147 -294
- data/lib/square/api/devices_api.rb +42 -89
- data/lib/square/api/disputes_api.rb +132 -290
- data/lib/square/api/employees_api.rb +28 -63
- data/lib/square/api/gift_card_activities_api.rb +34 -66
- data/lib/square/api/gift_cards_api.rb +109 -207
- data/lib/square/api/inventory_api.rb +204 -391
- data/lib/square/api/invoices_api.rb +121 -240
- data/lib/square/api/labor_api.rb +223 -459
- data/lib/square/api/location_custom_attributes_api.rb +173 -338
- data/lib/square/api/locations_api.rb +54 -112
- data/lib/square/api/loyalty_api.rb +283 -535
- data/lib/square/api/merchants_api.rb +25 -60
- data/lib/square/api/mobile_authorization_api.rb +14 -30
- data/lib/square/api/o_auth_api.rb +54 -109
- data/lib/square/api/order_custom_attributes_api.rb +174 -339
- data/lib/square/api/orders_api.rb +115 -222
- data/lib/square/api/payments_api.rb +118 -217
- data/lib/square/api/payouts_api.rb +54 -107
- data/lib/square/api/refunds_api.rb +59 -104
- data/lib/square/api/sites_api.rb +11 -28
- data/lib/square/api/snippets_api.rb +42 -90
- data/lib/square/api/subscriptions_api.rb +150 -299
- data/lib/square/api/team_api.rb +114 -224
- data/lib/square/api/terminal_api.rb +162 -328
- data/lib/square/api/transactions_api.rb +64 -128
- data/lib/square/api/v1_transactions_api.rb +155 -296
- data/lib/square/api/vendors_api.rb +100 -193
- data/lib/square/api/webhook_subscriptions_api.rb +124 -244
- data/lib/square/api_helper.rb +1 -437
- data/lib/square/client.rb +77 -47
- data/lib/square/configuration.rb +28 -53
- data/lib/square/exceptions/api_exception.rb +1 -11
- data/lib/square/http/api_response.rb +13 -19
- data/lib/square/http/auth/o_auth2.rb +14 -7
- data/lib/square/http/http_call_back.rb +1 -15
- data/lib/square/http/http_method_enum.rb +1 -4
- data/lib/square/http/http_request.rb +1 -45
- data/lib/square/http/http_response.rb +1 -20
- data/lib/square/utilities/date_time_helper.rb +1 -146
- data/lib/square/utilities/file_wrapper.rb +5 -5
- data/lib/square.rb +6 -6
- data/spec/user_journey_spec.rb +2 -2
- data/test/api/api_test_base.rb +13 -5
- data/test/api/test_catalog_api.rb +5 -4
- data/test/api/test_customers_api.rb +3 -2
- data/test/api/test_employees_api.rb +4 -3
- data/test/api/test_labor_api.rb +6 -5
- data/test/api/test_locations_api.rb +3 -2
- data/test/api/test_merchants_api.rb +4 -3
- data/test/api/test_payments_api.rb +4 -3
- data/test/api/test_refunds_api.rb +4 -3
- metadata +11 -111
- data/lib/square/exceptions/validation_exception.rb +0 -13
- data/lib/square/http/faraday_client.rb +0 -93
- data/lib/square/http/http_client.rb +0 -118
- data/test/test_helper.rb +0 -89
@@ -1,28 +1,27 @@
|
|
1
1
|
module Square
|
2
2
|
# PaymentsApi
|
3
3
|
class PaymentsApi < BaseApi
|
4
|
-
def initialize(config, http_call_back: nil)
|
5
|
-
super(config, http_call_back: http_call_back)
|
6
|
-
end
|
7
|
-
|
8
4
|
# Retrieves a list of payments taken by the account making the request.
|
9
5
|
# Results are eventually consistent, and new payments or changes to payments
|
10
6
|
# might take several
|
11
7
|
# seconds to appear.
|
12
8
|
# The maximum results per page is 100.
|
13
|
-
# @param [String] begin_time Optional parameter:
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
17
|
-
#
|
9
|
+
# @param [String] begin_time Optional parameter: Indicates the start of the
|
10
|
+
# time range to retrieve payments for, in RFC 3339 format. The range is
|
11
|
+
# determined using the `created_at` field for each Payment. Inclusive.
|
12
|
+
# Default: The current time minus one year.
|
13
|
+
# @param [String] end_time Optional parameter: Indicates the end of the time
|
14
|
+
# range to retrieve payments for, in RFC 3339 format. The range is
|
15
|
+
# determined using the `created_at` field for each Payment. Default: The
|
16
|
+
# current time.
|
18
17
|
# @param [String] sort_order Optional parameter: The order in which results
|
19
|
-
# are listed
|
20
|
-
# (default).
|
18
|
+
# are listed by `Payment.created_at`: - `ASC` - Oldest to newest. - `DESC` -
|
19
|
+
# Newest to oldest (default).
|
21
20
|
# @param [String] cursor Optional parameter: A pagination cursor returned by
|
22
21
|
# a previous call to this endpoint. Provide this cursor to retrieve the next
|
23
22
|
# set of results for the original query. For more information, see
|
24
|
-
# [Pagination](https://developer.squareup.com/docs/basics/
|
25
|
-
# .
|
23
|
+
# [Pagination](https://developer.squareup.com/docs/build-basics/common-api-p
|
24
|
+
# atterns/pagination).
|
26
25
|
# @param [String] location_id Optional parameter: Limit results to the
|
27
26
|
# location supplied. By default, results are returned for the default (main)
|
28
27
|
# location associated with the seller.
|
@@ -48,42 +47,26 @@ module Square
|
|
48
47
|
last_4: nil,
|
49
48
|
card_brand: nil,
|
50
49
|
limit: nil)
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
}
|
72
|
-
|
73
|
-
# Prepare and execute HttpRequest.
|
74
|
-
_request = config.http_client.get(
|
75
|
-
_query_url,
|
76
|
-
headers: _headers
|
77
|
-
)
|
78
|
-
OAuth2.apply(config, _request)
|
79
|
-
_response = execute_request(_request)
|
80
|
-
|
81
|
-
# Return appropriate response type.
|
82
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
83
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
84
|
-
ApiResponse.new(
|
85
|
-
_response, data: decoded, errors: _errors
|
86
|
-
)
|
50
|
+
new_api_call_builder
|
51
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
52
|
+
'/v2/payments',
|
53
|
+
'default')
|
54
|
+
.query_param(new_parameter(begin_time, key: 'begin_time'))
|
55
|
+
.query_param(new_parameter(end_time, key: 'end_time'))
|
56
|
+
.query_param(new_parameter(sort_order, key: 'sort_order'))
|
57
|
+
.query_param(new_parameter(cursor, key: 'cursor'))
|
58
|
+
.query_param(new_parameter(location_id, key: 'location_id'))
|
59
|
+
.query_param(new_parameter(total, key: 'total'))
|
60
|
+
.query_param(new_parameter(last_4, key: 'last_4'))
|
61
|
+
.query_param(new_parameter(card_brand, key: 'card_brand'))
|
62
|
+
.query_param(new_parameter(limit, key: 'limit'))
|
63
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
64
|
+
.auth(Single.new('global')))
|
65
|
+
.response(new_response_handler
|
66
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
67
|
+
.is_api_response(true)
|
68
|
+
.convertor(ApiResponse.method(:create)))
|
69
|
+
.execute
|
87
70
|
end
|
88
71
|
|
89
72
|
# Creates a payment using the provided source. You can use this endpoint
|
@@ -99,32 +82,20 @@ module Square
|
|
99
82
|
# object definition for field details.
|
100
83
|
# @return [CreatePaymentResponse Hash] response from the API call
|
101
84
|
def create_payment(body:)
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
headers: _headers,
|
117
|
-
parameters: body.to_json
|
118
|
-
)
|
119
|
-
OAuth2.apply(config, _request)
|
120
|
-
_response = execute_request(_request)
|
121
|
-
|
122
|
-
# Return appropriate response type.
|
123
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
124
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
125
|
-
ApiResponse.new(
|
126
|
-
_response, data: decoded, errors: _errors
|
127
|
-
)
|
85
|
+
new_api_call_builder
|
86
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
87
|
+
'/v2/payments',
|
88
|
+
'default')
|
89
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
90
|
+
.body_param(new_parameter(body))
|
91
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
92
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
93
|
+
.auth(Single.new('global')))
|
94
|
+
.response(new_response_handler
|
95
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
96
|
+
.is_api_response(true)
|
97
|
+
.convertor(ApiResponse.method(:create)))
|
98
|
+
.execute
|
128
99
|
end
|
129
100
|
|
130
101
|
# Cancels (voids) a payment identified by the idempotency key that is
|
@@ -147,32 +118,20 @@ module Square
|
|
147
118
|
# corresponding object definition for field details.
|
148
119
|
# @return [CancelPaymentByIdempotencyKeyResponse Hash] response from the API call
|
149
120
|
def cancel_payment_by_idempotency_key(body:)
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
headers: _headers,
|
165
|
-
parameters: body.to_json
|
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(
|
174
|
-
_response, data: decoded, errors: _errors
|
175
|
-
)
|
121
|
+
new_api_call_builder
|
122
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
123
|
+
'/v2/payments/cancel',
|
124
|
+
'default')
|
125
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
126
|
+
.body_param(new_parameter(body))
|
127
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
128
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
129
|
+
.auth(Single.new('global')))
|
130
|
+
.response(new_response_handler
|
131
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
132
|
+
.is_api_response(true)
|
133
|
+
.convertor(ApiResponse.method(:create)))
|
134
|
+
.execute
|
176
135
|
end
|
177
136
|
|
178
137
|
# Retrieves details for a specific payment.
|
@@ -180,34 +139,19 @@ module Square
|
|
180
139
|
# payment.
|
181
140
|
# @return [GetPaymentResponse Hash] response from the API call
|
182
141
|
def get_payment(payment_id:)
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
# Prepare and execute HttpRequest.
|
198
|
-
_request = config.http_client.get(
|
199
|
-
_query_url,
|
200
|
-
headers: _headers
|
201
|
-
)
|
202
|
-
OAuth2.apply(config, _request)
|
203
|
-
_response = execute_request(_request)
|
204
|
-
|
205
|
-
# Return appropriate response type.
|
206
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
207
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
208
|
-
ApiResponse.new(
|
209
|
-
_response, data: decoded, errors: _errors
|
210
|
-
)
|
142
|
+
new_api_call_builder
|
143
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
144
|
+
'/v2/payments/{payment_id}',
|
145
|
+
'default')
|
146
|
+
.template_param(new_parameter(payment_id, key: 'payment_id')
|
147
|
+
.should_encode(true))
|
148
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
149
|
+
.auth(Single.new('global')))
|
150
|
+
.response(new_response_handler
|
151
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
152
|
+
.is_api_response(true)
|
153
|
+
.convertor(ApiResponse.method(:create)))
|
154
|
+
.execute
|
211
155
|
end
|
212
156
|
|
213
157
|
# Updates a payment with the APPROVED status.
|
@@ -220,36 +164,22 @@ module Square
|
|
220
164
|
# @return [UpdatePaymentResponse Hash] response from the API call
|
221
165
|
def update_payment(payment_id:,
|
222
166
|
body:)
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
_request = config.http_client.put(
|
240
|
-
_query_url,
|
241
|
-
headers: _headers,
|
242
|
-
parameters: body.to_json
|
243
|
-
)
|
244
|
-
OAuth2.apply(config, _request)
|
245
|
-
_response = execute_request(_request)
|
246
|
-
|
247
|
-
# Return appropriate response type.
|
248
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
249
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
250
|
-
ApiResponse.new(
|
251
|
-
_response, data: decoded, errors: _errors
|
252
|
-
)
|
167
|
+
new_api_call_builder
|
168
|
+
.request(new_request_builder(HttpMethodEnum::PUT,
|
169
|
+
'/v2/payments/{payment_id}',
|
170
|
+
'default')
|
171
|
+
.template_param(new_parameter(payment_id, key: 'payment_id')
|
172
|
+
.should_encode(true))
|
173
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
174
|
+
.body_param(new_parameter(body))
|
175
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
176
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
177
|
+
.auth(Single.new('global')))
|
178
|
+
.response(new_response_handler
|
179
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
180
|
+
.is_api_response(true)
|
181
|
+
.convertor(ApiResponse.method(:create)))
|
182
|
+
.execute
|
253
183
|
end
|
254
184
|
|
255
185
|
# Cancels (voids) a payment. You can use this endpoint to cancel a payment
|
@@ -259,34 +189,19 @@ module Square
|
|
259
189
|
# cancel.
|
260
190
|
# @return [CancelPaymentResponse Hash] response from the API call
|
261
191
|
def cancel_payment(payment_id:)
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
# Prepare and execute HttpRequest.
|
277
|
-
_request = config.http_client.post(
|
278
|
-
_query_url,
|
279
|
-
headers: _headers
|
280
|
-
)
|
281
|
-
OAuth2.apply(config, _request)
|
282
|
-
_response = execute_request(_request)
|
283
|
-
|
284
|
-
# Return appropriate response type.
|
285
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
286
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
287
|
-
ApiResponse.new(
|
288
|
-
_response, data: decoded, errors: _errors
|
289
|
-
)
|
192
|
+
new_api_call_builder
|
193
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
194
|
+
'/v2/payments/{payment_id}/cancel',
|
195
|
+
'default')
|
196
|
+
.template_param(new_parameter(payment_id, key: 'payment_id')
|
197
|
+
.should_encode(true))
|
198
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
199
|
+
.auth(Single.new('global')))
|
200
|
+
.response(new_response_handler
|
201
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
202
|
+
.is_api_response(true)
|
203
|
+
.convertor(ApiResponse.method(:create)))
|
204
|
+
.execute
|
290
205
|
end
|
291
206
|
|
292
207
|
# Completes (captures) a payment.
|
@@ -302,36 +217,22 @@ module Square
|
|
302
217
|
# @return [CompletePaymentResponse Hash] response from the API call
|
303
218
|
def complete_payment(payment_id:,
|
304
219
|
body:)
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
_request = config.http_client.post(
|
322
|
-
_query_url,
|
323
|
-
headers: _headers,
|
324
|
-
parameters: body.to_json
|
325
|
-
)
|
326
|
-
OAuth2.apply(config, _request)
|
327
|
-
_response = execute_request(_request)
|
328
|
-
|
329
|
-
# Return appropriate response type.
|
330
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
331
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
332
|
-
ApiResponse.new(
|
333
|
-
_response, data: decoded, errors: _errors
|
334
|
-
)
|
220
|
+
new_api_call_builder
|
221
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
222
|
+
'/v2/payments/{payment_id}/complete',
|
223
|
+
'default')
|
224
|
+
.template_param(new_parameter(payment_id, key: 'payment_id')
|
225
|
+
.should_encode(true))
|
226
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
227
|
+
.body_param(new_parameter(body))
|
228
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
229
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
230
|
+
.auth(Single.new('global')))
|
231
|
+
.response(new_response_handler
|
232
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
233
|
+
.is_api_response(true)
|
234
|
+
.convertor(ApiResponse.method(:create)))
|
235
|
+
.execute
|
335
236
|
end
|
336
237
|
end
|
337
238
|
end
|
@@ -1,16 +1,12 @@
|
|
1
1
|
module Square
|
2
2
|
# PayoutsApi
|
3
3
|
class PayoutsApi < BaseApi
|
4
|
-
def initialize(config, http_call_back: nil)
|
5
|
-
super(config, http_call_back: http_call_back)
|
6
|
-
end
|
7
|
-
|
8
4
|
# Retrieves a list of all payouts for the default location.
|
9
5
|
# You can filter payouts by location ID, status, time range, and order them
|
10
6
|
# in ascending or descending order.
|
11
7
|
# To call this endpoint, set `PAYOUTS_READ` for the OAuth scope.
|
12
8
|
# @param [String] location_id Optional parameter: The ID of the location for
|
13
|
-
# which to list the payouts.
|
9
|
+
# which to list the payouts. By default, payouts are returned for the
|
14
10
|
# default (main) location associated with the seller.
|
15
11
|
# @param [PayoutStatus] status Optional parameter: If provided, only payouts
|
16
12
|
# with the given status are returned.
|
@@ -24,9 +20,9 @@ module Square
|
|
24
20
|
# @param [String] cursor Optional parameter: A pagination cursor returned by
|
25
21
|
# a previous call to this endpoint. Provide this cursor to retrieve the next
|
26
22
|
# set of results for the original query. For more information, see
|
27
|
-
# [Pagination](https://developer.squareup.com/docs/basics/
|
28
|
-
# . If request parameters change between requests,
|
29
|
-
# contain duplicates or missing records.
|
23
|
+
# [Pagination](https://developer.squareup.com/docs/build-basics/common-api-p
|
24
|
+
# atterns/pagination). If request parameters change between requests,
|
25
|
+
# subsequent results may contain duplicates or missing records.
|
30
26
|
# @param [Integer] limit Optional parameter: The maximum number of results
|
31
27
|
# to be returned in a single page. It is possible to receive fewer results
|
32
28
|
# than the specified limit on a given page. The default value of 100 is also
|
@@ -40,40 +36,24 @@ module Square
|
|
40
36
|
sort_order: nil,
|
41
37
|
cursor: nil,
|
42
38
|
limit: nil)
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
}
|
62
|
-
|
63
|
-
# Prepare and execute HttpRequest.
|
64
|
-
_request = config.http_client.get(
|
65
|
-
_query_url,
|
66
|
-
headers: _headers
|
67
|
-
)
|
68
|
-
OAuth2.apply(config, _request)
|
69
|
-
_response = execute_request(_request)
|
70
|
-
|
71
|
-
# Return appropriate response type.
|
72
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
73
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
74
|
-
ApiResponse.new(
|
75
|
-
_response, data: decoded, errors: _errors
|
76
|
-
)
|
39
|
+
new_api_call_builder
|
40
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
41
|
+
'/v2/payouts',
|
42
|
+
'default')
|
43
|
+
.query_param(new_parameter(location_id, key: 'location_id'))
|
44
|
+
.query_param(new_parameter(status, key: 'status'))
|
45
|
+
.query_param(new_parameter(begin_time, key: 'begin_time'))
|
46
|
+
.query_param(new_parameter(end_time, key: 'end_time'))
|
47
|
+
.query_param(new_parameter(sort_order, key: 'sort_order'))
|
48
|
+
.query_param(new_parameter(cursor, key: 'cursor'))
|
49
|
+
.query_param(new_parameter(limit, key: 'limit'))
|
50
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
51
|
+
.auth(Single.new('global')))
|
52
|
+
.response(new_response_handler
|
53
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
54
|
+
.is_api_response(true)
|
55
|
+
.convertor(ApiResponse.method(:create)))
|
56
|
+
.execute
|
77
57
|
end
|
78
58
|
|
79
59
|
# Retrieves details of a specific payout identified by a payout ID.
|
@@ -82,34 +62,19 @@ module Square
|
|
82
62
|
# retrieve the information for.
|
83
63
|
# @return [GetPayoutResponse Hash] response from the API call
|
84
64
|
def get_payout(payout_id:)
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
# Prepare and execute HttpRequest.
|
100
|
-
_request = config.http_client.get(
|
101
|
-
_query_url,
|
102
|
-
headers: _headers
|
103
|
-
)
|
104
|
-
OAuth2.apply(config, _request)
|
105
|
-
_response = execute_request(_request)
|
106
|
-
|
107
|
-
# Return appropriate response type.
|
108
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
109
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
110
|
-
ApiResponse.new(
|
111
|
-
_response, data: decoded, errors: _errors
|
112
|
-
)
|
65
|
+
new_api_call_builder
|
66
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
67
|
+
'/v2/payouts/{payout_id}',
|
68
|
+
'default')
|
69
|
+
.template_param(new_parameter(payout_id, key: 'payout_id')
|
70
|
+
.should_encode(true))
|
71
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
72
|
+
.auth(Single.new('global')))
|
73
|
+
.response(new_response_handler
|
74
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
75
|
+
.is_api_response(true)
|
76
|
+
.convertor(ApiResponse.method(:create)))
|
77
|
+
.execute
|
113
78
|
end
|
114
79
|
|
115
80
|
# Retrieves a list of all payout entries for a specific payout.
|
@@ -121,9 +86,9 @@ module Square
|
|
121
86
|
# @param [String] cursor Optional parameter: A pagination cursor returned by
|
122
87
|
# a previous call to this endpoint. Provide this cursor to retrieve the next
|
123
88
|
# set of results for the original query. For more information, see
|
124
|
-
# [Pagination](https://developer.squareup.com/docs/basics/
|
125
|
-
# . If request parameters change between requests,
|
126
|
-
# contain duplicates or missing records.
|
89
|
+
# [Pagination](https://developer.squareup.com/docs/build-basics/common-api-p
|
90
|
+
# atterns/pagination). If request parameters change between requests,
|
91
|
+
# subsequent results may contain duplicates or missing records.
|
127
92
|
# @param [Integer] limit Optional parameter: The maximum number of results
|
128
93
|
# to be returned in a single page. It is possible to receive fewer results
|
129
94
|
# than the specified limit on a given page. The default value of 100 is also
|
@@ -134,40 +99,22 @@ module Square
|
|
134
99
|
sort_order: nil,
|
135
100
|
cursor: nil,
|
136
101
|
limit: nil)
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
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(
|
169
|
-
_response, data: decoded, errors: _errors
|
170
|
-
)
|
102
|
+
new_api_call_builder
|
103
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
104
|
+
'/v2/payouts/{payout_id}/payout-entries',
|
105
|
+
'default')
|
106
|
+
.template_param(new_parameter(payout_id, key: 'payout_id')
|
107
|
+
.should_encode(true))
|
108
|
+
.query_param(new_parameter(sort_order, key: 'sort_order'))
|
109
|
+
.query_param(new_parameter(cursor, key: 'cursor'))
|
110
|
+
.query_param(new_parameter(limit, key: 'limit'))
|
111
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
112
|
+
.auth(Single.new('global')))
|
113
|
+
.response(new_response_handler
|
114
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
115
|
+
.is_api_response(true)
|
116
|
+
.convertor(ApiResponse.method(:create)))
|
117
|
+
.execute
|
171
118
|
end
|
172
119
|
end
|
173
120
|
end
|