square.rb 8.0.0.20201216 → 26.1.0.20230119
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/README.md +79 -221
- data/lib/square/api/apple_pay_api.rb +15 -8
- data/lib/square/api/bank_accounts_api.rb +5 -5
- data/lib/square/api/base_api.rb +27 -9
- data/lib/square/api/booking_custom_attributes_api.rb +555 -0
- data/lib/square/api/bookings_api.rb +107 -15
- data/lib/square/api/cards_api.rb +171 -0
- data/lib/square/api/cash_drawers_api.rb +2 -2
- data/lib/square/api/catalog_api.rb +167 -73
- data/lib/square/api/checkout_api.rb +205 -3
- data/lib/square/api/customer_custom_attributes_api.rb +561 -0
- data/lib/square/api/customer_groups_api.rb +17 -8
- data/lib/square/api/customer_segments_api.rb +15 -6
- data/lib/square/api/customers_api.rb +67 -33
- data/lib/square/api/devices_api.rb +3 -2
- data/lib/square/api/disputes_api.rb +109 -105
- data/lib/square/api/gift_card_activities_api.rb +132 -0
- data/lib/square/api/gift_cards_api.rb +298 -0
- data/lib/square/api/inventory_api.rb +263 -24
- data/lib/square/api/invoices_api.rb +21 -21
- data/lib/square/api/labor_api.rb +70 -68
- data/lib/square/api/location_custom_attributes_api.rb +584 -0
- data/lib/square/api/locations_api.rb +21 -14
- data/lib/square/api/loyalty_api.rb +333 -50
- data/lib/square/api/merchants_api.rb +11 -9
- data/lib/square/api/mobile_authorization_api.rb +4 -4
- data/lib/square/api/o_auth_api.rb +78 -25
- data/lib/square/api/order_custom_attributes_api.rb +601 -0
- data/lib/square/api/orders_api.rb +84 -45
- data/lib/square/api/payments_api.rb +72 -24
- data/lib/square/api/payouts_api.rb +173 -0
- data/lib/square/api/refunds_api.rb +18 -7
- data/lib/square/api/sites_api.rb +43 -0
- data/lib/square/api/snippets_api.rb +146 -0
- data/lib/square/api/subscriptions_api.rb +190 -15
- data/lib/square/api/team_api.rb +46 -46
- data/lib/square/api/terminal_api.rb +172 -22
- data/lib/square/api/transactions_api.rb +15 -191
- data/lib/square/api/v1_transactions_api.rb +52 -124
- data/lib/square/api/vendors_api.rb +257 -0
- data/lib/square/api/webhook_subscriptions_api.rb +327 -0
- data/lib/square/api_helper.rb +217 -57
- data/lib/square/client.rb +90 -18
- data/lib/square/configuration.rb +64 -20
- data/lib/square/exceptions/validation_exception.rb +13 -0
- data/lib/square/http/api_response.rb +7 -9
- data/lib/square/http/faraday_client.rb +40 -9
- data/lib/square/http/http_client.rb +31 -12
- data/lib/square/http/http_request.rb +6 -2
- data/lib/square/utilities/date_time_helper.rb +151 -0
- data/lib/square/utilities/file_wrapper.rb +1 -2
- data/lib/square.rb +56 -44
- data/test/api/test_locations_api.rb +2 -5
- data/test/test_helper.rb +2 -2
- metadata +83 -15
- data/lib/square/api/v1_employees_api.rb +0 -751
- data/lib/square/api/v1_items_api.rb +0 -1766
@@ -5,14 +5,14 @@ module Square
|
|
5
5
|
super(config, http_call_back: http_call_back)
|
6
6
|
end
|
7
7
|
|
8
|
-
# Creates a new [
|
8
|
+
# Creates a new [order]($m/Order) that can include information about
|
9
9
|
# products for
|
10
10
|
# purchase and settings to apply to the purchase.
|
11
|
-
# To pay for a created order,
|
12
|
-
#
|
13
|
-
#
|
14
|
-
# You can modify open orders using the
|
15
|
-
#
|
11
|
+
# To pay for a created order, see
|
12
|
+
# [Pay for
|
13
|
+
# Orders](https://developer.squareup.com/docs/orders-api/pay-for-orders).
|
14
|
+
# You can modify open orders using the [UpdateOrder]($e/Orders/UpdateOrder)
|
15
|
+
# endpoint.
|
16
16
|
# @param [CreateOrderRequest] body Required parameter: An object containing
|
17
17
|
# the fields to POST for the request. See the corresponding object
|
18
18
|
# definition for field details.
|
@@ -26,7 +26,7 @@ module Square
|
|
26
26
|
# Prepare headers.
|
27
27
|
_headers = {
|
28
28
|
'accept' => 'application/json',
|
29
|
-
'
|
29
|
+
'Content-Type' => 'application/json'
|
30
30
|
}
|
31
31
|
|
32
32
|
# Prepare and execute HttpRequest.
|
@@ -46,8 +46,8 @@ module Square
|
|
46
46
|
)
|
47
47
|
end
|
48
48
|
|
49
|
-
# Retrieves a set of [
|
50
|
-
# If a given
|
49
|
+
# Retrieves a set of [orders]($m/Order) by their IDs.
|
50
|
+
# If a given order ID does not exist, the ID is ignored instead of
|
51
51
|
# generating an error.
|
52
52
|
# @param [BatchRetrieveOrdersRequest] body Required parameter: An object
|
53
53
|
# containing the fields to POST for the request. See the corresponding
|
@@ -62,7 +62,7 @@ module Square
|
|
62
62
|
# Prepare headers.
|
63
63
|
_headers = {
|
64
64
|
'accept' => 'application/json',
|
65
|
-
'
|
65
|
+
'Content-Type' => 'application/json'
|
66
66
|
}
|
67
67
|
|
68
68
|
# Prepare and execute HttpRequest.
|
@@ -82,7 +82,7 @@ module Square
|
|
82
82
|
)
|
83
83
|
end
|
84
84
|
|
85
|
-
#
|
85
|
+
# Enables applications to preview order pricing without creating an order.
|
86
86
|
# @param [CalculateOrderRequest] body Required parameter: An object
|
87
87
|
# containing the fields to POST for the request. See the corresponding
|
88
88
|
# object definition for field details.
|
@@ -96,7 +96,44 @@ module Square
|
|
96
96
|
# Prepare headers.
|
97
97
|
_headers = {
|
98
98
|
'accept' => 'application/json',
|
99
|
-
'
|
99
|
+
'Content-Type' => 'application/json'
|
100
|
+
}
|
101
|
+
|
102
|
+
# Prepare and execute HttpRequest.
|
103
|
+
_request = config.http_client.post(
|
104
|
+
_query_url,
|
105
|
+
headers: _headers,
|
106
|
+
parameters: body.to_json
|
107
|
+
)
|
108
|
+
OAuth2.apply(config, _request)
|
109
|
+
_response = execute_request(_request)
|
110
|
+
|
111
|
+
# Return appropriate response type.
|
112
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
113
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
114
|
+
ApiResponse.new(
|
115
|
+
_response, data: decoded, errors: _errors
|
116
|
+
)
|
117
|
+
end
|
118
|
+
|
119
|
+
# Creates a new order, in the `DRAFT` state, by duplicating an existing
|
120
|
+
# order. The newly created order has
|
121
|
+
# only the core fields (such as line items, taxes, and discounts) copied
|
122
|
+
# from the original order.
|
123
|
+
# @param [CloneOrderRequest] body Required parameter: An object containing
|
124
|
+
# the fields to POST for the request. See the corresponding object
|
125
|
+
# definition for field details.
|
126
|
+
# @return [CloneOrderResponse Hash] response from the API call
|
127
|
+
def clone_order(body:)
|
128
|
+
# Prepare query url.
|
129
|
+
_query_builder = config.get_base_uri
|
130
|
+
_query_builder << '/v2/orders/clone'
|
131
|
+
_query_url = APIHelper.clean_url _query_builder
|
132
|
+
|
133
|
+
# Prepare headers.
|
134
|
+
_headers = {
|
135
|
+
'accept' => 'application/json',
|
136
|
+
'Content-Type' => 'application/json'
|
100
137
|
}
|
101
138
|
|
102
139
|
# Prepare and execute HttpRequest.
|
@@ -118,17 +155,18 @@ module Square
|
|
118
155
|
|
119
156
|
# Search all orders for one or more locations. Orders include all sales,
|
120
157
|
# returns, and exchanges regardless of how or when they entered the Square
|
121
|
-
#
|
122
|
-
# SearchOrders requests need to specify which locations to search and
|
123
|
-
# a
|
124
|
-
# [
|
125
|
-
# how to sort or filter the results. Your SearchOrdersQuery can:
|
158
|
+
# ecosystem (such as Point of Sale, Invoices, and Connect APIs).
|
159
|
+
# `SearchOrders` requests need to specify which locations to search and
|
160
|
+
# define a
|
161
|
+
# [SearchOrdersQuery]($m/SearchOrdersQuery) object that controls
|
162
|
+
# how to sort or filter the results. Your `SearchOrdersQuery` can:
|
126
163
|
# Set filter criteria.
|
127
|
-
# Set sort order.
|
128
|
-
# Determine whether to return results as complete Order objects
|
129
|
-
# [OrderEntry](
|
164
|
+
# Set the sort order.
|
165
|
+
# Determine whether to return results as complete `Order` objects or as
|
166
|
+
# [OrderEntry]($m/OrderEntry) objects.
|
130
167
|
# Note that details for orders processed with Square Point of Sale while in
|
131
|
-
# offline mode
|
168
|
+
# offline mode might not be transmitted to Square for up to 72 hours.
|
169
|
+
# Offline
|
132
170
|
# orders have a `created_at` value that reflects the time the order was
|
133
171
|
# created,
|
134
172
|
# not the time it was subsequently transmitted to Square.
|
@@ -145,7 +183,7 @@ module Square
|
|
145
183
|
# Prepare headers.
|
146
184
|
_headers = {
|
147
185
|
'accept' => 'application/json',
|
148
|
-
'
|
186
|
+
'Content-Type' => 'application/json'
|
149
187
|
}
|
150
188
|
|
151
189
|
# Prepare and execute HttpRequest.
|
@@ -165,7 +203,7 @@ module Square
|
|
165
203
|
)
|
166
204
|
end
|
167
205
|
|
168
|
-
# Retrieves an [Order](
|
206
|
+
# Retrieves an [Order]($m/Order) by ID.
|
169
207
|
# @param [String] order_id Required parameter: The ID of the order to
|
170
208
|
# retrieve.
|
171
209
|
# @return [RetrieveOrderResponse Hash] response from the API call
|
@@ -200,23 +238,24 @@ module Square
|
|
200
238
|
)
|
201
239
|
end
|
202
240
|
|
203
|
-
# Updates an open [
|
241
|
+
# Updates an open [order]($m/Order) by adding, replacing, or deleting
|
204
242
|
# fields. Orders with a `COMPLETED` or `CANCELED` state cannot be updated.
|
205
|
-
# An UpdateOrder request requires the following:
|
243
|
+
# An `UpdateOrder` request requires the following:
|
206
244
|
# - The `order_id` in the endpoint path, identifying the order to update.
|
207
245
|
# - The latest `version` of the order to update.
|
208
246
|
# - The [sparse
|
209
|
-
# order](https://developer.squareup.com/docs/orders-api/manage-orders
|
210
|
-
# -order-objects)
|
211
|
-
# containing only the fields to update and the version the update
|
212
|
-
#
|
247
|
+
# order](https://developer.squareup.com/docs/orders-api/manage-orders/update
|
248
|
+
# -orders#sparse-order-objects)
|
249
|
+
# containing only the fields to update and the version to which the update
|
250
|
+
# is
|
251
|
+
# being applied.
|
213
252
|
# - If deleting fields, the [dot notation
|
214
|
-
# paths](https://developer.squareup.com/docs/orders-api/manage-orders
|
215
|
-
# -
|
216
|
-
# identifying fields to clear.
|
217
|
-
# To pay for an order,
|
218
|
-
#
|
219
|
-
#
|
253
|
+
# paths](https://developer.squareup.com/docs/orders-api/manage-orders/update
|
254
|
+
# -orders#identifying-fields-to-delete)
|
255
|
+
# identifying the fields to clear.
|
256
|
+
# To pay for an order, see
|
257
|
+
# [Pay for
|
258
|
+
# Orders](https://developer.squareup.com/docs/orders-api/pay-for-orders).
|
220
259
|
# @param [String] order_id Required parameter: The ID of the order to
|
221
260
|
# update.
|
222
261
|
# @param [UpdateOrderRequest] body Required parameter: An object containing
|
@@ -237,7 +276,7 @@ module Square
|
|
237
276
|
# Prepare headers.
|
238
277
|
_headers = {
|
239
278
|
'accept' => 'application/json',
|
240
|
-
'
|
279
|
+
'Content-Type' => 'application/json'
|
241
280
|
}
|
242
281
|
|
243
282
|
# Prepare and execute HttpRequest.
|
@@ -257,24 +296,24 @@ module Square
|
|
257
296
|
)
|
258
297
|
end
|
259
298
|
|
260
|
-
# Pay for an [order](
|
261
|
-
# [payments](
|
299
|
+
# Pay for an [order]($m/Order) using one or more approved
|
300
|
+
# [payments]($m/Payment)
|
262
301
|
# or settle an order with a total of `0`.
|
263
302
|
# The total of the `payment_ids` listed in the request must be equal to the
|
264
303
|
# order
|
265
304
|
# total. Orders with a total amount of `0` can be marked as paid by
|
266
305
|
# specifying an empty
|
267
306
|
# array of `payment_ids` in the request.
|
268
|
-
# To be used with PayOrder
|
307
|
+
# To be used with `PayOrder`, a payment must:
|
269
308
|
# - Reference the order by specifying the `order_id` when [creating the
|
270
|
-
# payment](
|
309
|
+
# payment]($e/Payments/CreatePayment).
|
271
310
|
# Any approved payments that reference the same `order_id` not specified in
|
272
311
|
# the
|
273
|
-
# `payment_ids`
|
312
|
+
# `payment_ids` is canceled.
|
274
313
|
# - Be approved with [delayed
|
275
|
-
# capture](https://developer.squareup.com/docs/payments-api/take-payments
|
276
|
-
#
|
277
|
-
# Using a delayed capture payment with PayOrder
|
314
|
+
# capture](https://developer.squareup.com/docs/payments-api/take-payments/ca
|
315
|
+
# rd-payments/delayed-capture).
|
316
|
+
# Using a delayed capture payment with `PayOrder` completes the approved
|
278
317
|
# payment.
|
279
318
|
# @param [String] order_id Required parameter: The ID of the order being
|
280
319
|
# paid.
|
@@ -296,7 +335,7 @@ module Square
|
|
296
335
|
# Prepare headers.
|
297
336
|
_headers = {
|
298
337
|
'accept' => 'application/json',
|
299
|
-
'
|
338
|
+
'Content-Type' => 'application/json'
|
300
339
|
}
|
301
340
|
|
302
341
|
# Prepare and execute HttpRequest.
|
@@ -6,6 +6,9 @@ module Square
|
|
6
6
|
end
|
7
7
|
|
8
8
|
# Retrieves a list of payments taken by the account making the request.
|
9
|
+
# Results are eventually consistent, and new payments or changes to payments
|
10
|
+
# might take several
|
11
|
+
# seconds to appear.
|
9
12
|
# The maximum results per page is 100.
|
10
13
|
# @param [String] begin_time Optional parameter: The timestamp for the
|
11
14
|
# beginning of the reporting period, in RFC 3339 format. Inclusive. Default:
|
@@ -23,7 +26,7 @@ module Square
|
|
23
26
|
# @param [String] location_id Optional parameter: Limit results to the
|
24
27
|
# location supplied. By default, results are returned for the default (main)
|
25
28
|
# location associated with the seller.
|
26
|
-
# @param [
|
29
|
+
# @param [Integer] total Optional parameter: The exact amount in the
|
27
30
|
# `total_money` for a payment.
|
28
31
|
# @param [String] last_4 Optional parameter: The last four digits of a
|
29
32
|
# payment card.
|
@@ -83,16 +86,14 @@ module Square
|
|
83
86
|
)
|
84
87
|
end
|
85
88
|
|
86
|
-
#
|
87
|
-
#
|
88
|
-
#
|
89
|
-
#
|
90
|
-
#
|
91
|
-
#
|
92
|
-
#
|
93
|
-
#
|
94
|
-
# The `PAYMENTS_WRITE_ADDITIONAL_RECIPIENTS` OAuth permission is required
|
95
|
-
# to enable application fees.
|
89
|
+
# Creates a payment using the provided source. You can use this endpoint
|
90
|
+
# to charge a card (credit/debit card or
|
91
|
+
# Square gift card) or record a payment that the seller received outside of
|
92
|
+
# Square
|
93
|
+
# (cash payment from a buyer or a payment that an external entity
|
94
|
+
# processed on behalf of the seller).
|
95
|
+
# The endpoint creates a
|
96
|
+
# `Payment` object and returns it in the response.
|
96
97
|
# @param [CreatePaymentRequest] body Required parameter: An object
|
97
98
|
# containing the fields to POST for the request. See the corresponding
|
98
99
|
# object definition for field details.
|
@@ -106,7 +107,7 @@ module Square
|
|
106
107
|
# Prepare headers.
|
107
108
|
_headers = {
|
108
109
|
'accept' => 'application/json',
|
109
|
-
'
|
110
|
+
'Content-Type' => 'application/json'
|
110
111
|
}
|
111
112
|
|
112
113
|
# Prepare and execute HttpRequest.
|
@@ -154,7 +155,7 @@ module Square
|
|
154
155
|
# Prepare headers.
|
155
156
|
_headers = {
|
156
157
|
'accept' => 'application/json',
|
157
|
-
'
|
158
|
+
'Content-Type' => 'application/json'
|
158
159
|
}
|
159
160
|
|
160
161
|
# Prepare and execute HttpRequest.
|
@@ -209,11 +210,53 @@ module Square
|
|
209
210
|
)
|
210
211
|
end
|
211
212
|
|
212
|
-
#
|
213
|
-
#
|
214
|
-
#
|
215
|
-
#
|
216
|
-
#
|
213
|
+
# Updates a payment with the APPROVED status.
|
214
|
+
# You can update the `amount_money` and `tip_money` using this endpoint.
|
215
|
+
# @param [String] payment_id Required parameter: The ID of the payment to
|
216
|
+
# update.
|
217
|
+
# @param [UpdatePaymentRequest] body Required parameter: An object
|
218
|
+
# containing the fields to POST for the request. See the corresponding
|
219
|
+
# object definition for field details.
|
220
|
+
# @return [UpdatePaymentResponse Hash] response from the API call
|
221
|
+
def update_payment(payment_id:,
|
222
|
+
body:)
|
223
|
+
# Prepare query url.
|
224
|
+
_query_builder = config.get_base_uri
|
225
|
+
_query_builder << '/v2/payments/{payment_id}'
|
226
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
227
|
+
_query_builder,
|
228
|
+
'payment_id' => { 'value' => payment_id, 'encode' => true }
|
229
|
+
)
|
230
|
+
_query_url = APIHelper.clean_url _query_builder
|
231
|
+
|
232
|
+
# Prepare headers.
|
233
|
+
_headers = {
|
234
|
+
'accept' => 'application/json',
|
235
|
+
'Content-Type' => 'application/json'
|
236
|
+
}
|
237
|
+
|
238
|
+
# Prepare and execute HttpRequest.
|
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
|
+
)
|
253
|
+
end
|
254
|
+
|
255
|
+
# Cancels (voids) a payment. You can use this endpoint to cancel a payment
|
256
|
+
# with
|
257
|
+
# the APPROVED `status`.
|
258
|
+
# @param [String] payment_id Required parameter: The ID of the payment to
|
259
|
+
# cancel.
|
217
260
|
# @return [CancelPaymentResponse Hash] response from the API call
|
218
261
|
def cancel_payment(payment_id:)
|
219
262
|
# Prepare query url.
|
@@ -249,13 +292,16 @@ module Square
|
|
249
292
|
# Completes (captures) a payment.
|
250
293
|
# By default, payments are set to complete immediately after they are
|
251
294
|
# created.
|
252
|
-
#
|
253
|
-
#
|
254
|
-
# the payment using this endpoint.
|
295
|
+
# You can use this endpoint to complete a payment with the APPROVED
|
296
|
+
# `status`.
|
255
297
|
# @param [String] payment_id Required parameter: The unique ID identifying
|
256
298
|
# the payment to be completed.
|
299
|
+
# @param [CompletePaymentRequest] body Required parameter: An object
|
300
|
+
# containing the fields to POST for the request. See the corresponding
|
301
|
+
# object definition for field details.
|
257
302
|
# @return [CompletePaymentResponse Hash] response from the API call
|
258
|
-
def complete_payment(payment_id
|
303
|
+
def complete_payment(payment_id:,
|
304
|
+
body:)
|
259
305
|
# Prepare query url.
|
260
306
|
_query_builder = config.get_base_uri
|
261
307
|
_query_builder << '/v2/payments/{payment_id}/complete'
|
@@ -267,13 +313,15 @@ module Square
|
|
267
313
|
|
268
314
|
# Prepare headers.
|
269
315
|
_headers = {
|
270
|
-
'accept' => 'application/json'
|
316
|
+
'accept' => 'application/json',
|
317
|
+
'Content-Type' => 'application/json'
|
271
318
|
}
|
272
319
|
|
273
320
|
# Prepare and execute HttpRequest.
|
274
321
|
_request = config.http_client.post(
|
275
322
|
_query_url,
|
276
|
-
headers: _headers
|
323
|
+
headers: _headers,
|
324
|
+
parameters: body.to_json
|
277
325
|
)
|
278
326
|
OAuth2.apply(config, _request)
|
279
327
|
_response = execute_request(_request)
|
@@ -0,0 +1,173 @@
|
|
1
|
+
module Square
|
2
|
+
# PayoutsApi
|
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
|
+
# Retrieves a list of all payouts for the default location.
|
9
|
+
# You can filter payouts by location ID, status, time range, and order them
|
10
|
+
# in ascending or descending order.
|
11
|
+
# To call this endpoint, set `PAYOUTS_READ` for the OAuth scope.
|
12
|
+
# @param [String] location_id Optional parameter: The ID of the location for
|
13
|
+
# which to list the payouts. By default, payouts are returned for the
|
14
|
+
# default (main) location associated with the seller.
|
15
|
+
# @param [PayoutStatus] status Optional parameter: If provided, only payouts
|
16
|
+
# with the given status are returned.
|
17
|
+
# @param [String] begin_time Optional parameter: The timestamp for the
|
18
|
+
# beginning of the payout creation time, in RFC 3339 format. Inclusive.
|
19
|
+
# Default: The current time minus one year.
|
20
|
+
# @param [String] end_time Optional parameter: The timestamp for the end of
|
21
|
+
# the payout creation time, in RFC 3339 format. Default: The current time.
|
22
|
+
# @param [SortOrder] sort_order Optional parameter: The order in which
|
23
|
+
# payouts are listed.
|
24
|
+
# @param [String] cursor Optional parameter: A pagination cursor returned by
|
25
|
+
# a previous call to this endpoint. Provide this cursor to retrieve the next
|
26
|
+
# set of results for the original query. For more information, see
|
27
|
+
# [Pagination](https://developer.squareup.com/docs/basics/api101/pagination)
|
28
|
+
# . If request parameters change between requests, subsequent results may
|
29
|
+
# contain duplicates or missing records.
|
30
|
+
# @param [Integer] limit Optional parameter: The maximum number of results
|
31
|
+
# to be returned in a single page. It is possible to receive fewer results
|
32
|
+
# than the specified limit on a given page. The default value of 100 is also
|
33
|
+
# the maximum allowed value. If the provided value is greater than 100, it
|
34
|
+
# is ignored and the default value is used instead. Default: `100`
|
35
|
+
# @return [ListPayoutsResponse Hash] response from the API call
|
36
|
+
def list_payouts(location_id: nil,
|
37
|
+
status: nil,
|
38
|
+
begin_time: nil,
|
39
|
+
end_time: nil,
|
40
|
+
sort_order: nil,
|
41
|
+
cursor: nil,
|
42
|
+
limit: nil)
|
43
|
+
# Prepare query url.
|
44
|
+
_query_builder = config.get_base_uri
|
45
|
+
_query_builder << '/v2/payouts'
|
46
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
47
|
+
_query_builder,
|
48
|
+
'location_id' => location_id,
|
49
|
+
'status' => status,
|
50
|
+
'begin_time' => begin_time,
|
51
|
+
'end_time' => end_time,
|
52
|
+
'sort_order' => sort_order,
|
53
|
+
'cursor' => cursor,
|
54
|
+
'limit' => limit
|
55
|
+
)
|
56
|
+
_query_url = APIHelper.clean_url _query_builder
|
57
|
+
|
58
|
+
# Prepare headers.
|
59
|
+
_headers = {
|
60
|
+
'accept' => 'application/json'
|
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
|
+
)
|
77
|
+
end
|
78
|
+
|
79
|
+
# Retrieves details of a specific payout identified by a payout ID.
|
80
|
+
# To call this endpoint, set `PAYOUTS_READ` for the OAuth scope.
|
81
|
+
# @param [String] payout_id Required parameter: The ID of the payout to
|
82
|
+
# retrieve the information for.
|
83
|
+
# @return [GetPayoutResponse Hash] response from the API call
|
84
|
+
def get_payout(payout_id:)
|
85
|
+
# Prepare query url.
|
86
|
+
_query_builder = config.get_base_uri
|
87
|
+
_query_builder << '/v2/payouts/{payout_id}'
|
88
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
89
|
+
_query_builder,
|
90
|
+
'payout_id' => { 'value' => payout_id, 'encode' => true }
|
91
|
+
)
|
92
|
+
_query_url = APIHelper.clean_url _query_builder
|
93
|
+
|
94
|
+
# Prepare headers.
|
95
|
+
_headers = {
|
96
|
+
'accept' => 'application/json'
|
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
|
+
)
|
113
|
+
end
|
114
|
+
|
115
|
+
# Retrieves a list of all payout entries for a specific payout.
|
116
|
+
# To call this endpoint, set `PAYOUTS_READ` for the OAuth scope.
|
117
|
+
# @param [String] payout_id Required parameter: The ID of the payout to
|
118
|
+
# retrieve the information for.
|
119
|
+
# @param [SortOrder] sort_order Optional parameter: The order in which
|
120
|
+
# payout entries are listed.
|
121
|
+
# @param [String] cursor Optional parameter: A pagination cursor returned by
|
122
|
+
# a previous call to this endpoint. Provide this cursor to retrieve the next
|
123
|
+
# set of results for the original query. For more information, see
|
124
|
+
# [Pagination](https://developer.squareup.com/docs/basics/api101/pagination)
|
125
|
+
# . If request parameters change between requests, subsequent results may
|
126
|
+
# contain duplicates or missing records.
|
127
|
+
# @param [Integer] limit Optional parameter: The maximum number of results
|
128
|
+
# to be returned in a single page. It is possible to receive fewer results
|
129
|
+
# than the specified limit on a given page. The default value of 100 is also
|
130
|
+
# the maximum allowed value. If the provided value is greater than 100, it
|
131
|
+
# is ignored and the default value is used instead. Default: `100`
|
132
|
+
# @return [ListPayoutEntriesResponse Hash] response from the API call
|
133
|
+
def list_payout_entries(payout_id:,
|
134
|
+
sort_order: nil,
|
135
|
+
cursor: nil,
|
136
|
+
limit: nil)
|
137
|
+
# Prepare query url.
|
138
|
+
_query_builder = config.get_base_uri
|
139
|
+
_query_builder << '/v2/payouts/{payout_id}/payout-entries'
|
140
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
141
|
+
_query_builder,
|
142
|
+
'payout_id' => { 'value' => payout_id, 'encode' => true }
|
143
|
+
)
|
144
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
145
|
+
_query_builder,
|
146
|
+
'sort_order' => sort_order,
|
147
|
+
'cursor' => cursor,
|
148
|
+
'limit' => limit
|
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(
|
169
|
+
_response, data: decoded, errors: _errors
|
170
|
+
)
|
171
|
+
end
|
172
|
+
end
|
173
|
+
end
|
@@ -6,6 +6,9 @@ module Square
|
|
6
6
|
end
|
7
7
|
|
8
8
|
# Retrieves a list of refunds for the account making the request.
|
9
|
+
# Results are eventually consistent, and new refunds or changes to refunds
|
10
|
+
# might take several
|
11
|
+
# seconds to appear.
|
9
12
|
# The maximum results per page is 100.
|
10
13
|
# @param [String] begin_time Optional parameter: The timestamp for the
|
11
14
|
# beginning of the requested reporting period, in RFC 3339 format. Default:
|
@@ -26,12 +29,15 @@ module Square
|
|
26
29
|
# associated with the seller.
|
27
30
|
# @param [String] status Optional parameter: If provided, only refunds with
|
28
31
|
# the given status are returned. For a list of refund status values, see
|
29
|
-
# [PaymentRefund](
|
32
|
+
# [PaymentRefund]($m/PaymentRefund). Default: If omitted, refunds are
|
30
33
|
# returned regardless of their status.
|
31
|
-
# @param [String] source_type Optional parameter: If provided, only
|
32
|
-
#
|
33
|
-
#
|
34
|
-
#
|
34
|
+
# @param [String] source_type Optional parameter: If provided, only returns
|
35
|
+
# refunds whose payments have the indicated source type. Current values
|
36
|
+
# include `CARD`, `BANK_ACCOUNT`, `WALLET`, `CASH`, and `EXTERNAL`. For
|
37
|
+
# information about these payment source types, see [Take
|
38
|
+
# Payments](https://developer.squareup.com/docs/payments-api/take-payments).
|
39
|
+
# Default: If omitted, refunds are returned regardless of the source
|
40
|
+
# type.
|
35
41
|
# @param [Integer] limit Optional parameter: The maximum number of results
|
36
42
|
# to be returned in a single page. It is possible to receive fewer results
|
37
43
|
# than the specified limit on a given page. If the supplied value is
|
@@ -83,7 +89,12 @@ module Square
|
|
83
89
|
end
|
84
90
|
|
85
91
|
# Refunds a payment. You can refund the entire payment amount or a
|
86
|
-
# portion of it.
|
92
|
+
# portion of it. You can use this endpoint to refund a card payment or
|
93
|
+
# record a
|
94
|
+
# refund of a cash or external payment. For more information, see
|
95
|
+
# [Refund
|
96
|
+
# Payment](https://developer.squareup.com/docs/payments-api/refund-payments)
|
97
|
+
# .
|
87
98
|
# @param [RefundPaymentRequest] body Required parameter: An object
|
88
99
|
# containing the fields to POST for the request. See the corresponding
|
89
100
|
# object definition for field details.
|
@@ -97,7 +108,7 @@ module Square
|
|
97
108
|
# Prepare headers.
|
98
109
|
_headers = {
|
99
110
|
'accept' => 'application/json',
|
100
|
-
'
|
111
|
+
'Content-Type' => 'application/json'
|
101
112
|
}
|
102
113
|
|
103
114
|
# Prepare and execute HttpRequest.
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Square
|
2
|
+
# SitesApi
|
3
|
+
class SitesApi < BaseApi
|
4
|
+
def initialize(config, http_call_back: nil)
|
5
|
+
super(config, http_call_back: http_call_back)
|
6
|
+
end
|
7
|
+
|
8
|
+
# Lists the Square Online sites that belong to a seller. Sites are listed in
|
9
|
+
# descending order by the `created_at` date.
|
10
|
+
# __Note:__ Square Online APIs are publicly available as part of an early
|
11
|
+
# access program. For more information, see [Early access program for Square
|
12
|
+
# Online
|
13
|
+
# APIs](https://developer.squareup.com/docs/online-api#early-access-program-
|
14
|
+
# for-square-online-apis).
|
15
|
+
# @return [ListSitesResponse Hash] response from the API call
|
16
|
+
def list_sites
|
17
|
+
# Prepare query url.
|
18
|
+
_query_builder = config.get_base_uri
|
19
|
+
_query_builder << '/v2/sites'
|
20
|
+
_query_url = APIHelper.clean_url _query_builder
|
21
|
+
|
22
|
+
# Prepare headers.
|
23
|
+
_headers = {
|
24
|
+
'accept' => 'application/json'
|
25
|
+
}
|
26
|
+
|
27
|
+
# Prepare and execute HttpRequest.
|
28
|
+
_request = config.http_client.get(
|
29
|
+
_query_url,
|
30
|
+
headers: _headers
|
31
|
+
)
|
32
|
+
OAuth2.apply(config, _request)
|
33
|
+
_response = execute_request(_request)
|
34
|
+
|
35
|
+
# Return appropriate response type.
|
36
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
37
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
38
|
+
ApiResponse.new(
|
39
|
+
_response, data: decoded, errors: _errors
|
40
|
+
)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|