square.rb 20.1.0.20220616 → 21.0.0.20220720
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/square/api/base_api.rb +8 -1
- data/lib/square/api/bookings_api.rb +3 -3
- data/lib/square/api/cards_api.rb +3 -2
- data/lib/square/api/catalog_api.rb +22 -22
- data/lib/square/api/customer_custom_attributes_api.rb +12 -12
- data/lib/square/api/customers_api.rb +1 -1
- data/lib/square/api/orders_api.rb +2 -2
- data/lib/square/api/payments_api.rb +1 -1
- data/lib/square/api/v1_transactions_api.rb +4 -4
- data/lib/square/api_helper.rb +176 -4
- data/lib/square/client.rb +4 -5
- data/lib/square/configuration.rb +3 -4
- data/lib/square/exceptions/validation_exception.rb +13 -0
- data/lib/square/http/faraday_client.rb +1 -0
- data/lib/square.rb +1 -0
- data/test/test_helper.rb +1 -1
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b8c49dc5dec3f51ebfdb70e1789d9ffd0c1826b9f953c7a1e0fa59b62dae9d4f
|
4
|
+
data.tar.gz: b49dd9dbf71cdb0c1371dc0f5fb9505a26aaffe5c1905a366a3e46ecae5ea7fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf2fcb52842fd5fc4f4b0cce1196a0276b882ec2d27d9a1d1eb6c717c0130eca6c52c0fda1d176bf4cc7f78f64b018162a58e484aa548534f58bf5738cee0e8d
|
7
|
+
data.tar.gz: d2efdfc7be2f8afde9906e01bc3b6dac865fd092f0394ea5ebe3e427101752251100ff409e8a9fff7b5c7d7af5d52278ec641289b90a52a8c6aa70715ce6c39c
|
data/lib/square/api/base_api.rb
CHANGED
@@ -20,6 +20,13 @@ module Square
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
+
def validate_parameters_types(args)
|
24
|
+
args.each do |_name, type|
|
25
|
+
key, val = type.first
|
26
|
+
APIHelper.validate_types(key, val) unless key.nil?
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
23
30
|
def execute_request(request, binary: false)
|
24
31
|
@http_call_back&.on_before_request(request)
|
25
32
|
|
@@ -38,7 +45,7 @@ module Square
|
|
38
45
|
end
|
39
46
|
|
40
47
|
def get_user_agent
|
41
|
-
user_agent = 'Square-Ruby-SDK/
|
48
|
+
user_agent = 'Square-Ruby-SDK/21.0.0.20220720 ({api-version}) {engine}/{engine-version} ({os-info}) {detail}'
|
42
49
|
user_agent['{engine}'] = RUBY_ENGINE
|
43
50
|
user_agent['{engine-version}'] = RUBY_ENGINE_VERSION
|
44
51
|
user_agent['{os-info}'] = RUBY_PLATFORM
|
@@ -178,9 +178,9 @@ module Square
|
|
178
178
|
end
|
179
179
|
|
180
180
|
# Lists booking profiles for team members.
|
181
|
-
# @param [
|
182
|
-
# include only bookable team members in the returned result
|
183
|
-
# (`false`).
|
181
|
+
# @param [TrueClass|FalseClass] bookable_only Optional parameter: Indicates
|
182
|
+
# whether to include only bookable team members in the returned result
|
183
|
+
# (`true`) or not (`false`).
|
184
184
|
# @param [Integer] limit Optional parameter: The maximum number of results
|
185
185
|
# to return in a paged response.
|
186
186
|
# @param [String] cursor Optional parameter: The pagination cursor from the
|
data/lib/square/api/cards_api.rb
CHANGED
@@ -15,8 +15,9 @@ module Square
|
|
15
15
|
# @param [String] customer_id Optional parameter: Limit results to cards
|
16
16
|
# associated with the customer supplied. By default, all cards owned by the
|
17
17
|
# merchant are returned.
|
18
|
-
# @param [
|
19
|
-
# cards. By default, all enabled cards owned by the
|
18
|
+
# @param [TrueClass|FalseClass] include_disabled Optional parameter:
|
19
|
+
# Includes disabled cards. By default, all enabled cards owned by the
|
20
|
+
# merchant are returned.
|
20
21
|
# @param [String] reference_id Optional parameter: Limit results to cards
|
21
22
|
# associated with the reference_id supplied.
|
22
23
|
# @param [SortOrder] sort_order Optional parameter: Sorts the returned list
|
@@ -319,8 +319,8 @@ module Square
|
|
319
319
|
# MODIFIER_LIST, PRICING_RULE, PRODUCT_SET, TIME_PERIOD, MEASUREMENT_UNIT,
|
320
320
|
# SUBSCRIPTION_PLAN, ITEM_OPTION, CUSTOM_ATTRIBUTE_DEFINITION,
|
321
321
|
# QUICK_AMOUNT_SETTINGS.
|
322
|
-
# @param [
|
323
|
-
# the catalog objects to be included in the response. This allows you to
|
322
|
+
# @param [Integer] catalog_version Optional parameter: The specific version
|
323
|
+
# of the catalog objects to be included in the response. This allows you to
|
324
324
|
# retrieve historical versions of objects. The specified version value is
|
325
325
|
# matched against the [CatalogObject]($m/CatalogObject)s' `version`
|
326
326
|
# attribute. If not included, results will be from the current version of
|
@@ -448,26 +448,26 @@ module Square
|
|
448
448
|
# any [CatalogTax]($m/CatalogTax) objects that apply to it.
|
449
449
|
# @param [String] object_id Required parameter: The object ID of any type of
|
450
450
|
# catalog objects to be retrieved.
|
451
|
-
# @param [
|
452
|
-
# the response will include additional objects that are related
|
453
|
-
# requested objects. Related objects are defined as any objects
|
454
|
-
# by ID by the results in the `objects` field of the response.
|
455
|
-
# are put in the `related_objects` field. Setting this to
|
456
|
-
# when the objects are needed for immediate display to a
|
457
|
-
# only goes one level deep. Objects referenced by the
|
458
|
-
# not be included. For example, if the `objects` field
|
459
|
-
# contains a CatalogItem, its associated CatalogCategory
|
460
|
-
# objects, CatalogImage objects and CatalogModifierLists
|
461
|
-
# the `related_objects` field of the response. If the
|
462
|
-
# response contains a CatalogItemVariation, its
|
463
|
-
# returned in the `related_objects` field of the
|
464
|
-
# `false`
|
465
|
-
# @param [
|
466
|
-
# specific version of the catalog. This allows you to retrieve
|
467
|
-
# versions of objects. The value to retrieve a specific version
|
468
|
-
# can be found in the version field of
|
469
|
-
# If not included, results will be from
|
470
|
-
# catalog.
|
451
|
+
# @param [TrueClass|FalseClass] include_related_objects Optional parameter:
|
452
|
+
# If `true`, the response will include additional objects that are related
|
453
|
+
# to the requested objects. Related objects are defined as any objects
|
454
|
+
# referenced by ID by the results in the `objects` field of the response.
|
455
|
+
# These objects are put in the `related_objects` field. Setting this to
|
456
|
+
# `true` is helpful when the objects are needed for immediate display to a
|
457
|
+
# user. This process only goes one level deep. Objects referenced by the
|
458
|
+
# related objects will not be included. For example, if the `objects` field
|
459
|
+
# of the response contains a CatalogItem, its associated CatalogCategory
|
460
|
+
# objects, CatalogTax objects, CatalogImage objects and CatalogModifierLists
|
461
|
+
# will be returned in the `related_objects` field of the response. If the
|
462
|
+
# `objects` field of the response contains a CatalogItemVariation, its
|
463
|
+
# parent CatalogItem will be returned in the `related_objects` field of the
|
464
|
+
# response. Default value: `false`
|
465
|
+
# @param [Integer] catalog_version Optional parameter: Requests objects as
|
466
|
+
# of a specific version of the catalog. This allows you to retrieve
|
467
|
+
# historical versions of objects. The value to retrieve a specific version
|
468
|
+
# of an object can be found in the version field of
|
469
|
+
# [CatalogObject]($m/CatalogObject)s. If not included, results will be from
|
470
|
+
# the current version of the catalog.
|
471
471
|
# @return [RetrieveCatalogObjectResponse Hash] response from the API call
|
472
472
|
def retrieve_catalog_object(object_id:,
|
473
473
|
include_related_objects: false,
|
@@ -323,12 +323,12 @@ module Square
|
|
323
323
|
# more information, see
|
324
324
|
# [Pagination](https://developer.squareup.com/docs/build-basics/common-api-p
|
325
325
|
# atterns/pagination).
|
326
|
-
# @param [
|
327
|
-
# return the [custom attribute
|
328
|
-
# the `definition` field of
|
329
|
-
# `true` to get the name and
|
330
|
-
# information about the data type, or
|
331
|
-
# value is `false`.
|
326
|
+
# @param [TrueClass|FalseClass] with_definitions Optional parameter:
|
327
|
+
# Indicates whether to return the [custom attribute
|
328
|
+
# definition]($m/CustomAttributeDefinition) in the `definition` field of
|
329
|
+
# each custom attribute. Set this parameter to `true` to get the name and
|
330
|
+
# description of each custom attribute, information about the data type, or
|
331
|
+
# other definition details. The default value is `false`.
|
332
332
|
# @return [ListCustomerCustomAttributesResponse Hash] response from the API call
|
333
333
|
def list_customer_custom_attributes(customer_id:,
|
334
334
|
limit: nil,
|
@@ -427,12 +427,12 @@ module Square
|
|
427
427
|
# retrieve. This key must match the `key` of a custom attribute definition
|
428
428
|
# in the Square seller account. If the requesting application is not the
|
429
429
|
# definition owner, you must use the qualified key.
|
430
|
-
# @param [
|
431
|
-
# return the [custom attribute
|
432
|
-
# the `definition` field of the
|
433
|
-
# `true` to get the name and
|
434
|
-
# information about the data type, or
|
435
|
-
# value is `false`.
|
430
|
+
# @param [TrueClass|FalseClass] with_definition Optional parameter:
|
431
|
+
# Indicates whether to return the [custom attribute
|
432
|
+
# definition]($m/CustomAttributeDefinition) in the `definition` field of the
|
433
|
+
# custom attribute. Set this parameter to `true` to get the name and
|
434
|
+
# description of the custom attribute, information about the data type, or
|
435
|
+
# other definition details. The default value is `false`.
|
436
436
|
# @param [Integer] version Optional parameter: The current version of the
|
437
437
|
# custom attribute, which is used for strongly consistent reads to guarantee
|
438
438
|
# that you receive the most up-to-date data. When included in the request,
|
@@ -165,7 +165,7 @@ module Square
|
|
165
165
|
# profiles, you must use the ID of the newly created profile.
|
166
166
|
# @param [String] customer_id Required parameter: The ID of the customer to
|
167
167
|
# delete.
|
168
|
-
# @param [
|
168
|
+
# @param [Integer] version Optional parameter: The current version of the
|
169
169
|
# customer profile. As a best practice, you should include this parameter
|
170
170
|
# to enable [optimistic
|
171
171
|
# concurrency](https://developer.squareup.com/docs/build-basics/common-api-p
|
@@ -244,8 +244,8 @@ module Square
|
|
244
244
|
# - The `order_id` in the endpoint path, identifying the order to update.
|
245
245
|
# - The latest `version` of the order to update.
|
246
246
|
# - The [sparse
|
247
|
-
# order](https://developer.squareup.com/docs/orders-api/manage-orders
|
248
|
-
# -order-objects)
|
247
|
+
# order](https://developer.squareup.com/docs/orders-api/manage-orders/update
|
248
|
+
# -orders#sparse-order-objects)
|
249
249
|
# containing only the fields to update and the version to which the update
|
250
250
|
# is
|
251
251
|
# being applied.
|
@@ -26,7 +26,7 @@ module Square
|
|
26
26
|
# @param [String] location_id Optional parameter: Limit results to the
|
27
27
|
# location supplied. By default, results are returned for the default (main)
|
28
28
|
# location associated with the seller.
|
29
|
-
# @param [
|
29
|
+
# @param [Integer] total Optional parameter: The exact amount in the
|
30
30
|
# `total_money` for a payment.
|
31
31
|
# @param [String] last_4 Optional parameter: The last four digits of a
|
32
32
|
# payment card.
|
@@ -175,10 +175,10 @@ module Square
|
|
175
175
|
# @param [String] batch_token Optional parameter: A pagination cursor to
|
176
176
|
# retrieve the next set of results for your original query to the
|
177
177
|
# endpoint.
|
178
|
-
# @param [
|
179
|
-
# not to include partial payments in the response.
|
180
|
-
# have the tenders collected so far, but the
|
181
|
-
# until the payment is completed.
|
178
|
+
# @param [TrueClass|FalseClass] include_partial Optional parameter:
|
179
|
+
# Indicates whether or not to include partial payments in the response.
|
180
|
+
# Partial payments will have the tenders collected so far, but the
|
181
|
+
# itemizations will be empty until the payment is completed.
|
182
182
|
# @return [List of V1Payment Hash] response from the API call
|
183
183
|
def list_payments(location_id:,
|
184
184
|
order: nil,
|
data/lib/square/api_helper.rb
CHANGED
@@ -130,6 +130,12 @@ module Square
|
|
130
130
|
raise TypeError, 'Server responded with invalid JSON.'
|
131
131
|
end
|
132
132
|
|
133
|
+
# Parses JSON string.
|
134
|
+
# @param [object] The object to serialize.
|
135
|
+
def self.json_serialize(obj)
|
136
|
+
serializable_types.map { |x| obj.is_a? x }.any? ? obj.to_s : obj.to_json
|
137
|
+
end
|
138
|
+
|
133
139
|
# Removes elements with empty values from a hash.
|
134
140
|
# @param [Hash] The hash to clean.
|
135
141
|
def self.clean_hash(hash)
|
@@ -199,9 +205,6 @@ module Square
|
|
199
205
|
def self.form_encode(obj, instance_name, formatting: 'indexed')
|
200
206
|
retval = {}
|
201
207
|
|
202
|
-
serializable_types = [String, Numeric, TrueClass,
|
203
|
-
FalseClass, Date, DateTime]
|
204
|
-
|
205
208
|
# Create a form encoded hash for this object.
|
206
209
|
if obj.nil?
|
207
210
|
nil
|
@@ -210,7 +213,7 @@ module Square
|
|
210
213
|
obj.each_with_index do |value, index|
|
211
214
|
retval.merge!(APIHelper.form_encode(value, "#{instance_name}[#{index}]"))
|
212
215
|
end
|
213
|
-
elsif serializable_types.map { |x| obj[0].is_a? x }.any?
|
216
|
+
elsif APIHelper.serializable_types.map { |x| obj[0].is_a? x }.any?
|
214
217
|
obj.each do |value|
|
215
218
|
abc = if formatting == 'unindexed'
|
216
219
|
APIHelper.form_encode(value, "#{instance_name}[]",
|
@@ -265,5 +268,174 @@ module Square
|
|
265
268
|
end
|
266
269
|
val
|
267
270
|
end
|
271
|
+
|
272
|
+
# Deserialize the value against the template (group of types).
|
273
|
+
# @param [String] The value to be deserialized.
|
274
|
+
# @param [String] The parameter indicates the type-combination
|
275
|
+
# against which the value will be mapped (oneOf(Integer, String)).
|
276
|
+
def self.deserialize(template, value)
|
277
|
+
decoded = APIHelper.json_deserialize(value)
|
278
|
+
map_types(decoded, template)
|
279
|
+
end
|
280
|
+
|
281
|
+
# Validates and processes the value against the template(group of types).
|
282
|
+
# @param [String] The value to be mapped against the template.
|
283
|
+
# @param [String] The parameter indicates the group of types (oneOf(Integer, String)).
|
284
|
+
# @param [String] The parameter indicates the group (oneOf|anyOf).
|
285
|
+
def self.map_types(value, template, group_name: nil)
|
286
|
+
result_value = nil
|
287
|
+
matches = 0
|
288
|
+
types = []
|
289
|
+
group_name = template.partition('(').first if group_name.nil? && template.match?(/anyOf|oneOf/)
|
290
|
+
|
291
|
+
return if value.nil?
|
292
|
+
|
293
|
+
if template.end_with?('{}') || template.end_with?('[]')
|
294
|
+
types = template.split(group_name, 2).last.gsub(/\s+/, '').split
|
295
|
+
else
|
296
|
+
template = template.split(group_name, 2).last.delete_prefix('(').delete_suffix(')')
|
297
|
+
types = template.scan(/(anyOf|oneOf)[(]([^[)]]*)[)]/).flatten.combination(2).map { |a, b| "#{a}(#{b})" }
|
298
|
+
types.each { |t| template = template.gsub(", #{t}", '') }
|
299
|
+
types = template.gsub(/\s+/, '').split(',').push(*types)
|
300
|
+
end
|
301
|
+
types.each do |element|
|
302
|
+
if element.match?(/^(oneOf|anyOf)[(].*$/)
|
303
|
+
begin
|
304
|
+
result_value = map_types(value, element, matches)
|
305
|
+
matches += 1
|
306
|
+
rescue ValidationException
|
307
|
+
next
|
308
|
+
end
|
309
|
+
elsif element.end_with?('{}')
|
310
|
+
result_value, matches = map_hash_type(value, element, group_name, matches)
|
311
|
+
elsif element.end_with?('[]')
|
312
|
+
result_value, matches = map_array_type(value, element, group_name, matches)
|
313
|
+
else
|
314
|
+
begin
|
315
|
+
result_value, matches = map_type(value, element, group_name, matches)
|
316
|
+
rescue StandardError
|
317
|
+
next
|
318
|
+
end
|
319
|
+
end
|
320
|
+
break if group_name == 'anyOf' && matches == 1
|
321
|
+
end
|
322
|
+
raise ValidationException.new(value, template) unless matches == 1
|
323
|
+
|
324
|
+
value = result_value unless result_value.nil?
|
325
|
+
value
|
326
|
+
end
|
327
|
+
|
328
|
+
# Validates and processes the value against the [Hash] type.
|
329
|
+
# @param [String] The value to be mapped against the type.
|
330
|
+
# @param [String] The possible type of the value.
|
331
|
+
# @param [String] The parameter indicates the group (oneOf|anyOf).
|
332
|
+
# @param [Integer] The parameter indicates the number of matches of value against types.
|
333
|
+
def self.map_hash_type(value, type, group_name, matches)
|
334
|
+
if value.instance_of? Hash
|
335
|
+
decoded = {}
|
336
|
+
value.each do |key, val|
|
337
|
+
type = type.chomp('{}').to_s
|
338
|
+
val = map_types(val, type, group_name: group_name)
|
339
|
+
decoded[key] = val unless type.empty?
|
340
|
+
rescue ValidationException
|
341
|
+
next
|
342
|
+
end
|
343
|
+
matches += 1 if decoded.length == value.length
|
344
|
+
value = decoded unless decoded.empty?
|
345
|
+
end
|
346
|
+
[value, matches]
|
347
|
+
end
|
348
|
+
|
349
|
+
# Validates and processes the value against the [Array] type.
|
350
|
+
# @param [String] The value to be mapped against the type.
|
351
|
+
# @param [String] The possible type of the value.
|
352
|
+
# @param [String] The parameter indicates the group (oneOf|anyOf).
|
353
|
+
# @param [Integer] The parameter indicates the number of matches of value against types.
|
354
|
+
def self.map_array_type(value, type, group_name, matches)
|
355
|
+
if value.instance_of? Array
|
356
|
+
decoded = []
|
357
|
+
value.each do |val|
|
358
|
+
type = type.chomp('[]').to_s
|
359
|
+
val = map_types(val, type, group_name: group_name)
|
360
|
+
decoded.append(val) unless type.empty?
|
361
|
+
rescue ValidationException
|
362
|
+
next
|
363
|
+
end
|
364
|
+
matches += 1 if decoded.length == value.length
|
365
|
+
value = decoded unless decoded.empty?
|
366
|
+
end
|
367
|
+
[value, matches]
|
368
|
+
end
|
369
|
+
|
370
|
+
# Validates and processes the value against the type.
|
371
|
+
# @param [String] The value to be mapped against the type.
|
372
|
+
# @param [String] The possible type of the value.
|
373
|
+
# @param [String] The parameter indicates the group (oneOf|anyOf).
|
374
|
+
# @param [Integer] The parameter indicates the number of matches of value against types.
|
375
|
+
def self.map_type(value, type, _group_name, matches)
|
376
|
+
if Square.constants.select do |c|
|
377
|
+
Square.const_get(c).to_s == "Square::#{type}"
|
378
|
+
end.empty?
|
379
|
+
value, matches = map_data_type(value, type, matches)
|
380
|
+
else
|
381
|
+
value, matches = map_complex_type(value, type, matches)
|
382
|
+
end
|
383
|
+
[value, matches]
|
384
|
+
end
|
385
|
+
|
386
|
+
# Validates and processes the value against the complex types.
|
387
|
+
# @param [String] The value to be mapped against the type.
|
388
|
+
# @param [String] The possible type of the value.
|
389
|
+
# @param [Integer] The parameter indicates the number of matches of value against types.
|
390
|
+
def self.map_complex_type(value, type, matches)
|
391
|
+
obj = Square.const_get(type)
|
392
|
+
value = if obj.respond_to? 'from_hash'
|
393
|
+
obj.send('from_hash', value)
|
394
|
+
else
|
395
|
+
obj.constants.find { |k| obj.const_get(k) == value }
|
396
|
+
end
|
397
|
+
matches += 1 unless value.nil?
|
398
|
+
[value, matches]
|
399
|
+
end
|
400
|
+
|
401
|
+
# Validates and processes the value against the data types.
|
402
|
+
# @param [String] The value to be mapped against the type.
|
403
|
+
# @param [String] The possible type of the value.
|
404
|
+
# @param [Integer] The parameter indicates the number of matches of value against types.
|
405
|
+
def self.map_data_type(value, element, matches)
|
406
|
+
element = element.split('|').map { |x| Object.const_get x }
|
407
|
+
matches += 1 if element.all? { |x| APIHelper.data_types.include?(x) } &&
|
408
|
+
element.any? { |x| (value.instance_of? x) || (value.class.ancestors.include? x) }
|
409
|
+
[value, matches]
|
410
|
+
end
|
411
|
+
|
412
|
+
# Validates the value against the template(group of types).
|
413
|
+
# @param [String] The value to be mapped against the type.
|
414
|
+
# @param [String] The parameter indicates the group of types (oneOf(Integer, String)).
|
415
|
+
def self.validate_types(value, template)
|
416
|
+
map_types(APIHelper.json_deserialize(value.to_json), template)
|
417
|
+
end
|
418
|
+
|
419
|
+
# Get content-type depending on the value
|
420
|
+
def self.get_content_type(value)
|
421
|
+
if serializable_types.map { |x| value.is_a? x }.any?
|
422
|
+
'text/plain; charset=utf-8'
|
423
|
+
else
|
424
|
+
'application/json; charset=utf-8'
|
425
|
+
end
|
426
|
+
end
|
427
|
+
|
428
|
+
# Array of serializable types
|
429
|
+
def self.serializable_types
|
430
|
+
[String, Numeric, TrueClass,
|
431
|
+
FalseClass, Date, DateTime]
|
432
|
+
end
|
433
|
+
|
434
|
+
# Array of supported data types
|
435
|
+
def self.data_types
|
436
|
+
[String, Float, Integer,
|
437
|
+
TrueClass, FalseClass, Date,
|
438
|
+
DateTime, Array, Hash, Object]
|
439
|
+
end
|
268
440
|
end
|
269
441
|
end
|
data/lib/square/client.rb
CHANGED
@@ -4,7 +4,7 @@ module Square
|
|
4
4
|
attr_reader :config
|
5
5
|
|
6
6
|
def sdk_version
|
7
|
-
'
|
7
|
+
'21.0.0.20220720'
|
8
8
|
end
|
9
9
|
|
10
10
|
def square_version
|
@@ -231,13 +231,12 @@ module Square
|
|
231
231
|
@vendors ||= VendorsApi.new config
|
232
232
|
end
|
233
233
|
|
234
|
-
def initialize(connection: nil, adapter:
|
235
|
-
|
236
|
-
backoff_factor: 2,
|
234
|
+
def initialize(connection: nil, adapter: :net_http_persistent, timeout: 60,
|
235
|
+
max_retries: 0, retry_interval: 1, backoff_factor: 2,
|
237
236
|
retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
|
238
237
|
retry_methods: %i[get put], environment: 'production',
|
239
238
|
custom_url: 'https://connect.squareup.com',
|
240
|
-
square_version: '2022-
|
239
|
+
square_version: '2022-07-20', access_token: '',
|
241
240
|
user_agent_detail: '', additional_headers: {}, config: nil)
|
242
241
|
@config = if config.nil?
|
243
242
|
Configuration.new(connection: connection, adapter: adapter,
|
data/lib/square/configuration.rb
CHANGED
@@ -15,13 +15,12 @@ module Square
|
|
15
15
|
attr_reader :environments
|
16
16
|
end
|
17
17
|
|
18
|
-
def initialize(connection: nil, adapter:
|
19
|
-
|
20
|
-
backoff_factor: 2,
|
18
|
+
def initialize(connection: nil, adapter: :net_http_persistent, timeout: 60,
|
19
|
+
max_retries: 0, retry_interval: 1, backoff_factor: 2,
|
21
20
|
retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
|
22
21
|
retry_methods: %i[get put], environment: 'production',
|
23
22
|
custom_url: 'https://connect.squareup.com',
|
24
|
-
square_version: '2022-
|
23
|
+
square_version: '2022-07-20', access_token: '',
|
25
24
|
user_agent_detail: '', additional_headers: {})
|
26
25
|
# The Faraday connection object passed by the SDK user for making requests
|
27
26
|
@connection = connection
|
@@ -0,0 +1,13 @@
|
|
1
|
+
module Square
|
2
|
+
# Class for exceptions when there is a schema validation error.
|
3
|
+
class ValidationException < StandardError
|
4
|
+
attr_reader :reason
|
5
|
+
|
6
|
+
# The constructor.
|
7
|
+
# @param [String] The reason for raising an exception.
|
8
|
+
def initialize(value, template)
|
9
|
+
@reason = "The value #{value} provided doesn't validate against the schema #{template}"
|
10
|
+
super(reason)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/square.rb
CHANGED
data/test/test_helper.rb
CHANGED
@@ -49,7 +49,7 @@ class TestHelper
|
|
49
49
|
end
|
50
50
|
end
|
51
51
|
elsif expected_body.instance_of? Array
|
52
|
-
return
|
52
|
+
return false unless received_body.instance_of? Array
|
53
53
|
if check_count == true && (expected_body.length != received_body.length)
|
54
54
|
return false
|
55
55
|
else
|
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: 21.0.0.20220720
|
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: 2022-
|
11
|
+
date: 2022-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logging
|
@@ -100,6 +100,20 @@ dependencies:
|
|
100
100
|
- - "~>"
|
101
101
|
- !ruby/object:Gem::Version
|
102
102
|
version: '1.0'
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: faraday-net_http_persistent
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - "~>"
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '2.0'
|
110
|
+
type: :runtime
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - "~>"
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '2.0'
|
103
117
|
- !ruby/object:Gem::Dependency
|
104
118
|
name: certifi
|
105
119
|
requirement: !ruby/object:Gem::Requirement
|
@@ -219,6 +233,7 @@ files:
|
|
219
233
|
- lib/square/client.rb
|
220
234
|
- lib/square/configuration.rb
|
221
235
|
- lib/square/exceptions/api_exception.rb
|
236
|
+
- lib/square/exceptions/validation_exception.rb
|
222
237
|
- lib/square/http/api_response.rb
|
223
238
|
- lib/square/http/auth/o_auth2.rb
|
224
239
|
- lib/square/http/faraday_client.rb
|