square.rb 8.1.0.20210121 → 18.1.0.20220316
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 +59 -213
- data/lib/square/api/apple_pay_api.rb +9 -8
- data/lib/square/api/bank_accounts_api.rb +5 -5
- data/lib/square/api/base_api.rb +20 -9
- data/lib/square/api/bookings_api.rb +95 -12
- data/lib/square/api/cards_api.rb +170 -0
- data/lib/square/api/cash_drawers_api.rb +2 -2
- data/lib/square/api/catalog_api.rb +140 -66
- data/lib/square/api/checkout_api.rb +3 -3
- 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 +61 -31
- data/lib/square/api/devices_api.rb +3 -2
- data/lib/square/api/disputes_api.rb +101 -92
- data/lib/square/api/gift_card_activities_api.rb +133 -0
- data/lib/square/api/gift_cards_api.rb +297 -0
- data/lib/square/api/inventory_api.rb +263 -24
- data/lib/square/api/invoices_api.rb +19 -19
- data/lib/square/api/labor_api.rb +70 -68
- data/lib/square/api/locations_api.rb +22 -14
- data/lib/square/api/loyalty_api.rb +86 -32
- 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 +31 -25
- data/lib/square/api/orders_api.rb +78 -39
- data/lib/square/api/payments_api.rb +71 -23
- 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 -12
- data/lib/square/api/team_api.rb +46 -46
- data/lib/square/api/terminal_api.rb +19 -18
- data/lib/square/api/transactions_api.rb +15 -191
- data/lib/square/api/v1_transactions_api.rb +13 -85
- data/lib/square/api/vendors_api.rb +257 -0
- data/lib/square/api_helper.rb +45 -57
- data/lib/square/client.rb +54 -18
- data/lib/square/configuration.rb +59 -20
- data/lib/square/http/api_response.rb +1 -1
- data/lib/square/http/faraday_client.rb +24 -4
- data/lib/square/utilities/date_time_helper.rb +151 -0
- data/lib/square/utilities/file_wrapper.rb +1 -2
- data/lib/square.rb +49 -44
- data/test/api/test_locations_api.rb +2 -5
- data/test/test_helper.rb +1 -1
- metadata +11 -6
- data/lib/square/api/v1_employees_api.rb +0 -749
- data/lib/square/api/v1_items_api.rb +0 -1766
@@ -5,97 +5,33 @@ module Square
|
|
5
5
|
super(config, http_call_back: http_call_back)
|
6
6
|
end
|
7
7
|
|
8
|
-
# Lists refunds for one of a business's locations.
|
9
|
-
# In addition to full or partial tender refunds processed through Square
|
10
|
-
# APIs,
|
11
|
-
# refunds may result from itemized returns or exchanges through Square's
|
12
|
-
# Point of Sale applications.
|
13
|
-
# Refunds with a `status` of `PENDING` are not currently included in this
|
14
|
-
# endpoint's response.
|
15
|
-
# Max results per [page](#paginatingresults): 50
|
16
|
-
# @param [String] location_id Required parameter: The ID of the location to
|
17
|
-
# list refunds for.
|
18
|
-
# @param [String] begin_time Optional parameter: The beginning of the
|
19
|
-
# requested reporting period, in RFC 3339 format. See [Date
|
20
|
-
# ranges](#dateranges) for details on date inclusivity/exclusivity. Default
|
21
|
-
# value: The current time minus one year.
|
22
|
-
# @param [String] end_time Optional parameter: The end of the requested
|
23
|
-
# reporting period, in RFC 3339 format. See [Date ranges](#dateranges) for
|
24
|
-
# details on date inclusivity/exclusivity. Default value: The current
|
25
|
-
# time.
|
26
|
-
# @param [SortOrder] sort_order Optional parameter: The order in which
|
27
|
-
# results are listed in the response (`ASC` for oldest first, `DESC` for
|
28
|
-
# newest first). Default value: `DESC`
|
29
|
-
# @param [String] cursor Optional parameter: A pagination cursor returned by
|
30
|
-
# a previous call to this endpoint. Provide this to retrieve the next set of
|
31
|
-
# results for your original query. See [Paginating
|
32
|
-
# results](#paginatingresults) for more information.
|
33
|
-
# @return [ListRefundsResponse Hash] response from the API call
|
34
|
-
def list_refunds(location_id:,
|
35
|
-
begin_time: nil,
|
36
|
-
end_time: nil,
|
37
|
-
sort_order: nil,
|
38
|
-
cursor: nil)
|
39
|
-
warn 'Endpoint list_refunds in TransactionsApi is deprecated'
|
40
|
-
# Prepare query url.
|
41
|
-
_query_builder = config.get_base_uri
|
42
|
-
_query_builder << '/v2/locations/{location_id}/refunds'
|
43
|
-
_query_builder = APIHelper.append_url_with_template_parameters(
|
44
|
-
_query_builder,
|
45
|
-
'location_id' => { 'value' => location_id, 'encode' => true }
|
46
|
-
)
|
47
|
-
_query_builder = APIHelper.append_url_with_query_parameters(
|
48
|
-
_query_builder,
|
49
|
-
'begin_time' => begin_time,
|
50
|
-
'end_time' => end_time,
|
51
|
-
'sort_order' => sort_order,
|
52
|
-
'cursor' => cursor
|
53
|
-
)
|
54
|
-
_query_url = APIHelper.clean_url _query_builder
|
55
|
-
|
56
|
-
# Prepare headers.
|
57
|
-
_headers = {
|
58
|
-
'accept' => 'application/json'
|
59
|
-
}
|
60
|
-
|
61
|
-
# Prepare and execute HttpRequest.
|
62
|
-
_request = config.http_client.get(
|
63
|
-
_query_url,
|
64
|
-
headers: _headers
|
65
|
-
)
|
66
|
-
OAuth2.apply(config, _request)
|
67
|
-
_response = execute_request(_request)
|
68
|
-
|
69
|
-
# Return appropriate response type.
|
70
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
71
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
72
|
-
ApiResponse.new(
|
73
|
-
_response, data: decoded, errors: _errors
|
74
|
-
)
|
75
|
-
end
|
76
|
-
|
77
8
|
# Lists transactions for a particular location.
|
78
9
|
# Transactions include payment information from sales and exchanges and
|
79
10
|
# refund
|
80
11
|
# information from returns and exchanges.
|
81
|
-
# Max results per
|
12
|
+
# Max results per
|
13
|
+
# [page](https://developer.squareup.com/docs/working-with-apis/pagination):
|
14
|
+
# 50
|
82
15
|
# @param [String] location_id Required parameter: The ID of the location to
|
83
16
|
# list transactions for.
|
84
17
|
# @param [String] begin_time Optional parameter: The beginning of the
|
85
18
|
# requested reporting period, in RFC 3339 format. See [Date
|
86
|
-
# ranges](
|
87
|
-
#
|
19
|
+
# ranges](https://developer.squareup.com/docs/build-basics/working-with-date
|
20
|
+
# s) for details on date inclusivity/exclusivity. Default value: The
|
21
|
+
# current time minus one year.
|
88
22
|
# @param [String] end_time Optional parameter: The end of the requested
|
89
|
-
# reporting period, in RFC 3339 format. See [Date
|
90
|
-
#
|
91
|
-
#
|
23
|
+
# reporting period, in RFC 3339 format. See [Date
|
24
|
+
# ranges](https://developer.squareup.com/docs/build-basics/working-with-date
|
25
|
+
# s) for details on date inclusivity/exclusivity. Default value: The
|
26
|
+
# current time.
|
92
27
|
# @param [SortOrder] sort_order Optional parameter: The order in which
|
93
28
|
# results are listed in the response (`ASC` for oldest first, `DESC` for
|
94
29
|
# newest first). Default value: `DESC`
|
95
30
|
# @param [String] cursor Optional parameter: A pagination cursor returned by
|
96
31
|
# a previous call to this endpoint. Provide this to retrieve the next set of
|
97
32
|
# results for your original query. See [Paginating
|
98
|
-
# results](
|
33
|
+
# results](https://developer.squareup.com/docs/working-with-apis/pagination)
|
34
|
+
# for more information.
|
99
35
|
# @return [ListTransactionsResponse Hash] response from the API call
|
100
36
|
def list_transactions(location_id:,
|
101
37
|
begin_time: nil,
|
@@ -140,66 +76,6 @@ module Square
|
|
140
76
|
)
|
141
77
|
end
|
142
78
|
|
143
|
-
# Charges a card represented by a card nonce or a customer's card on file.
|
144
|
-
# Your request to this endpoint must include _either_:
|
145
|
-
# - A value for the `card_nonce` parameter (to charge a card nonce generated
|
146
|
-
# with the `SqPaymentForm`)
|
147
|
-
# - Values for the `customer_card_id` and `customer_id` parameters (to
|
148
|
-
# charge
|
149
|
-
# a customer's card on file)
|
150
|
-
# In order for an eCommerce payment to potentially qualify for
|
151
|
-
# [Square chargeback protection](https://squareup.com/help/article/5394),
|
152
|
-
# you
|
153
|
-
# _must_ provide values for the following parameters in your request:
|
154
|
-
# - `buyer_email_address`
|
155
|
-
# - At least one of `billing_address` or `shipping_address`
|
156
|
-
# When this response is returned, the amount of Square's processing fee
|
157
|
-
# might not yet be
|
158
|
-
# calculated. To obtain the processing fee, wait about ten seconds and call
|
159
|
-
# [RetrieveTransaction](#endpoint-retrievetransaction). See the
|
160
|
-
# `processing_fee_money`
|
161
|
-
# field of each [Tender included](#type-tender) in the transaction.
|
162
|
-
# @param [String] location_id Required parameter: The ID of the location to
|
163
|
-
# associate the created transaction with.
|
164
|
-
# @param [ChargeRequest] body Required parameter: An object containing the
|
165
|
-
# fields to POST for the request. See the corresponding object definition
|
166
|
-
# for field details.
|
167
|
-
# @return [ChargeResponse Hash] response from the API call
|
168
|
-
def charge(location_id:,
|
169
|
-
body:)
|
170
|
-
warn 'Endpoint charge in TransactionsApi is deprecated'
|
171
|
-
# Prepare query url.
|
172
|
-
_query_builder = config.get_base_uri
|
173
|
-
_query_builder << '/v2/locations/{location_id}/transactions'
|
174
|
-
_query_builder = APIHelper.append_url_with_template_parameters(
|
175
|
-
_query_builder,
|
176
|
-
'location_id' => { 'value' => location_id, 'encode' => true }
|
177
|
-
)
|
178
|
-
_query_url = APIHelper.clean_url _query_builder
|
179
|
-
|
180
|
-
# Prepare headers.
|
181
|
-
_headers = {
|
182
|
-
'accept' => 'application/json',
|
183
|
-
'content-type' => 'application/json; charset=utf-8'
|
184
|
-
}
|
185
|
-
|
186
|
-
# Prepare and execute HttpRequest.
|
187
|
-
_request = config.http_client.post(
|
188
|
-
_query_url,
|
189
|
-
headers: _headers,
|
190
|
-
parameters: body.to_json
|
191
|
-
)
|
192
|
-
OAuth2.apply(config, _request)
|
193
|
-
_response = execute_request(_request)
|
194
|
-
|
195
|
-
# Return appropriate response type.
|
196
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
197
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
198
|
-
ApiResponse.new(
|
199
|
-
_response, data: decoded, errors: _errors
|
200
|
-
)
|
201
|
-
end
|
202
|
-
|
203
79
|
# Retrieves details for a single transaction.
|
204
80
|
# @param [String] location_id Required parameter: The ID of the
|
205
81
|
# transaction's associated location.
|
@@ -241,7 +117,7 @@ module Square
|
|
241
117
|
end
|
242
118
|
|
243
119
|
# Captures a transaction that was created with the
|
244
|
-
# [Charge](
|
120
|
+
# [Charge]($e/Transactions/Charge)
|
245
121
|
# endpoint with a `delay_capture` value of `true`.
|
246
122
|
# See [Delayed capture
|
247
123
|
# transactions](https://developer.squareup.com/docs/payments/transactions/ov
|
@@ -284,60 +160,8 @@ module Square
|
|
284
160
|
)
|
285
161
|
end
|
286
162
|
|
287
|
-
#
|
288
|
-
#
|
289
|
-
# [this article](https://squareup.com/help/us/en/article/5060) for more
|
290
|
-
# information
|
291
|
-
# on refund behavior.
|
292
|
-
# NOTE: Card-present transactions with Interac credit cards **cannot be
|
293
|
-
# refunded using the Connect API**. Interac transactions must refunded
|
294
|
-
# in-person (e.g., dipping the card using POS app).
|
295
|
-
# @param [String] location_id Required parameter: The ID of the original
|
296
|
-
# transaction's associated location.
|
297
|
-
# @param [String] transaction_id Required parameter: The ID of the original
|
298
|
-
# transaction that includes the tender to refund.
|
299
|
-
# @param [CreateRefundRequest] body Required parameter: An object containing
|
300
|
-
# the fields to POST for the request. See the corresponding object
|
301
|
-
# definition for field details.
|
302
|
-
# @return [CreateRefundResponse Hash] response from the API call
|
303
|
-
def create_refund(location_id:,
|
304
|
-
transaction_id:,
|
305
|
-
body:)
|
306
|
-
warn 'Endpoint create_refund in TransactionsApi is deprecated'
|
307
|
-
# Prepare query url.
|
308
|
-
_query_builder = config.get_base_uri
|
309
|
-
_query_builder << '/v2/locations/{location_id}/transactions/{transaction_id}/refund'
|
310
|
-
_query_builder = APIHelper.append_url_with_template_parameters(
|
311
|
-
_query_builder,
|
312
|
-
'location_id' => { 'value' => location_id, 'encode' => true },
|
313
|
-
'transaction_id' => { 'value' => transaction_id, 'encode' => true }
|
314
|
-
)
|
315
|
-
_query_url = APIHelper.clean_url _query_builder
|
316
|
-
|
317
|
-
# Prepare headers.
|
318
|
-
_headers = {
|
319
|
-
'accept' => 'application/json',
|
320
|
-
'content-type' => 'application/json; charset=utf-8'
|
321
|
-
}
|
322
|
-
|
323
|
-
# Prepare and execute HttpRequest.
|
324
|
-
_request = config.http_client.post(
|
325
|
-
_query_url,
|
326
|
-
headers: _headers,
|
327
|
-
parameters: body.to_json
|
328
|
-
)
|
329
|
-
OAuth2.apply(config, _request)
|
330
|
-
_response = execute_request(_request)
|
331
|
-
|
332
|
-
# Return appropriate response type.
|
333
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
334
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
335
|
-
ApiResponse.new(
|
336
|
-
_response, data: decoded, errors: _errors
|
337
|
-
)
|
338
|
-
end
|
339
|
-
|
340
|
-
# Cancels a transaction that was created with the [Charge](#endpoint-charge)
|
163
|
+
# Cancels a transaction that was created with the
|
164
|
+
# [Charge]($e/Transactions/Charge)
|
341
165
|
# endpoint with a `delay_capture` value of `true`.
|
342
166
|
# See [Delayed capture
|
343
167
|
# transactions](https://developer.squareup.com/docs/payments/transactions/ov
|
@@ -5,91 +5,10 @@ module Square
|
|
5
5
|
super(config, http_call_back: http_call_back)
|
6
6
|
end
|
7
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
|
-
warn 'Endpoint list_bank_accounts in V1TransactionsApi is deprecated'
|
16
|
-
# Prepare query url.
|
17
|
-
_query_builder = config.get_base_uri
|
18
|
-
_query_builder << '/v1/{location_id}/bank-accounts'
|
19
|
-
_query_builder = APIHelper.append_url_with_template_parameters(
|
20
|
-
_query_builder,
|
21
|
-
'location_id' => { 'value' => location_id, 'encode' => true }
|
22
|
-
)
|
23
|
-
_query_url = APIHelper.clean_url _query_builder
|
24
|
-
|
25
|
-
# Prepare headers.
|
26
|
-
_headers = {
|
27
|
-
'accept' => 'application/json'
|
28
|
-
}
|
29
|
-
|
30
|
-
# Prepare and execute HttpRequest.
|
31
|
-
_request = config.http_client.get(
|
32
|
-
_query_url,
|
33
|
-
headers: _headers
|
34
|
-
)
|
35
|
-
OAuth2.apply(config, _request)
|
36
|
-
_response = execute_request(_request)
|
37
|
-
|
38
|
-
# Return appropriate response type.
|
39
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
40
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
41
|
-
ApiResponse.new(
|
42
|
-
_response, data: decoded, errors: _errors
|
43
|
-
)
|
44
|
-
end
|
45
|
-
|
46
|
-
# Provides non-confidential details for a merchant's associated bank
|
47
|
-
# account. This endpoint does not provide full bank account numbers, and
|
48
|
-
# there is no way to obtain a full bank account number with the Connect API.
|
49
|
-
# @param [String] location_id Required parameter: The ID of the bank
|
50
|
-
# account's associated location.
|
51
|
-
# @param [String] bank_account_id Required parameter: The bank account's
|
52
|
-
# Square-issued ID. You obtain this value from Settlement objects
|
53
|
-
# returned.
|
54
|
-
# @return [V1BankAccount Hash] response from the API call
|
55
|
-
def retrieve_bank_account(location_id:,
|
56
|
-
bank_account_id:)
|
57
|
-
warn 'Endpoint retrieve_bank_account in V1TransactionsApi is deprecated'
|
58
|
-
# Prepare query url.
|
59
|
-
_query_builder = config.get_base_uri
|
60
|
-
_query_builder << '/v1/{location_id}/bank-accounts/{bank_account_id}'
|
61
|
-
_query_builder = APIHelper.append_url_with_template_parameters(
|
62
|
-
_query_builder,
|
63
|
-
'location_id' => { 'value' => location_id, 'encode' => true },
|
64
|
-
'bank_account_id' => { 'value' => bank_account_id, 'encode' => true }
|
65
|
-
)
|
66
|
-
_query_url = APIHelper.clean_url _query_builder
|
67
|
-
|
68
|
-
# Prepare headers.
|
69
|
-
_headers = {
|
70
|
-
'accept' => 'application/json'
|
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
|
-
)
|
87
|
-
end
|
88
|
-
|
89
8
|
# Provides summary information for a merchant's online store orders.
|
90
9
|
# @param [String] location_id Required parameter: The ID of the location to
|
91
10
|
# list online store orders for.
|
92
|
-
# @param [SortOrder] order Optional parameter:
|
11
|
+
# @param [SortOrder] order Optional parameter: The order in which payments
|
93
12
|
# are listed in the response.
|
94
13
|
# @param [Integer] limit Optional parameter: The maximum number of payments
|
95
14
|
# to return in a single response. This value cannot exceed 200.
|
@@ -101,6 +20,7 @@ module Square
|
|
101
20
|
order: nil,
|
102
21
|
limit: nil,
|
103
22
|
batch_token: nil)
|
23
|
+
warn 'Endpoint list_orders in V1TransactionsApi is deprecated'
|
104
24
|
# Prepare query url.
|
105
25
|
_query_builder = config.get_base_uri
|
106
26
|
_query_builder << '/v1/{location_id}/orders'
|
@@ -147,6 +67,7 @@ module Square
|
|
147
67
|
# @return [V1Order Hash] response from the API call
|
148
68
|
def retrieve_order(location_id:,
|
149
69
|
order_id:)
|
70
|
+
warn 'Endpoint retrieve_order in V1TransactionsApi is deprecated'
|
150
71
|
# Prepare query url.
|
151
72
|
_query_builder = config.get_base_uri
|
152
73
|
_query_builder << '/v1/{location_id}/orders/{order_id}'
|
@@ -192,6 +113,7 @@ module Square
|
|
192
113
|
def update_order(location_id:,
|
193
114
|
order_id:,
|
194
115
|
body:)
|
116
|
+
warn 'Endpoint update_order in V1TransactionsApi is deprecated'
|
195
117
|
# Prepare query url.
|
196
118
|
_query_builder = config.get_base_uri
|
197
119
|
_query_builder << '/v1/{location_id}/orders/{order_id}'
|
@@ -205,7 +127,7 @@ module Square
|
|
205
127
|
# Prepare headers.
|
206
128
|
_headers = {
|
207
129
|
'accept' => 'application/json',
|
208
|
-
'
|
130
|
+
'Content-Type' => 'application/json'
|
209
131
|
}
|
210
132
|
|
211
133
|
# Prepare and execute HttpRequest.
|
@@ -265,6 +187,7 @@ module Square
|
|
265
187
|
limit: nil,
|
266
188
|
batch_token: nil,
|
267
189
|
include_partial: false)
|
190
|
+
warn 'Endpoint list_payments in V1TransactionsApi is deprecated'
|
268
191
|
# Prepare query url.
|
269
192
|
_query_builder = config.get_base_uri
|
270
193
|
_query_builder << '/v1/{location_id}/payments'
|
@@ -314,6 +237,7 @@ module Square
|
|
314
237
|
# @return [V1Payment Hash] response from the API call
|
315
238
|
def retrieve_payment(location_id:,
|
316
239
|
payment_id:)
|
240
|
+
warn 'Endpoint retrieve_payment in V1TransactionsApi is deprecated'
|
317
241
|
# Prepare query url.
|
318
242
|
_query_builder = config.get_base_uri
|
319
243
|
_query_builder << '/v1/{location_id}/payments/{payment_id}'
|
@@ -350,7 +274,7 @@ module Square
|
|
350
274
|
# year in length.
|
351
275
|
# @param [String] location_id Required parameter: The ID of the location to
|
352
276
|
# list refunds for.
|
353
|
-
# @param [SortOrder] order Optional parameter:
|
277
|
+
# @param [SortOrder] order Optional parameter: The order in which payments
|
354
278
|
# are listed in the response.
|
355
279
|
# @param [String] begin_time Optional parameter: The beginning of the
|
356
280
|
# requested reporting period, in ISO 8601 format. If this value is before
|
@@ -375,6 +299,7 @@ module Square
|
|
375
299
|
end_time: nil,
|
376
300
|
limit: nil,
|
377
301
|
batch_token: nil)
|
302
|
+
warn 'Endpoint list_refunds in V1TransactionsApi is deprecated'
|
378
303
|
# Prepare query url.
|
379
304
|
_query_builder = config.get_base_uri
|
380
305
|
_query_builder << '/v1/{location_id}/refunds'
|
@@ -431,6 +356,7 @@ module Square
|
|
431
356
|
# @return [V1Refund Hash] response from the API call
|
432
357
|
def create_refund(location_id:,
|
433
358
|
body:)
|
359
|
+
warn 'Endpoint create_refund in V1TransactionsApi is deprecated'
|
434
360
|
# Prepare query url.
|
435
361
|
_query_builder = config.get_base_uri
|
436
362
|
_query_builder << '/v1/{location_id}/refunds'
|
@@ -443,7 +369,7 @@ module Square
|
|
443
369
|
# Prepare headers.
|
444
370
|
_headers = {
|
445
371
|
'accept' => 'application/json',
|
446
|
-
'
|
372
|
+
'Content-Type' => 'application/json'
|
447
373
|
}
|
448
374
|
|
449
375
|
# Prepare and execute HttpRequest.
|
@@ -498,6 +424,7 @@ module Square
|
|
498
424
|
limit: nil,
|
499
425
|
status: nil,
|
500
426
|
batch_token: nil)
|
427
|
+
warn 'Endpoint list_settlements in V1TransactionsApi is deprecated'
|
501
428
|
# Prepare query url.
|
502
429
|
_query_builder = config.get_base_uri
|
503
430
|
_query_builder << '/v1/{location_id}/settlements'
|
@@ -560,6 +487,7 @@ module Square
|
|
560
487
|
# @return [V1Settlement Hash] response from the API call
|
561
488
|
def retrieve_settlement(location_id:,
|
562
489
|
settlement_id:)
|
490
|
+
warn 'Endpoint retrieve_settlement in V1TransactionsApi is deprecated'
|
563
491
|
# Prepare query url.
|
564
492
|
_query_builder = config.get_base_uri
|
565
493
|
_query_builder << '/v1/{location_id}/settlements/{settlement_id}'
|
@@ -0,0 +1,257 @@
|
|
1
|
+
module Square
|
2
|
+
# VendorsApi
|
3
|
+
class VendorsApi < BaseApi
|
4
|
+
def initialize(config, http_call_back: nil)
|
5
|
+
super(config, http_call_back: http_call_back)
|
6
|
+
end
|
7
|
+
|
8
|
+
# Creates one or more [Vendor]($m/Vendor) objects to represent suppliers to
|
9
|
+
# a seller.
|
10
|
+
# @param [BulkCreateVendorsRequest] body Required parameter: An object
|
11
|
+
# containing the fields to POST for the request. See the corresponding
|
12
|
+
# object definition for field details.
|
13
|
+
# @return [BulkCreateVendorsResponse Hash] response from the API call
|
14
|
+
def bulk_create_vendors(body:)
|
15
|
+
# Prepare query url.
|
16
|
+
_query_builder = config.get_base_uri
|
17
|
+
_query_builder << '/v2/vendors/bulk-create'
|
18
|
+
_query_url = APIHelper.clean_url _query_builder
|
19
|
+
|
20
|
+
# Prepare headers.
|
21
|
+
_headers = {
|
22
|
+
'accept' => 'application/json',
|
23
|
+
'Content-Type' => 'application/json'
|
24
|
+
}
|
25
|
+
|
26
|
+
# Prepare and execute HttpRequest.
|
27
|
+
_request = config.http_client.post(
|
28
|
+
_query_url,
|
29
|
+
headers: _headers,
|
30
|
+
parameters: body.to_json
|
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
|
+
|
43
|
+
# Retrieves one or more vendors of specified [Vendor]($m/Vendor) IDs.
|
44
|
+
# @param [BulkRetrieveVendorsRequest] body Required parameter: An object
|
45
|
+
# containing the fields to POST for the request. See the corresponding
|
46
|
+
# object definition for field details.
|
47
|
+
# @return [BulkRetrieveVendorsResponse Hash] response from the API call
|
48
|
+
def bulk_retrieve_vendors(body:)
|
49
|
+
# Prepare query url.
|
50
|
+
_query_builder = config.get_base_uri
|
51
|
+
_query_builder << '/v2/vendors/bulk-retrieve'
|
52
|
+
_query_url = APIHelper.clean_url _query_builder
|
53
|
+
|
54
|
+
# Prepare headers.
|
55
|
+
_headers = {
|
56
|
+
'accept' => 'application/json',
|
57
|
+
'Content-Type' => 'application/json'
|
58
|
+
}
|
59
|
+
|
60
|
+
# Prepare and execute HttpRequest.
|
61
|
+
_request = config.http_client.post(
|
62
|
+
_query_url,
|
63
|
+
headers: _headers,
|
64
|
+
parameters: body.to_json
|
65
|
+
)
|
66
|
+
OAuth2.apply(config, _request)
|
67
|
+
_response = execute_request(_request)
|
68
|
+
|
69
|
+
# Return appropriate response type.
|
70
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
71
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
72
|
+
ApiResponse.new(
|
73
|
+
_response, data: decoded, errors: _errors
|
74
|
+
)
|
75
|
+
end
|
76
|
+
|
77
|
+
# Updates one or more of existing [Vendor]($m/Vendor) objects as suppliers
|
78
|
+
# to a seller.
|
79
|
+
# @param [BulkUpdateVendorsRequest] body Required parameter: An object
|
80
|
+
# containing the fields to POST for the request. See the corresponding
|
81
|
+
# object definition for field details.
|
82
|
+
# @return [BulkUpdateVendorsResponse Hash] response from the API call
|
83
|
+
def bulk_update_vendors(body:)
|
84
|
+
# Prepare query url.
|
85
|
+
_query_builder = config.get_base_uri
|
86
|
+
_query_builder << '/v2/vendors/bulk-update'
|
87
|
+
_query_url = APIHelper.clean_url _query_builder
|
88
|
+
|
89
|
+
# Prepare headers.
|
90
|
+
_headers = {
|
91
|
+
'accept' => 'application/json',
|
92
|
+
'Content-Type' => 'application/json'
|
93
|
+
}
|
94
|
+
|
95
|
+
# Prepare and execute HttpRequest.
|
96
|
+
_request = config.http_client.put(
|
97
|
+
_query_url,
|
98
|
+
headers: _headers,
|
99
|
+
parameters: body.to_json
|
100
|
+
)
|
101
|
+
OAuth2.apply(config, _request)
|
102
|
+
_response = execute_request(_request)
|
103
|
+
|
104
|
+
# Return appropriate response type.
|
105
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
106
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
107
|
+
ApiResponse.new(
|
108
|
+
_response, data: decoded, errors: _errors
|
109
|
+
)
|
110
|
+
end
|
111
|
+
|
112
|
+
# Creates a single [Vendor]($m/Vendor) object to represent a supplier to a
|
113
|
+
# seller.
|
114
|
+
# @param [CreateVendorRequest] body Required parameter: An object containing
|
115
|
+
# the fields to POST for the request. See the corresponding object
|
116
|
+
# definition for field details.
|
117
|
+
# @return [CreateVendorResponse Hash] response from the API call
|
118
|
+
def create_vendor(body:)
|
119
|
+
# Prepare query url.
|
120
|
+
_query_builder = config.get_base_uri
|
121
|
+
_query_builder << '/v2/vendors/create'
|
122
|
+
_query_url = APIHelper.clean_url _query_builder
|
123
|
+
|
124
|
+
# Prepare headers.
|
125
|
+
_headers = {
|
126
|
+
'accept' => 'application/json',
|
127
|
+
'Content-Type' => 'application/json'
|
128
|
+
}
|
129
|
+
|
130
|
+
# Prepare and execute HttpRequest.
|
131
|
+
_request = config.http_client.post(
|
132
|
+
_query_url,
|
133
|
+
headers: _headers,
|
134
|
+
parameters: body.to_json
|
135
|
+
)
|
136
|
+
OAuth2.apply(config, _request)
|
137
|
+
_response = execute_request(_request)
|
138
|
+
|
139
|
+
# Return appropriate response type.
|
140
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
141
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
142
|
+
ApiResponse.new(
|
143
|
+
_response, data: decoded, errors: _errors
|
144
|
+
)
|
145
|
+
end
|
146
|
+
|
147
|
+
# Searches for vendors using a filter against supported [Vendor]($m/Vendor)
|
148
|
+
# properties and a supported sorter.
|
149
|
+
# @param [SearchVendorsRequest] body Required parameter: An object
|
150
|
+
# containing the fields to POST for the request. See the corresponding
|
151
|
+
# object definition for field details.
|
152
|
+
# @return [SearchVendorsResponse Hash] response from the API call
|
153
|
+
def search_vendors(body:)
|
154
|
+
# Prepare query url.
|
155
|
+
_query_builder = config.get_base_uri
|
156
|
+
_query_builder << '/v2/vendors/search'
|
157
|
+
_query_url = APIHelper.clean_url _query_builder
|
158
|
+
|
159
|
+
# Prepare headers.
|
160
|
+
_headers = {
|
161
|
+
'accept' => 'application/json',
|
162
|
+
'Content-Type' => 'application/json'
|
163
|
+
}
|
164
|
+
|
165
|
+
# Prepare and execute HttpRequest.
|
166
|
+
_request = config.http_client.post(
|
167
|
+
_query_url,
|
168
|
+
headers: _headers,
|
169
|
+
parameters: body.to_json
|
170
|
+
)
|
171
|
+
OAuth2.apply(config, _request)
|
172
|
+
_response = execute_request(_request)
|
173
|
+
|
174
|
+
# Return appropriate response type.
|
175
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
176
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
177
|
+
ApiResponse.new(
|
178
|
+
_response, data: decoded, errors: _errors
|
179
|
+
)
|
180
|
+
end
|
181
|
+
|
182
|
+
# Retrieves the vendor of a specified [Vendor]($m/Vendor) ID.
|
183
|
+
# @param [String] vendor_id Required parameter: ID of the
|
184
|
+
# [Vendor]($m/Vendor) to retrieve.
|
185
|
+
# @return [RetrieveVendorResponse Hash] response from the API call
|
186
|
+
def retrieve_vendor(vendor_id:)
|
187
|
+
# Prepare query url.
|
188
|
+
_query_builder = config.get_base_uri
|
189
|
+
_query_builder << '/v2/vendors/{vendor_id}'
|
190
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
191
|
+
_query_builder,
|
192
|
+
'vendor_id' => { 'value' => vendor_id, 'encode' => true }
|
193
|
+
)
|
194
|
+
_query_url = APIHelper.clean_url _query_builder
|
195
|
+
|
196
|
+
# Prepare headers.
|
197
|
+
_headers = {
|
198
|
+
'accept' => 'application/json'
|
199
|
+
}
|
200
|
+
|
201
|
+
# Prepare and execute HttpRequest.
|
202
|
+
_request = config.http_client.get(
|
203
|
+
_query_url,
|
204
|
+
headers: _headers
|
205
|
+
)
|
206
|
+
OAuth2.apply(config, _request)
|
207
|
+
_response = execute_request(_request)
|
208
|
+
|
209
|
+
# Return appropriate response type.
|
210
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
211
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
212
|
+
ApiResponse.new(
|
213
|
+
_response, data: decoded, errors: _errors
|
214
|
+
)
|
215
|
+
end
|
216
|
+
|
217
|
+
# Updates an existing [Vendor]($m/Vendor) object as a supplier to a seller.
|
218
|
+
# @param [UpdateVendorRequest] body Required parameter: An object containing
|
219
|
+
# the fields to POST for the request. See the corresponding object
|
220
|
+
# definition for field details.
|
221
|
+
# @param [String] vendor_id Required parameter: Example:
|
222
|
+
# @return [UpdateVendorResponse Hash] response from the API call
|
223
|
+
def update_vendor(body:,
|
224
|
+
vendor_id:)
|
225
|
+
# Prepare query url.
|
226
|
+
_query_builder = config.get_base_uri
|
227
|
+
_query_builder << '/v2/vendors/{vendor_id}'
|
228
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
229
|
+
_query_builder,
|
230
|
+
'vendor_id' => { 'value' => vendor_id, 'encode' => true }
|
231
|
+
)
|
232
|
+
_query_url = APIHelper.clean_url _query_builder
|
233
|
+
|
234
|
+
# Prepare headers.
|
235
|
+
_headers = {
|
236
|
+
'accept' => 'application/json',
|
237
|
+
'Content-Type' => 'application/json'
|
238
|
+
}
|
239
|
+
|
240
|
+
# Prepare and execute HttpRequest.
|
241
|
+
_request = config.http_client.put(
|
242
|
+
_query_url,
|
243
|
+
headers: _headers,
|
244
|
+
parameters: body.to_json
|
245
|
+
)
|
246
|
+
OAuth2.apply(config, _request)
|
247
|
+
_response = execute_request(_request)
|
248
|
+
|
249
|
+
# Return appropriate response type.
|
250
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
251
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
252
|
+
ApiResponse.new(
|
253
|
+
_response, data: decoded, errors: _errors
|
254
|
+
)
|
255
|
+
end
|
256
|
+
end
|
257
|
+
end
|