square.rb 9.1.0.20210317 → 12.0.0.20210616
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -3
- data/lib/square.rb +5 -0
- data/lib/square/api/bank_accounts_api.rb +5 -5
- data/lib/square/api/base_api.rb +1 -1
- data/lib/square/api/bookings_api.rb +3 -5
- 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 +40 -41
- data/lib/square/api/customer_groups_api.rb +4 -4
- data/lib/square/api/customer_segments_api.rb +4 -4
- data/lib/square/api/customers_api.rb +45 -26
- data/lib/square/api/devices_api.rb +2 -1
- data/lib/square/api/disputes_api.rb +100 -91
- data/lib/square/api/gift_card_activities_api.rb +127 -0
- data/lib/square/api/gift_cards_api.rb +291 -0
- data/lib/square/api/inventory_api.rb +16 -16
- data/lib/square/api/invoices_api.rb +14 -14
- data/lib/square/api/locations_api.rb +1 -2
- data/lib/square/api/loyalty_api.rb +66 -14
- data/lib/square/api/merchants_api.rb +1 -1
- data/lib/square/api/o_auth_api.rb +8 -9
- data/lib/square/api/orders_api.rb +35 -33
- data/lib/square/api/payments_api.rb +4 -1
- data/lib/square/api/refunds_api.rb +4 -1
- data/lib/square/api/sites_api.rb +42 -0
- data/lib/square/api/snippets_api.rb +146 -0
- data/lib/square/api/subscriptions_api.rb +36 -1
- data/lib/square/api/team_api.rb +40 -40
- data/lib/square/api/transactions_api.rb +32 -20
- data/lib/square/api/v1_employees_api.rb +2 -1
- data/lib/square/api/v1_transactions_api.rb +9 -0
- data/lib/square/api_helper.rb +5 -5
- data/lib/square/client.rb +37 -3
- data/lib/square/configuration.rb +23 -8
- data/lib/square/http/faraday_client.rb +5 -2
- data/test/api/test_locations_api.rb +1 -1
- metadata +11 -6
@@ -247,7 +247,8 @@ module Square
|
|
247
247
|
# employee with that role. For example, an employee with a "Shift Manager"
|
248
248
|
# role might be able to issue refunds in Square Point of Sale, whereas an
|
249
249
|
# employee with a "Clerk" role might not.
|
250
|
-
# Roles are assigned with the
|
250
|
+
# Roles are assigned with the
|
251
|
+
# [V1UpdateEmployee]($e/V1Employees/UpdateEmployeeRole)
|
251
252
|
# endpoint. An employee can have only one role at a time.
|
252
253
|
# If an employee has no role, they have none of the permissions associated
|
253
254
|
# with roles. All employees can accept payments with Square Point of Sale.
|
@@ -20,6 +20,7 @@ module Square
|
|
20
20
|
order: nil,
|
21
21
|
limit: nil,
|
22
22
|
batch_token: nil)
|
23
|
+
warn 'Endpoint list_orders in V1TransactionsApi is deprecated'
|
23
24
|
# Prepare query url.
|
24
25
|
_query_builder = config.get_base_uri
|
25
26
|
_query_builder << '/v1/{location_id}/orders'
|
@@ -66,6 +67,7 @@ module Square
|
|
66
67
|
# @return [V1Order Hash] response from the API call
|
67
68
|
def retrieve_order(location_id:,
|
68
69
|
order_id:)
|
70
|
+
warn 'Endpoint retrieve_order in V1TransactionsApi is deprecated'
|
69
71
|
# Prepare query url.
|
70
72
|
_query_builder = config.get_base_uri
|
71
73
|
_query_builder << '/v1/{location_id}/orders/{order_id}'
|
@@ -111,6 +113,7 @@ module Square
|
|
111
113
|
def update_order(location_id:,
|
112
114
|
order_id:,
|
113
115
|
body:)
|
116
|
+
warn 'Endpoint update_order in V1TransactionsApi is deprecated'
|
114
117
|
# Prepare query url.
|
115
118
|
_query_builder = config.get_base_uri
|
116
119
|
_query_builder << '/v1/{location_id}/orders/{order_id}'
|
@@ -184,6 +187,7 @@ module Square
|
|
184
187
|
limit: nil,
|
185
188
|
batch_token: nil,
|
186
189
|
include_partial: false)
|
190
|
+
warn 'Endpoint list_payments in V1TransactionsApi is deprecated'
|
187
191
|
# Prepare query url.
|
188
192
|
_query_builder = config.get_base_uri
|
189
193
|
_query_builder << '/v1/{location_id}/payments'
|
@@ -233,6 +237,7 @@ module Square
|
|
233
237
|
# @return [V1Payment Hash] response from the API call
|
234
238
|
def retrieve_payment(location_id:,
|
235
239
|
payment_id:)
|
240
|
+
warn 'Endpoint retrieve_payment in V1TransactionsApi is deprecated'
|
236
241
|
# Prepare query url.
|
237
242
|
_query_builder = config.get_base_uri
|
238
243
|
_query_builder << '/v1/{location_id}/payments/{payment_id}'
|
@@ -294,6 +299,7 @@ module Square
|
|
294
299
|
end_time: nil,
|
295
300
|
limit: nil,
|
296
301
|
batch_token: nil)
|
302
|
+
warn 'Endpoint list_refunds in V1TransactionsApi is deprecated'
|
297
303
|
# Prepare query url.
|
298
304
|
_query_builder = config.get_base_uri
|
299
305
|
_query_builder << '/v1/{location_id}/refunds'
|
@@ -350,6 +356,7 @@ module Square
|
|
350
356
|
# @return [V1Refund Hash] response from the API call
|
351
357
|
def create_refund(location_id:,
|
352
358
|
body:)
|
359
|
+
warn 'Endpoint create_refund in V1TransactionsApi is deprecated'
|
353
360
|
# Prepare query url.
|
354
361
|
_query_builder = config.get_base_uri
|
355
362
|
_query_builder << '/v1/{location_id}/refunds'
|
@@ -417,6 +424,7 @@ module Square
|
|
417
424
|
limit: nil,
|
418
425
|
status: nil,
|
419
426
|
batch_token: nil)
|
427
|
+
warn 'Endpoint list_settlements in V1TransactionsApi is deprecated'
|
420
428
|
# Prepare query url.
|
421
429
|
_query_builder = config.get_base_uri
|
422
430
|
_query_builder << '/v1/{location_id}/settlements'
|
@@ -479,6 +487,7 @@ module Square
|
|
479
487
|
# @return [V1Settlement Hash] response from the API call
|
480
488
|
def retrieve_settlement(location_id:,
|
481
489
|
settlement_id:)
|
490
|
+
warn 'Endpoint retrieve_settlement in V1TransactionsApi is deprecated'
|
482
491
|
# Prepare query url.
|
483
492
|
_query_builder = config.get_base_uri
|
484
493
|
_query_builder << '/v1/{location_id}/settlements/{settlement_id}'
|
data/lib/square/api_helper.rb
CHANGED
@@ -63,9 +63,7 @@ module Square
|
|
63
63
|
# Appends the given set of parameters to the given query string.
|
64
64
|
# @param [String] The query string builder to add the query parameters to.
|
65
65
|
# @param [Hash] The parameters to append.
|
66
|
-
|
67
|
-
def self.append_url_with_query_parameters(query_builder, parameters,
|
68
|
-
array_serialization: 'indexed')
|
66
|
+
def self.append_url_with_query_parameters(query_builder, parameters)
|
69
67
|
# Perform parameter validation.
|
70
68
|
unless query_builder.instance_of? String
|
71
69
|
raise ArgumentError, 'Given value for parameter \"query_builder\"
|
@@ -75,6 +73,8 @@ module Square
|
|
75
73
|
# Return if there are no parameters to replace.
|
76
74
|
return query_builder if parameters.nil?
|
77
75
|
|
76
|
+
array_serialization = 'indexed'
|
77
|
+
|
78
78
|
parameters.each do |key, value|
|
79
79
|
seperator = query_builder.include?('?') ? '&' : '?'
|
80
80
|
unless value.nil?
|
@@ -151,8 +151,8 @@ module Square
|
|
151
151
|
# Form encodes a hash of parameters.
|
152
152
|
# @param [Hash] The hash of parameters to encode.
|
153
153
|
# @return [Hash] A hash with the same parameters form encoded.
|
154
|
-
def self.form_encode_parameters(form_parameters
|
155
|
-
|
154
|
+
def self.form_encode_parameters(form_parameters)
|
155
|
+
array_serialization = 'indexed'
|
156
156
|
encoded = {}
|
157
157
|
form_parameters.each do |key, value|
|
158
158
|
encoded.merge!(APIHelper.form_encode(value, key, formatting:
|
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
|
+
'12.0.0.20210616'
|
8
8
|
end
|
9
9
|
|
10
10
|
def square_version
|
@@ -53,6 +53,12 @@ module Square
|
|
53
53
|
@bookings ||= BookingsApi.new config
|
54
54
|
end
|
55
55
|
|
56
|
+
# Access to cards controller.
|
57
|
+
# @return [CardsApi] Returns the controller instance.
|
58
|
+
def cards
|
59
|
+
@cards ||= CardsApi.new config
|
60
|
+
end
|
61
|
+
|
56
62
|
# Access to cash_drawers controller.
|
57
63
|
# @return [CashDrawersApi] Returns the controller instance.
|
58
64
|
def cash_drawers
|
@@ -101,6 +107,18 @@ module Square
|
|
101
107
|
@employees ||= EmployeesApi.new config
|
102
108
|
end
|
103
109
|
|
110
|
+
# Access to gift_cards controller.
|
111
|
+
# @return [GiftCardsApi] Returns the controller instance.
|
112
|
+
def gift_cards
|
113
|
+
@gift_cards ||= GiftCardsApi.new config
|
114
|
+
end
|
115
|
+
|
116
|
+
# Access to gift_card_activities controller.
|
117
|
+
# @return [GiftCardActivitiesApi] Returns the controller instance.
|
118
|
+
def gift_card_activities
|
119
|
+
@gift_card_activities ||= GiftCardActivitiesApi.new config
|
120
|
+
end
|
121
|
+
|
104
122
|
# Access to inventory controller.
|
105
123
|
# @return [InventoryApi] Returns the controller instance.
|
106
124
|
def inventory
|
@@ -167,6 +185,18 @@ module Square
|
|
167
185
|
@refunds ||= RefundsApi.new config
|
168
186
|
end
|
169
187
|
|
188
|
+
# Access to sites controller.
|
189
|
+
# @return [SitesApi] Returns the controller instance.
|
190
|
+
def sites
|
191
|
+
@sites ||= SitesApi.new config
|
192
|
+
end
|
193
|
+
|
194
|
+
# Access to snippets controller.
|
195
|
+
# @return [SnippetsApi] Returns the controller instance.
|
196
|
+
def snippets
|
197
|
+
@snippets ||= SnippetsApi.new config
|
198
|
+
end
|
199
|
+
|
170
200
|
# Access to subscriptions controller.
|
171
201
|
# @return [SubscriptionsApi] Returns the controller instance.
|
172
202
|
def subscriptions
|
@@ -186,14 +216,18 @@ module Square
|
|
186
216
|
end
|
187
217
|
|
188
218
|
def initialize(timeout: 60, max_retries: 0, retry_interval: 1,
|
189
|
-
backoff_factor:
|
219
|
+
backoff_factor: 2,
|
220
|
+
retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
|
221
|
+
retry_methods: %i[get put], environment: 'production',
|
190
222
|
custom_url: 'https://connect.squareup.com',
|
191
|
-
square_version: '2021-
|
223
|
+
square_version: '2021-06-16', access_token: 'TODO: Replace',
|
192
224
|
additional_headers: {}, config: nil)
|
193
225
|
@config = if config.nil?
|
194
226
|
Configuration.new(timeout: timeout, max_retries: max_retries,
|
195
227
|
retry_interval: retry_interval,
|
196
228
|
backoff_factor: backoff_factor,
|
229
|
+
retry_statuses: retry_statuses,
|
230
|
+
retry_methods: retry_methods,
|
197
231
|
environment: environment,
|
198
232
|
custom_url: custom_url,
|
199
233
|
square_version: square_version,
|
data/lib/square/configuration.rb
CHANGED
@@ -8,6 +8,8 @@ module Square
|
|
8
8
|
attr_reader :max_retries
|
9
9
|
attr_reader :retry_interval
|
10
10
|
attr_reader :backoff_factor
|
11
|
+
attr_reader :retry_statuses
|
12
|
+
attr_reader :retry_methods
|
11
13
|
attr_reader :environment
|
12
14
|
attr_reader :custom_url
|
13
15
|
attr_reader :square_version
|
@@ -22,9 +24,11 @@ module Square
|
|
22
24
|
end
|
23
25
|
|
24
26
|
def initialize(timeout: 60, max_retries: 0, retry_interval: 1,
|
25
|
-
backoff_factor:
|
27
|
+
backoff_factor: 2,
|
28
|
+
retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
|
29
|
+
retry_methods: %i[get put], environment: 'production',
|
26
30
|
custom_url: 'https://connect.squareup.com',
|
27
|
-
square_version: '2021-
|
31
|
+
square_version: '2021-06-16', access_token: 'TODO: Replace',
|
28
32
|
additional_headers: {})
|
29
33
|
# The value to use for connection timeout
|
30
34
|
@timeout = timeout
|
@@ -39,6 +43,12 @@ module Square
|
|
39
43
|
# by in order to provide backoff
|
40
44
|
@backoff_factor = backoff_factor
|
41
45
|
|
46
|
+
# A list of HTTP statuses to retry
|
47
|
+
@retry_statuses = retry_statuses
|
48
|
+
|
49
|
+
# A list of HTTP methods to retry
|
50
|
+
@retry_methods = retry_methods
|
51
|
+
|
42
52
|
# Current API environment
|
43
53
|
@environment = String(environment)
|
44
54
|
|
@@ -59,13 +69,15 @@ module Square
|
|
59
69
|
end
|
60
70
|
|
61
71
|
def clone_with(timeout: nil, max_retries: nil, retry_interval: nil,
|
62
|
-
backoff_factor: nil,
|
63
|
-
|
64
|
-
additional_headers: nil)
|
72
|
+
backoff_factor: nil, retry_statuses: nil, retry_methods: nil,
|
73
|
+
environment: nil, custom_url: nil, square_version: nil,
|
74
|
+
access_token: nil, additional_headers: nil)
|
65
75
|
timeout ||= self.timeout
|
66
76
|
max_retries ||= self.max_retries
|
67
77
|
retry_interval ||= self.retry_interval
|
68
78
|
backoff_factor ||= self.backoff_factor
|
79
|
+
retry_statuses ||= self.retry_statuses
|
80
|
+
retry_methods ||= self.retry_methods
|
69
81
|
environment ||= self.environment
|
70
82
|
custom_url ||= self.custom_url
|
71
83
|
square_version ||= self.square_version
|
@@ -75,8 +87,9 @@ module Square
|
|
75
87
|
Configuration.new(timeout: timeout, max_retries: max_retries,
|
76
88
|
retry_interval: retry_interval,
|
77
89
|
backoff_factor: backoff_factor,
|
78
|
-
|
79
|
-
|
90
|
+
retry_statuses: retry_statuses,
|
91
|
+
retry_methods: retry_methods, environment: environment,
|
92
|
+
custom_url: custom_url, square_version: square_version,
|
80
93
|
access_token: access_token,
|
81
94
|
additional_headers: additional_headers)
|
82
95
|
end
|
@@ -84,7 +97,9 @@ module Square
|
|
84
97
|
def create_http_client
|
85
98
|
FaradayClient.new(timeout: timeout, max_retries: max_retries,
|
86
99
|
retry_interval: retry_interval,
|
87
|
-
backoff_factor: backoff_factor
|
100
|
+
backoff_factor: backoff_factor,
|
101
|
+
retry_statuses: retry_statuses,
|
102
|
+
retry_methods: retry_methods)
|
88
103
|
end
|
89
104
|
|
90
105
|
# All the environments the SDK can run in.
|
@@ -6,7 +6,8 @@ module Square
|
|
6
6
|
class FaradayClient < HttpClient
|
7
7
|
# The constructor.
|
8
8
|
def initialize(timeout:, max_retries:, retry_interval:,
|
9
|
-
backoff_factor:,
|
9
|
+
backoff_factor:, retry_statuses:, retry_methods:,
|
10
|
+
cache: false, verify: true)
|
10
11
|
@connection = Faraday.new do |faraday|
|
11
12
|
faraday.use Faraday::HttpCache, serializer: Marshal if cache
|
12
13
|
faraday.use FaradayMiddleware::FollowRedirects
|
@@ -16,7 +17,9 @@ module Square
|
|
16
17
|
faraday.ssl[:ca_file] = Certifi.where
|
17
18
|
faraday.ssl[:verify] = verify
|
18
19
|
faraday.request :retry, max: max_retries, interval: retry_interval,
|
19
|
-
backoff_factor: backoff_factor
|
20
|
+
backoff_factor: backoff_factor,
|
21
|
+
retry_statuses: retry_statuses,
|
22
|
+
methods: retry_methods
|
20
23
|
faraday.adapter Faraday.default_adapter
|
21
24
|
faraday.options[:params_encoder] = Faraday::FlatParamsEncoder
|
22
25
|
faraday.options[:timeout] = timeout if timeout > 0
|
@@ -10,7 +10,7 @@ class LocationsApiTests < ApiTestBase
|
|
10
10
|
# Provides information of all locations of a business.
|
11
11
|
#
|
12
12
|
#Many Square API endpoints require a `location_id` parameter.
|
13
|
-
#The `id` field of the [`Location`](
|
13
|
+
#The `id` field of the [`Location`]($m/Location) objects returned by this
|
14
14
|
#endpoint correspond to that `location_id` parameter.
|
15
15
|
def test_list_locations()
|
16
16
|
|
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: 12.0.0.20210616
|
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: 2021-
|
11
|
+
date: 2021-06-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logging
|
@@ -31,9 +31,9 @@ dependencies:
|
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '1.0'
|
34
|
-
- - "
|
34
|
+
- - "<="
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version: 1.0
|
36
|
+
version: 1.3.0
|
37
37
|
type: :runtime
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -41,9 +41,9 @@ dependencies:
|
|
41
41
|
- - "~>"
|
42
42
|
- !ruby/object:Gem::Version
|
43
43
|
version: '1.0'
|
44
|
-
- - "
|
44
|
+
- - "<="
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: 1.0
|
46
|
+
version: 1.3.0
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: faraday_middleware
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -140,6 +140,7 @@ files:
|
|
140
140
|
- lib/square/api/bank_accounts_api.rb
|
141
141
|
- lib/square/api/base_api.rb
|
142
142
|
- lib/square/api/bookings_api.rb
|
143
|
+
- lib/square/api/cards_api.rb
|
143
144
|
- lib/square/api/cash_drawers_api.rb
|
144
145
|
- lib/square/api/catalog_api.rb
|
145
146
|
- lib/square/api/checkout_api.rb
|
@@ -149,6 +150,8 @@ files:
|
|
149
150
|
- lib/square/api/devices_api.rb
|
150
151
|
- lib/square/api/disputes_api.rb
|
151
152
|
- lib/square/api/employees_api.rb
|
153
|
+
- lib/square/api/gift_card_activities_api.rb
|
154
|
+
- lib/square/api/gift_cards_api.rb
|
152
155
|
- lib/square/api/inventory_api.rb
|
153
156
|
- lib/square/api/invoices_api.rb
|
154
157
|
- lib/square/api/labor_api.rb
|
@@ -160,6 +163,8 @@ files:
|
|
160
163
|
- lib/square/api/orders_api.rb
|
161
164
|
- lib/square/api/payments_api.rb
|
162
165
|
- lib/square/api/refunds_api.rb
|
166
|
+
- lib/square/api/sites_api.rb
|
167
|
+
- lib/square/api/snippets_api.rb
|
163
168
|
- lib/square/api/subscriptions_api.rb
|
164
169
|
- lib/square/api/team_api.rb
|
165
170
|
- lib/square/api/terminal_api.rb
|