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
data/lib/square/api_helper.rb
CHANGED
@@ -8,17 +8,16 @@ module Square
|
|
8
8
|
def self.serialize_array(key, array, formatting: 'indexed')
|
9
9
|
tuples = []
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
end
|
11
|
+
tuples += case formatting
|
12
|
+
when 'csv'
|
13
|
+
[[key, array.map { |element| CGI.escape(element.to_s) }.join(',')]]
|
14
|
+
when 'psv'
|
15
|
+
[[key, array.map { |element| CGI.escape(element.to_s) }.join('|')]]
|
16
|
+
when 'tsv'
|
17
|
+
[[key, array.map { |element| CGI.escape(element.to_s) }.join("\t")]]
|
18
|
+
else
|
19
|
+
array.map { |element| [key, element] }
|
20
|
+
end
|
22
21
|
tuples
|
23
22
|
end
|
24
23
|
|
@@ -55,7 +54,7 @@ module Square
|
|
55
54
|
end
|
56
55
|
|
57
56
|
# Find the template parameter and replace it with its value.
|
58
|
-
query_builder = query_builder.gsub(
|
57
|
+
query_builder = query_builder.gsub("{#{key}}", replace_value)
|
59
58
|
end
|
60
59
|
query_builder
|
61
60
|
end
|
@@ -63,9 +62,7 @@ module Square
|
|
63
62
|
# Appends the given set of parameters to the given query string.
|
64
63
|
# @param [String] The query string builder to add the query parameters to.
|
65
64
|
# @param [Hash] The parameters to append.
|
66
|
-
|
67
|
-
def self.append_url_with_query_parameters(query_builder, parameters,
|
68
|
-
array_serialization: 'indexed')
|
65
|
+
def self.append_url_with_query_parameters(query_builder, parameters)
|
69
66
|
# Perform parameter validation.
|
70
67
|
unless query_builder.instance_of? String
|
71
68
|
raise ArgumentError, 'Given value for parameter \"query_builder\"
|
@@ -75,29 +72,20 @@ module Square
|
|
75
72
|
# Return if there are no parameters to replace.
|
76
73
|
return query_builder if parameters.nil?
|
77
74
|
|
75
|
+
array_serialization = 'indexed'
|
76
|
+
parameters = process_complex_types_parameters(parameters, array_serialization)
|
77
|
+
|
78
78
|
parameters.each do |key, value|
|
79
79
|
seperator = query_builder.include?('?') ? '&' : '?'
|
80
80
|
unless value.nil?
|
81
81
|
if value.instance_of? Array
|
82
82
|
value.compact!
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
CGI.escape(element.to_s)
|
90
|
-
end.join('|')}"
|
91
|
-
elsif array_serialization == 'tsv'
|
92
|
-
"#{seperator}#{key}=#{value.map do |element|
|
93
|
-
CGI.escape(element.to_s)
|
94
|
-
end.join("\t")}"
|
95
|
-
else
|
96
|
-
"#{seperator}#{APIHelper.serialize_array(
|
97
|
-
key, value, formatting: array_serialization
|
98
|
-
).map { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }
|
99
|
-
.join('&')}"
|
100
|
-
end
|
83
|
+
APIHelper.serialize_array(
|
84
|
+
key, value, formatting: array_serialization
|
85
|
+
).each do |element|
|
86
|
+
seperator = query_builder.include?('?') ? '&' : '?'
|
87
|
+
query_builder += "#{seperator}#{element[0]}=#{element[1]}"
|
88
|
+
end
|
101
89
|
else
|
102
90
|
query_builder += "#{seperator}#{key}=#{CGI.escape(value.to_s)}"
|
103
91
|
end
|
@@ -114,7 +102,7 @@ module Square
|
|
114
102
|
raise ArgumentError, 'Invalid Url.' unless url.instance_of? String
|
115
103
|
|
116
104
|
# Ensure that the urls are absolute.
|
117
|
-
matches = url.match(%r{^(https
|
105
|
+
matches = url.match(%r{^(https?://[^/]+)})
|
118
106
|
raise ArgumentError, 'Invalid Url format.' if matches.nil?
|
119
107
|
|
120
108
|
# Get the http protocol match.
|
@@ -125,7 +113,7 @@ module Square
|
|
125
113
|
|
126
114
|
# Remove redundant forward slashes.
|
127
115
|
query = url[protocol.length...(!index.nil? ? index : url.length)]
|
128
|
-
query.gsub!(%r{
|
116
|
+
query.gsub!(%r{//+}, '/')
|
129
117
|
|
130
118
|
# Get the parameters.
|
131
119
|
parameters = !index.nil? ? url[url.index('?')...url.length] : ''
|
@@ -137,11 +125,17 @@ module Square
|
|
137
125
|
# Parses JSON string.
|
138
126
|
# @param [String] A JSON string.
|
139
127
|
def self.json_deserialize(json)
|
140
|
-
|
128
|
+
JSON.parse(json, symbolize_names: true)
|
141
129
|
rescue StandardError
|
142
130
|
raise TypeError, 'Server responded with invalid JSON.'
|
143
131
|
end
|
144
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
|
+
|
145
139
|
# Removes elements with empty values from a hash.
|
146
140
|
# @param [Hash] The hash to clean.
|
147
141
|
def self.clean_hash(hash)
|
@@ -151,8 +145,8 @@ module Square
|
|
151
145
|
# Form encodes a hash of parameters.
|
152
146
|
# @param [Hash] The hash of parameters to encode.
|
153
147
|
# @return [Hash] A hash with the same parameters form encoded.
|
154
|
-
def self.form_encode_parameters(form_parameters
|
155
|
-
|
148
|
+
def self.form_encode_parameters(form_parameters)
|
149
|
+
array_serialization = 'indexed'
|
156
150
|
encoded = {}
|
157
151
|
form_parameters.each do |key, value|
|
158
152
|
encoded.merge!(APIHelper.form_encode(value, key, formatting:
|
@@ -161,11 +155,24 @@ module Square
|
|
161
155
|
encoded
|
162
156
|
end
|
163
157
|
|
158
|
+
# Process complex types in query_params.
|
159
|
+
# @param [Hash] The hash of query parameters.
|
160
|
+
# @return [Hash] A hash with the processed query parameters.
|
161
|
+
def self.process_complex_types_parameters(query_parameters, array_serialization)
|
162
|
+
processed_params = {}
|
163
|
+
query_parameters.each do |key, value|
|
164
|
+
processed_params.merge!(APIHelper.form_encode(value, key, formatting:
|
165
|
+
array_serialization))
|
166
|
+
end
|
167
|
+
processed_params
|
168
|
+
end
|
169
|
+
|
164
170
|
def self.custom_merge(a, b)
|
165
171
|
x = {}
|
166
172
|
a.each do |key, value_a|
|
167
173
|
b.each do |k, value_b|
|
168
174
|
next unless key == k
|
175
|
+
|
169
176
|
x[k] = []
|
170
177
|
if value_a.instance_of? Array
|
171
178
|
value_a.each do |v|
|
@@ -198,22 +205,18 @@ module Square
|
|
198
205
|
def self.form_encode(obj, instance_name, formatting: 'indexed')
|
199
206
|
retval = {}
|
200
207
|
|
201
|
-
serializable_types = [String, Numeric, TrueClass,
|
202
|
-
FalseClass, Date, DateTime]
|
203
|
-
|
204
208
|
# Create a form encoded hash for this object.
|
205
209
|
if obj.nil?
|
206
210
|
nil
|
207
211
|
elsif obj.instance_of? Array
|
208
212
|
if formatting == 'indexed'
|
209
213
|
obj.each_with_index do |value, index|
|
210
|
-
retval.merge!(APIHelper.form_encode(value, instance_name
|
211
|
-
index.to_s + ']'))
|
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
|
-
APIHelper.form_encode(value, instance_name
|
219
|
+
APIHelper.form_encode(value, "#{instance_name}[]",
|
217
220
|
formatting: formatting)
|
218
221
|
else
|
219
222
|
APIHelper.form_encode(value, instance_name,
|
@@ -223,14 +226,14 @@ module Square
|
|
223
226
|
end
|
224
227
|
else
|
225
228
|
obj.each_with_index do |value, index|
|
226
|
-
retval.merge!(APIHelper.form_encode(value, instance_name
|
227
|
-
|
229
|
+
retval.merge!(APIHelper.form_encode(value, "#{instance_name}[#{index}]",
|
230
|
+
formatting: formatting))
|
228
231
|
end
|
229
232
|
end
|
230
233
|
elsif obj.instance_of? Hash
|
231
234
|
obj.each do |key, value|
|
232
|
-
retval.merge!(APIHelper.form_encode(value, instance_name
|
233
|
-
|
235
|
+
retval.merge!(APIHelper.form_encode(value, "#{instance_name}[#{key}]",
|
236
|
+
formatting: formatting))
|
234
237
|
end
|
235
238
|
elsif obj.instance_of? File
|
236
239
|
retval[instance_name] = UploadIO.new(
|
@@ -266,16 +269,173 @@ module Square
|
|
266
269
|
val
|
267
270
|
end
|
268
271
|
|
269
|
-
#
|
270
|
-
# @param [String] The
|
271
|
-
# @
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
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'
|
276
423
|
else
|
277
|
-
|
424
|
+
'application/json; charset=utf-8'
|
278
425
|
end
|
279
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
|
280
440
|
end
|
281
441
|
end
|
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
|
+
'26.1.0.20230119'
|
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
|
@@ -23,24 +27,12 @@ module Square
|
|
23
27
|
@o_auth ||= OAuthApi.new config
|
24
28
|
end
|
25
29
|
|
26
|
-
# Access to v1_employees controller.
|
27
|
-
# @return [V1EmployeesApi] Returns the controller instance.
|
28
|
-
def v1_employees
|
29
|
-
@v1_employees ||= V1EmployeesApi.new config
|
30
|
-
end
|
31
|
-
|
32
30
|
# Access to v1_transactions controller.
|
33
31
|
# @return [V1TransactionsApi] Returns the controller instance.
|
34
32
|
def v1_transactions
|
35
33
|
@v1_transactions ||= V1TransactionsApi.new config
|
36
34
|
end
|
37
35
|
|
38
|
-
# Access to v1_items controller.
|
39
|
-
# @return [V1ItemsApi] Returns the controller instance.
|
40
|
-
def v1_items
|
41
|
-
@v1_items ||= V1ItemsApi.new config
|
42
|
-
end
|
43
|
-
|
44
36
|
# Access to apple_pay controller.
|
45
37
|
# @return [ApplePayApi] Returns the controller instance.
|
46
38
|
def apple_pay
|
@@ -59,6 +51,18 @@ module Square
|
|
59
51
|
@bookings ||= BookingsApi.new config
|
60
52
|
end
|
61
53
|
|
54
|
+
# Access to booking_custom_attributes controller.
|
55
|
+
# @return [BookingCustomAttributesApi] Returns the controller instance.
|
56
|
+
def booking_custom_attributes
|
57
|
+
@booking_custom_attributes ||= BookingCustomAttributesApi.new config
|
58
|
+
end
|
59
|
+
|
60
|
+
# Access to cards controller.
|
61
|
+
# @return [CardsApi] Returns the controller instance.
|
62
|
+
def cards
|
63
|
+
@cards ||= CardsApi.new config
|
64
|
+
end
|
65
|
+
|
62
66
|
# Access to cash_drawers controller.
|
63
67
|
# @return [CashDrawersApi] Returns the controller instance.
|
64
68
|
def cash_drawers
|
@@ -77,6 +81,12 @@ module Square
|
|
77
81
|
@customers ||= CustomersApi.new config
|
78
82
|
end
|
79
83
|
|
84
|
+
# Access to customer_custom_attributes controller.
|
85
|
+
# @return [CustomerCustomAttributesApi] Returns the controller instance.
|
86
|
+
def customer_custom_attributes
|
87
|
+
@customer_custom_attributes ||= CustomerCustomAttributesApi.new config
|
88
|
+
end
|
89
|
+
|
80
90
|
# Access to customer_groups controller.
|
81
91
|
# @return [CustomerGroupsApi] Returns the controller instance.
|
82
92
|
def customer_groups
|
@@ -107,6 +117,18 @@ module Square
|
|
107
117
|
@employees ||= EmployeesApi.new config
|
108
118
|
end
|
109
119
|
|
120
|
+
# Access to gift_cards controller.
|
121
|
+
# @return [GiftCardsApi] Returns the controller instance.
|
122
|
+
def gift_cards
|
123
|
+
@gift_cards ||= GiftCardsApi.new config
|
124
|
+
end
|
125
|
+
|
126
|
+
# Access to gift_card_activities controller.
|
127
|
+
# @return [GiftCardActivitiesApi] Returns the controller instance.
|
128
|
+
def gift_card_activities
|
129
|
+
@gift_card_activities ||= GiftCardActivitiesApi.new config
|
130
|
+
end
|
131
|
+
|
110
132
|
# Access to inventory controller.
|
111
133
|
# @return [InventoryApi] Returns the controller instance.
|
112
134
|
def inventory
|
@@ -131,6 +153,12 @@ module Square
|
|
131
153
|
@locations ||= LocationsApi.new config
|
132
154
|
end
|
133
155
|
|
156
|
+
# Access to location_custom_attributes controller.
|
157
|
+
# @return [LocationCustomAttributesApi] Returns the controller instance.
|
158
|
+
def location_custom_attributes
|
159
|
+
@location_custom_attributes ||= LocationCustomAttributesApi.new config
|
160
|
+
end
|
161
|
+
|
134
162
|
# Access to checkout controller.
|
135
163
|
# @return [CheckoutApi] Returns the controller instance.
|
136
164
|
def checkout
|
@@ -161,18 +189,42 @@ module Square
|
|
161
189
|
@orders ||= OrdersApi.new config
|
162
190
|
end
|
163
191
|
|
192
|
+
# Access to order_custom_attributes controller.
|
193
|
+
# @return [OrderCustomAttributesApi] Returns the controller instance.
|
194
|
+
def order_custom_attributes
|
195
|
+
@order_custom_attributes ||= OrderCustomAttributesApi.new config
|
196
|
+
end
|
197
|
+
|
164
198
|
# Access to payments controller.
|
165
199
|
# @return [PaymentsApi] Returns the controller instance.
|
166
200
|
def payments
|
167
201
|
@payments ||= PaymentsApi.new config
|
168
202
|
end
|
169
203
|
|
204
|
+
# Access to payouts controller.
|
205
|
+
# @return [PayoutsApi] Returns the controller instance.
|
206
|
+
def payouts
|
207
|
+
@payouts ||= PayoutsApi.new config
|
208
|
+
end
|
209
|
+
|
170
210
|
# Access to refunds controller.
|
171
211
|
# @return [RefundsApi] Returns the controller instance.
|
172
212
|
def refunds
|
173
213
|
@refunds ||= RefundsApi.new config
|
174
214
|
end
|
175
215
|
|
216
|
+
# Access to sites controller.
|
217
|
+
# @return [SitesApi] Returns the controller instance.
|
218
|
+
def sites
|
219
|
+
@sites ||= SitesApi.new config
|
220
|
+
end
|
221
|
+
|
222
|
+
# Access to snippets controller.
|
223
|
+
# @return [SnippetsApi] Returns the controller instance.
|
224
|
+
def snippets
|
225
|
+
@snippets ||= SnippetsApi.new config
|
226
|
+
end
|
227
|
+
|
176
228
|
# Access to subscriptions controller.
|
177
229
|
# @return [SubscriptionsApi] Returns the controller instance.
|
178
230
|
def subscriptions
|
@@ -191,17 +243,37 @@ module Square
|
|
191
243
|
@terminal ||= TerminalApi.new config
|
192
244
|
end
|
193
245
|
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
246
|
+
# Access to vendors controller.
|
247
|
+
# @return [VendorsApi] Returns the controller instance.
|
248
|
+
def vendors
|
249
|
+
@vendors ||= VendorsApi.new config
|
250
|
+
end
|
251
|
+
|
252
|
+
# Access to webhook_subscriptions controller.
|
253
|
+
# @return [WebhookSubscriptionsApi] Returns the controller instance.
|
254
|
+
def webhook_subscriptions
|
255
|
+
@webhook_subscriptions ||= WebhookSubscriptionsApi.new config
|
256
|
+
end
|
257
|
+
|
258
|
+
def initialize(connection: nil, adapter: :net_http_persistent, timeout: 60,
|
259
|
+
max_retries: 0, retry_interval: 1, backoff_factor: 2,
|
260
|
+
retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
|
261
|
+
retry_methods: %i[get put], environment: 'production',
|
262
|
+
custom_url: 'https://connect.squareup.com',
|
263
|
+
square_version: '2023-01-19', access_token: '',
|
264
|
+
user_agent_detail: '', additional_headers: {}, config: nil)
|
198
265
|
@config = if config.nil?
|
199
|
-
Configuration.new(
|
266
|
+
Configuration.new(connection: connection, adapter: adapter,
|
267
|
+
timeout: timeout, max_retries: max_retries,
|
200
268
|
retry_interval: retry_interval,
|
201
269
|
backoff_factor: backoff_factor,
|
270
|
+
retry_statuses: retry_statuses,
|
271
|
+
retry_methods: retry_methods,
|
202
272
|
environment: environment,
|
273
|
+
custom_url: custom_url,
|
203
274
|
square_version: square_version,
|
204
275
|
access_token: access_token,
|
276
|
+
user_agent_detail: user_agent_detail,
|
205
277
|
additional_headers: additional_headers)
|
206
278
|
else
|
207
279
|
config
|