square.rb 15.0.0.20211020 → 17.1.0.20220120
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 +2 -2
- data/lib/square/api/apple_pay_api.rb +1 -1
- data/lib/square/api/base_api.rb +16 -1
- data/lib/square/api/bookings_api.rb +92 -7
- data/lib/square/api/cards_api.rb +1 -1
- data/lib/square/api/catalog_api.rb +109 -34
- data/lib/square/api/checkout_api.rb +1 -1
- data/lib/square/api/customer_groups_api.rb +2 -2
- data/lib/square/api/customers_api.rb +4 -4
- data/lib/square/api/devices_api.rb +1 -1
- data/lib/square/api/disputes_api.rb +1 -1
- data/lib/square/api/gift_card_activities_api.rb +26 -20
- data/lib/square/api/gift_cards_api.rb +29 -24
- data/lib/square/api/inventory_api.rb +6 -6
- data/lib/square/api/invoices_api.rb +5 -5
- data/lib/square/api/labor_api.rb +6 -6
- data/lib/square/api/locations_api.rb +22 -13
- data/lib/square/api/loyalty_api.rb +14 -23
- data/lib/square/api/mobile_authorization_api.rb +4 -4
- data/lib/square/api/o_auth_api.rb +10 -10
- data/lib/square/api/orders_api.rb +7 -7
- data/lib/square/api/payments_api.rb +4 -4
- data/lib/square/api/refunds_api.rb +8 -5
- data/lib/square/api/sites_api.rb +2 -1
- data/lib/square/api/snippets_api.rb +1 -1
- data/lib/square/api/subscriptions_api.rb +159 -16
- data/lib/square/api/team_api.rb +6 -6
- data/lib/square/api/terminal_api.rb +4 -4
- data/lib/square/api/v1_transactions_api.rb +2 -2
- data/lib/square/client.rb +8 -3
- data/lib/square/configuration.rb +15 -4
- data/test/api/test_locations_api.rb +2 -5
- data/test/test_helper.rb +1 -1
- metadata +2 -5
@@ -31,10 +31,13 @@ module Square
|
|
31
31
|
# the given status are returned. For a list of refund status values, see
|
32
32
|
# [PaymentRefund]($m/PaymentRefund). Default: If omitted, refunds are
|
33
33
|
# returned regardless of their status.
|
34
|
-
# @param [String] source_type Optional parameter: If provided, only
|
35
|
-
#
|
36
|
-
#
|
37
|
-
#
|
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.
|
38
41
|
# @param [Integer] limit Optional parameter: The maximum number of results
|
39
42
|
# to be returned in a single page. It is possible to receive fewer results
|
40
43
|
# than the specified limit on a given page. If the supplied value is
|
@@ -105,7 +108,7 @@ module Square
|
|
105
108
|
# Prepare headers.
|
106
109
|
_headers = {
|
107
110
|
'accept' => 'application/json',
|
108
|
-
'
|
111
|
+
'Content-Type' => 'application/json'
|
109
112
|
}
|
110
113
|
|
111
114
|
# Prepare and execute HttpRequest.
|
data/lib/square/api/sites_api.rb
CHANGED
@@ -5,7 +5,8 @@ module Square
|
|
5
5
|
super(config, http_call_back: http_call_back)
|
6
6
|
end
|
7
7
|
|
8
|
-
# Lists the Square Online sites that belong to a seller.
|
8
|
+
# Lists the Square Online sites that belong to a seller. Sites are listed in
|
9
|
+
# descending order by the `created_at` date.
|
9
10
|
# __Note:__ Square Online APIs are publicly available as part of an early
|
10
11
|
# access program. For more information, see [Early access program for Square
|
11
12
|
# Online
|
@@ -5,7 +5,7 @@ module Square
|
|
5
5
|
super(config, http_call_back: http_call_back)
|
6
6
|
end
|
7
7
|
|
8
|
-
# Creates a subscription
|
8
|
+
# Creates a subscription to a subscription plan by a customer.
|
9
9
|
# If you provide a card on file in the request, Square charges the card for
|
10
10
|
# the subscription. Otherwise, Square bills an invoice to the customer's
|
11
11
|
# email
|
@@ -25,7 +25,7 @@ module Square
|
|
25
25
|
# Prepare headers.
|
26
26
|
_headers = {
|
27
27
|
'accept' => 'application/json',
|
28
|
-
'
|
28
|
+
'Content-Type' => 'application/json'
|
29
29
|
}
|
30
30
|
|
31
31
|
# Prepare and execute HttpRequest.
|
@@ -75,7 +75,7 @@ module Square
|
|
75
75
|
# Prepare headers.
|
76
76
|
_headers = {
|
77
77
|
'accept' => 'application/json',
|
78
|
-
'
|
78
|
+
'Content-Type' => 'application/json'
|
79
79
|
}
|
80
80
|
|
81
81
|
# Prepare and execute HttpRequest.
|
@@ -98,8 +98,13 @@ module Square
|
|
98
98
|
# Retrieves a subscription.
|
99
99
|
# @param [String] subscription_id Required parameter: The ID of the
|
100
100
|
# subscription to retrieve.
|
101
|
+
# @param [String] include Optional parameter: A query parameter to specify
|
102
|
+
# related information to be included in the response. The supported query
|
103
|
+
# parameter values are: - `actions`: to include scheduled actions on the
|
104
|
+
# targeted subscription.
|
101
105
|
# @return [RetrieveSubscriptionResponse Hash] response from the API call
|
102
|
-
def retrieve_subscription(subscription_id
|
106
|
+
def retrieve_subscription(subscription_id:,
|
107
|
+
include: nil)
|
103
108
|
# Prepare query url.
|
104
109
|
_query_builder = config.get_base_uri
|
105
110
|
_query_builder << '/v2/subscriptions/{subscription_id}'
|
@@ -107,6 +112,10 @@ module Square
|
|
107
112
|
_query_builder,
|
108
113
|
'subscription_id' => { 'value' => subscription_id, 'encode' => true }
|
109
114
|
)
|
115
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
116
|
+
_query_builder,
|
117
|
+
'include' => include
|
118
|
+
)
|
110
119
|
_query_url = APIHelper.clean_url _query_builder
|
111
120
|
|
112
121
|
# Prepare headers.
|
@@ -132,7 +141,7 @@ module Square
|
|
132
141
|
|
133
142
|
# Updates a subscription. You can set, modify, and clear the
|
134
143
|
# `subscription` field values.
|
135
|
-
# @param [String] subscription_id Required parameter: The ID
|
144
|
+
# @param [String] subscription_id Required parameter: The ID of the
|
136
145
|
# subscription to update.
|
137
146
|
# @param [UpdateSubscriptionRequest] body Required parameter: An object
|
138
147
|
# containing the fields to POST for the request. See the corresponding
|
@@ -152,7 +161,7 @@ module Square
|
|
152
161
|
# Prepare headers.
|
153
162
|
_headers = {
|
154
163
|
'accept' => 'application/json',
|
155
|
-
'
|
164
|
+
'Content-Type' => 'application/json'
|
156
165
|
}
|
157
166
|
|
158
167
|
# Prepare and execute HttpRequest.
|
@@ -172,8 +181,50 @@ module Square
|
|
172
181
|
)
|
173
182
|
end
|
174
183
|
|
175
|
-
#
|
176
|
-
#
|
184
|
+
# Deletes a scheduled action for a subscription.
|
185
|
+
# @param [String] subscription_id Required parameter: The ID of the
|
186
|
+
# subscription the targeted action is to act upon.
|
187
|
+
# @param [String] action_id Required parameter: The ID of the targeted
|
188
|
+
# action to be deleted.
|
189
|
+
# @return [DeleteSubscriptionActionResponse Hash] response from the API call
|
190
|
+
def delete_subscription_action(subscription_id:,
|
191
|
+
action_id:)
|
192
|
+
# Prepare query url.
|
193
|
+
_query_builder = config.get_base_uri
|
194
|
+
_query_builder << '/v2/subscriptions/{subscription_id}/actions/{action_id}'
|
195
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
196
|
+
_query_builder,
|
197
|
+
'subscription_id' => { 'value' => subscription_id, 'encode' => true },
|
198
|
+
'action_id' => { 'value' => action_id, 'encode' => true }
|
199
|
+
)
|
200
|
+
_query_url = APIHelper.clean_url _query_builder
|
201
|
+
|
202
|
+
# Prepare headers.
|
203
|
+
_headers = {
|
204
|
+
'accept' => 'application/json'
|
205
|
+
}
|
206
|
+
|
207
|
+
# Prepare and execute HttpRequest.
|
208
|
+
_request = config.http_client.delete(
|
209
|
+
_query_url,
|
210
|
+
headers: _headers
|
211
|
+
)
|
212
|
+
OAuth2.apply(config, _request)
|
213
|
+
_response = execute_request(_request)
|
214
|
+
|
215
|
+
# Return appropriate response type.
|
216
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
217
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
218
|
+
ApiResponse.new(
|
219
|
+
_response, data: decoded, errors: _errors
|
220
|
+
)
|
221
|
+
end
|
222
|
+
|
223
|
+
# Schedules a `CANCEL` action to cancel an active subscription
|
224
|
+
# by setting the `canceled_date` field to the end of the active billing
|
225
|
+
# period
|
226
|
+
# and changing the subscription status from ACTIVE to CANCELED after this
|
227
|
+
# date.
|
177
228
|
# @param [String] subscription_id Required parameter: The ID of the
|
178
229
|
# subscription to cancel.
|
179
230
|
# @return [CancelSubscriptionResponse Hash] response from the API call
|
@@ -214,13 +265,15 @@ module Square
|
|
214
265
|
# returned.
|
215
266
|
# @param [String] subscription_id Required parameter: The ID of the
|
216
267
|
# subscription to retrieve the events for.
|
217
|
-
# @param [String] cursor Optional parameter:
|
218
|
-
#
|
219
|
-
#
|
268
|
+
# @param [String] cursor Optional parameter: When the total number of
|
269
|
+
# resulting subscription events exceeds the limit of a paged response,
|
270
|
+
# specify the cursor returned from a preceding response here to fetch the
|
271
|
+
# next set of results. If the cursor is unset, the response contains the
|
272
|
+
# last page of the results. For more information, see
|
220
273
|
# [Pagination](https://developer.squareup.com/docs/working-with-apis/paginat
|
221
274
|
# ion).
|
222
275
|
# @param [Integer] limit Optional parameter: The upper limit on the number
|
223
|
-
# of subscription events to return in
|
276
|
+
# of subscription events to return in a paged response.
|
224
277
|
# @return [ListSubscriptionEventsResponse Hash] response from the API call
|
225
278
|
def list_subscription_events(subscription_id:,
|
226
279
|
cursor: nil,
|
@@ -260,11 +313,57 @@ module Square
|
|
260
313
|
)
|
261
314
|
end
|
262
315
|
|
263
|
-
#
|
316
|
+
# Schedules a `PAUSE` action to pause an active subscription.
|
317
|
+
# @param [String] subscription_id Required parameter: The ID of the
|
318
|
+
# subscription to pause.
|
319
|
+
# @param [PauseSubscriptionRequest] body Required parameter: An object
|
320
|
+
# containing the fields to POST for the request. See the corresponding
|
321
|
+
# object definition for field details.
|
322
|
+
# @return [PauseSubscriptionResponse Hash] response from the API call
|
323
|
+
def pause_subscription(subscription_id:,
|
324
|
+
body:)
|
325
|
+
# Prepare query url.
|
326
|
+
_query_builder = config.get_base_uri
|
327
|
+
_query_builder << '/v2/subscriptions/{subscription_id}/pause'
|
328
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
329
|
+
_query_builder,
|
330
|
+
'subscription_id' => { 'value' => subscription_id, 'encode' => true }
|
331
|
+
)
|
332
|
+
_query_url = APIHelper.clean_url _query_builder
|
333
|
+
|
334
|
+
# Prepare headers.
|
335
|
+
_headers = {
|
336
|
+
'accept' => 'application/json',
|
337
|
+
'Content-Type' => 'application/json'
|
338
|
+
}
|
339
|
+
|
340
|
+
# Prepare and execute HttpRequest.
|
341
|
+
_request = config.http_client.post(
|
342
|
+
_query_url,
|
343
|
+
headers: _headers,
|
344
|
+
parameters: body.to_json
|
345
|
+
)
|
346
|
+
OAuth2.apply(config, _request)
|
347
|
+
_response = execute_request(_request)
|
348
|
+
|
349
|
+
# Return appropriate response type.
|
350
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
351
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
352
|
+
ApiResponse.new(
|
353
|
+
_response, data: decoded, errors: _errors
|
354
|
+
)
|
355
|
+
end
|
356
|
+
|
357
|
+
# Schedules a `RESUME` action to resume a paused or a deactivated
|
358
|
+
# subscription.
|
264
359
|
# @param [String] subscription_id Required parameter: The ID of the
|
265
360
|
# subscription to resume.
|
361
|
+
# @param [ResumeSubscriptionRequest] body Required parameter: An object
|
362
|
+
# containing the fields to POST for the request. See the corresponding
|
363
|
+
# object definition for field details.
|
266
364
|
# @return [ResumeSubscriptionResponse Hash] response from the API call
|
267
|
-
def resume_subscription(subscription_id
|
365
|
+
def resume_subscription(subscription_id:,
|
366
|
+
body:)
|
268
367
|
# Prepare query url.
|
269
368
|
_query_builder = config.get_base_uri
|
270
369
|
_query_builder << '/v2/subscriptions/{subscription_id}/resume'
|
@@ -276,13 +375,57 @@ module Square
|
|
276
375
|
|
277
376
|
# Prepare headers.
|
278
377
|
_headers = {
|
279
|
-
'accept' => 'application/json'
|
378
|
+
'accept' => 'application/json',
|
379
|
+
'Content-Type' => 'application/json'
|
280
380
|
}
|
281
381
|
|
282
382
|
# Prepare and execute HttpRequest.
|
283
383
|
_request = config.http_client.post(
|
284
384
|
_query_url,
|
285
|
-
headers: _headers
|
385
|
+
headers: _headers,
|
386
|
+
parameters: body.to_json
|
387
|
+
)
|
388
|
+
OAuth2.apply(config, _request)
|
389
|
+
_response = execute_request(_request)
|
390
|
+
|
391
|
+
# Return appropriate response type.
|
392
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
393
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
394
|
+
ApiResponse.new(
|
395
|
+
_response, data: decoded, errors: _errors
|
396
|
+
)
|
397
|
+
end
|
398
|
+
|
399
|
+
# Schedules a `SWAP_PLAN` action to swap a subscription plan in an existing
|
400
|
+
# subscription.
|
401
|
+
# @param [String] subscription_id Required parameter: The ID of the
|
402
|
+
# subscription to swap the subscription plan for.
|
403
|
+
# @param [SwapPlanRequest] body Required parameter: An object containing the
|
404
|
+
# fields to POST for the request. See the corresponding object definition
|
405
|
+
# for field details.
|
406
|
+
# @return [SwapPlanResponse Hash] response from the API call
|
407
|
+
def swap_plan(subscription_id:,
|
408
|
+
body:)
|
409
|
+
# Prepare query url.
|
410
|
+
_query_builder = config.get_base_uri
|
411
|
+
_query_builder << '/v2/subscriptions/{subscription_id}/swap-plan'
|
412
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
413
|
+
_query_builder,
|
414
|
+
'subscription_id' => { 'value' => subscription_id, 'encode' => true }
|
415
|
+
)
|
416
|
+
_query_url = APIHelper.clean_url _query_builder
|
417
|
+
|
418
|
+
# Prepare headers.
|
419
|
+
_headers = {
|
420
|
+
'accept' => 'application/json',
|
421
|
+
'Content-Type' => 'application/json'
|
422
|
+
}
|
423
|
+
|
424
|
+
# Prepare and execute HttpRequest.
|
425
|
+
_request = config.http_client.post(
|
426
|
+
_query_url,
|
427
|
+
headers: _headers,
|
428
|
+
parameters: body.to_json
|
286
429
|
)
|
287
430
|
OAuth2.apply(config, _request)
|
288
431
|
_response = execute_request(_request)
|
data/lib/square/api/team_api.rb
CHANGED
@@ -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.
|
@@ -69,7 +69,7 @@ module Square
|
|
69
69
|
# Prepare headers.
|
70
70
|
_headers = {
|
71
71
|
'accept' => 'application/json',
|
72
|
-
'
|
72
|
+
'Content-Type' => 'application/json'
|
73
73
|
}
|
74
74
|
|
75
75
|
# Prepare and execute HttpRequest.
|
@@ -112,7 +112,7 @@ module Square
|
|
112
112
|
# Prepare headers.
|
113
113
|
_headers = {
|
114
114
|
'accept' => 'application/json',
|
115
|
-
'
|
115
|
+
'Content-Type' => 'application/json'
|
116
116
|
}
|
117
117
|
|
118
118
|
# Prepare and execute HttpRequest.
|
@@ -149,7 +149,7 @@ module Square
|
|
149
149
|
# Prepare headers.
|
150
150
|
_headers = {
|
151
151
|
'accept' => 'application/json',
|
152
|
-
'
|
152
|
+
'Content-Type' => 'application/json'
|
153
153
|
}
|
154
154
|
|
155
155
|
# Prepare and execute HttpRequest.
|
@@ -232,7 +232,7 @@ module Square
|
|
232
232
|
# Prepare headers.
|
233
233
|
_headers = {
|
234
234
|
'accept' => 'application/json',
|
235
|
-
'
|
235
|
+
'Content-Type' => 'application/json'
|
236
236
|
}
|
237
237
|
|
238
238
|
# Prepare and execute HttpRequest.
|
@@ -319,7 +319,7 @@ module Square
|
|
319
319
|
# Prepare headers.
|
320
320
|
_headers = {
|
321
321
|
'accept' => 'application/json',
|
322
|
-
'
|
322
|
+
'Content-Type' => 'application/json'
|
323
323
|
}
|
324
324
|
|
325
325
|
# Prepare and execute HttpRequest.
|
@@ -21,7 +21,7 @@ module Square
|
|
21
21
|
# Prepare headers.
|
22
22
|
_headers = {
|
23
23
|
'accept' => 'application/json',
|
24
|
-
'
|
24
|
+
'Content-Type' => 'application/json'
|
25
25
|
}
|
26
26
|
|
27
27
|
# Prepare and execute HttpRequest.
|
@@ -56,7 +56,7 @@ module Square
|
|
56
56
|
# Prepare headers.
|
57
57
|
_headers = {
|
58
58
|
'accept' => 'application/json',
|
59
|
-
'
|
59
|
+
'Content-Type' => 'application/json'
|
60
60
|
}
|
61
61
|
|
62
62
|
# Prepare and execute HttpRequest.
|
@@ -162,7 +162,7 @@ module Square
|
|
162
162
|
# Prepare headers.
|
163
163
|
_headers = {
|
164
164
|
'accept' => 'application/json',
|
165
|
-
'
|
165
|
+
'Content-Type' => 'application/json'
|
166
166
|
}
|
167
167
|
|
168
168
|
# Prepare and execute HttpRequest.
|
@@ -197,7 +197,7 @@ module Square
|
|
197
197
|
# Prepare headers.
|
198
198
|
_headers = {
|
199
199
|
'accept' => 'application/json',
|
200
|
-
'
|
200
|
+
'Content-Type' => 'application/json'
|
201
201
|
}
|
202
202
|
|
203
203
|
# Prepare and execute HttpRequest.
|
@@ -127,7 +127,7 @@ module Square
|
|
127
127
|
# Prepare headers.
|
128
128
|
_headers = {
|
129
129
|
'accept' => 'application/json',
|
130
|
-
'
|
130
|
+
'Content-Type' => 'application/json'
|
131
131
|
}
|
132
132
|
|
133
133
|
# Prepare and execute HttpRequest.
|
@@ -369,7 +369,7 @@ module Square
|
|
369
369
|
# Prepare headers.
|
370
370
|
_headers = {
|
371
371
|
'accept' => 'application/json',
|
372
|
-
'
|
372
|
+
'Content-Type' => 'application/json'
|
373
373
|
}
|
374
374
|
|
375
375
|
# Prepare and execute HttpRequest.
|
data/lib/square/client.rb
CHANGED
@@ -4,13 +4,17 @@ module Square
|
|
4
4
|
attr_reader :config
|
5
5
|
|
6
6
|
def sdk_version
|
7
|
-
'
|
7
|
+
'17.1.0.20220120'
|
8
8
|
end
|
9
9
|
|
10
10
|
def square_version
|
11
11
|
config.square_version
|
12
12
|
end
|
13
13
|
|
14
|
+
def user_agent_detail
|
15
|
+
config.user_agent_detail
|
16
|
+
end
|
17
|
+
|
14
18
|
# Access to mobile_authorization controller.
|
15
19
|
# @return [MobileAuthorizationApi] Returns the controller instance.
|
16
20
|
def mobile_authorization
|
@@ -214,8 +218,8 @@ module Square
|
|
214
218
|
retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
|
215
219
|
retry_methods: %i[get put], environment: 'production',
|
216
220
|
custom_url: 'https://connect.squareup.com',
|
217
|
-
square_version: '
|
218
|
-
additional_headers: {}, config: nil)
|
221
|
+
square_version: '2022-01-20', access_token: '',
|
222
|
+
user_agent_detail: '', additional_headers: {}, config: nil)
|
219
223
|
@config = if config.nil?
|
220
224
|
Configuration.new(http_client_instance: http_client_instance,
|
221
225
|
timeout: timeout, max_retries: max_retries,
|
@@ -227,6 +231,7 @@ module Square
|
|
227
231
|
custom_url: custom_url,
|
228
232
|
square_version: square_version,
|
229
233
|
access_token: access_token,
|
234
|
+
user_agent_detail: user_agent_detail,
|
230
235
|
additional_headers: additional_headers)
|
231
236
|
else
|
232
237
|
config
|
data/lib/square/configuration.rb
CHANGED
@@ -5,7 +5,7 @@ module Square
|
|
5
5
|
# The attribute readers for properties.
|
6
6
|
attr_reader :http_client, :http_client_instance, :timeout, :max_retries, :retry_interval,
|
7
7
|
:backoff_factor, :retry_statuses, :retry_methods, :environment, :custom_url,
|
8
|
-
:square_version, :access_token
|
8
|
+
:square_version, :access_token, :user_agent_detail
|
9
9
|
|
10
10
|
def additional_headers
|
11
11
|
@additional_headers.clone
|
@@ -20,8 +20,8 @@ module Square
|
|
20
20
|
retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
|
21
21
|
retry_methods: %i[get put], environment: 'production',
|
22
22
|
custom_url: 'https://connect.squareup.com',
|
23
|
-
square_version: '
|
24
|
-
additional_headers: {})
|
23
|
+
square_version: '2022-01-20', access_token: '',
|
24
|
+
user_agent_detail: '', additional_headers: {})
|
25
25
|
# The Http Client passed from the sdk user for making requests
|
26
26
|
@http_client_instance = http_client_instance
|
27
27
|
|
@@ -61,13 +61,16 @@ module Square
|
|
61
61
|
|
62
62
|
# The Http Client to use for making requests.
|
63
63
|
@http_client = create_http_client
|
64
|
+
|
65
|
+
# User agent detail, to be appended with user-agent header.
|
66
|
+
@user_agent_detail = get_user_agent(user_agent_detail)
|
64
67
|
end
|
65
68
|
|
66
69
|
def clone_with(http_client_instance: nil, timeout: nil, max_retries: nil,
|
67
70
|
retry_interval: nil, backoff_factor: nil,
|
68
71
|
retry_statuses: nil, retry_methods: nil, environment: nil,
|
69
72
|
custom_url: nil, square_version: nil, access_token: nil,
|
70
|
-
additional_headers: nil)
|
73
|
+
user_agent_detail: nil, additional_headers: nil)
|
71
74
|
http_client_instance ||= self.http_client_instance
|
72
75
|
timeout ||= self.timeout
|
73
76
|
max_retries ||= self.max_retries
|
@@ -79,6 +82,7 @@ module Square
|
|
79
82
|
custom_url ||= self.custom_url
|
80
83
|
square_version ||= self.square_version
|
81
84
|
access_token ||= self.access_token
|
85
|
+
user_agent_detail ||= self.user_agent_detail
|
82
86
|
additional_headers ||= self.additional_headers
|
83
87
|
|
84
88
|
Configuration.new(http_client_instance: http_client_instance,
|
@@ -89,6 +93,7 @@ module Square
|
|
89
93
|
retry_methods: retry_methods, environment: environment,
|
90
94
|
custom_url: custom_url, square_version: square_version,
|
91
95
|
access_token: access_token,
|
96
|
+
user_agent_detail: user_agent_detail,
|
92
97
|
additional_headers: additional_headers)
|
93
98
|
end
|
94
99
|
|
@@ -101,6 +106,12 @@ module Square
|
|
101
106
|
http_client_instance: http_client_instance)
|
102
107
|
end
|
103
108
|
|
109
|
+
def get_user_agent(user_agent_detail)
|
110
|
+
raise ArgumentError, 'The length of user-agent detail should not exceed 128 characters.' unless user_agent_detail.length < 128
|
111
|
+
|
112
|
+
user_agent_detail
|
113
|
+
end
|
114
|
+
|
104
115
|
# All the environments the SDK can run in.
|
105
116
|
ENVIRONMENTS = {
|
106
117
|
'production' => {
|
@@ -7,11 +7,8 @@ class LocationsApiTests < ApiTestBase
|
|
7
7
|
@controller = LocationsApi.new CONFIG, http_call_back: @response_catcher
|
8
8
|
end
|
9
9
|
|
10
|
-
# Provides
|
11
|
-
#
|
12
|
-
#Many Square API endpoints require a `location_id` parameter.
|
13
|
-
#The `id` field of the [`Location`]($m/Location) objects returned by this
|
14
|
-
#endpoint correspond to that `location_id` parameter.
|
10
|
+
# Provides details about all of the seller's [locations](https://developer.squareup.com/docs/locations-api),
|
11
|
+
#including those with an inactive status.
|
15
12
|
def test_list_locations()
|
16
13
|
|
17
14
|
# Perform the API call through the SDK function
|
data/test/test_helper.rb
CHANGED
@@ -82,7 +82,7 @@ class TestHelper
|
|
82
82
|
unless @cache.keys.include? url
|
83
83
|
@cache[url] = Tempfile.new('APIMatic')
|
84
84
|
@cache[url].binmode
|
85
|
-
@cache[url].write(open(url, {ssl_ca_cert: Certifi.where}).read)
|
85
|
+
@cache[url].write(URI.open(url, {ssl_ca_cert: Certifi.where}).read)
|
86
86
|
end
|
87
87
|
return @cache[url].path
|
88
88
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: square.rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 17.1.0.20220120
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Square Developer Platform
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logging
|
@@ -209,9 +209,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
209
209
|
- - ">="
|
210
210
|
- !ruby/object:Gem::Version
|
211
211
|
version: '2.5'
|
212
|
-
- - "<"
|
213
|
-
- !ruby/object:Gem::Version
|
214
|
-
version: '3.0'
|
215
212
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
216
213
|
requirements:
|
217
214
|
- - ">="
|