square.rb 20.0.0.20220512 → 20.1.0.20220616
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/square/api/base_api.rb +1 -1
- data/lib/square/api/catalog_api.rb +3 -3
- data/lib/square/api/gift_cards_api.rb +2 -1
- data/lib/square/api/loyalty_api.rb +3 -2
- data/lib/square/api/terminal_api.rb +1 -3
- data/lib/square/client.rb +7 -6
- data/lib/square/configuration.rb +17 -11
- data/lib/square/http/api_response.rb +7 -9
- data/lib/square/http/faraday_client.rb +4 -4
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 68c3c60d1b69c141d163be8e453c91bd76cca35f98228aeae4a41f7b61afe8a6
|
4
|
+
data.tar.gz: 3df6c78f8e6e493967624fca0cd804c1547aa6ccfb2b57daaac05695a33df12d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab11afe945aa6630b158b07040290572d591b15e2d0829363dd334fc38f5197cc2d5eed47a36cf84e68061667d91b874486892da5acebb4f25420b8bec6e190b
|
7
|
+
data.tar.gz: 3427cb9920daac7363c982754ab7a5c8ef1abf609786e9c8b2bb4a6a4f82da77a2b05e9d7758d71c86613ef8dc54536ea44b9c9f9eed44576d90272121327b67
|
data/lib/square/api/base_api.rb
CHANGED
@@ -38,7 +38,7 @@ module Square
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def get_user_agent
|
41
|
-
user_agent = 'Square-Ruby-SDK/20.
|
41
|
+
user_agent = 'Square-Ruby-SDK/20.1.0.20220616 ({api-version}) {engine}/{engine-version} ({os-info}) {detail}'
|
42
42
|
user_agent['{engine}'] = RUBY_ENGINE
|
43
43
|
user_agent['{engine-version}'] = RUBY_ENGINE_VERSION
|
44
44
|
user_agent['{os-info}'] = RUBY_PLATFORM
|
@@ -316,9 +316,9 @@ module Square
|
|
316
316
|
# Square API used to make the request. Object types that are nested onto
|
317
317
|
# other object types are not included in the defaults. At the current API
|
318
318
|
# version the default object types are: ITEM, CATEGORY, TAX, DISCOUNT,
|
319
|
-
# MODIFIER_LIST,
|
320
|
-
#
|
321
|
-
#
|
319
|
+
# MODIFIER_LIST, PRICING_RULE, PRODUCT_SET, TIME_PERIOD, MEASUREMENT_UNIT,
|
320
|
+
# SUBSCRIPTION_PLAN, ITEM_OPTION, CUSTOM_ATTRIBUTE_DEFINITION,
|
321
|
+
# QUICK_AMOUNT_SETTINGS.
|
322
322
|
# @param [Long] catalog_version Optional parameter: The specific version of
|
323
323
|
# 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
|
@@ -6,7 +6,8 @@ module Square
|
|
6
6
|
end
|
7
7
|
|
8
8
|
# Lists all gift cards. You can specify optional filters to retrieve
|
9
|
-
# a subset of the gift cards.
|
9
|
+
# a subset of the gift cards. Results are sorted by `created_at` in
|
10
|
+
# ascending order.
|
10
11
|
# @param [String] type Optional parameter: If a [type]($m/GiftCardType) is
|
11
12
|
# provided, the endpoint returns gift cards of the specified type.
|
12
13
|
# Otherwise, the endpoint returns gift cards of all types.
|
@@ -113,7 +113,7 @@ module Square
|
|
113
113
|
)
|
114
114
|
end
|
115
115
|
|
116
|
-
# Adds points to a loyalty account.
|
116
|
+
# Adds points earned from the base loyalty program to a loyalty account.
|
117
117
|
# - If you are using the Orders API to manage orders, you only provide the
|
118
118
|
# `order_id`.
|
119
119
|
# The endpoint reads the order to compute points to add to the buyer's
|
@@ -124,6 +124,7 @@ module Square
|
|
124
124
|
# [CalculateLoyaltyPoints]($e/Loyalty/CalculateLoyaltyPoints) to compute the
|
125
125
|
# points
|
126
126
|
# that you provide to this endpoint.
|
127
|
+
# This endpoint excludes additional points earned from loyalty promotions.
|
127
128
|
# @param [String] account_id Required parameter: The [loyalty
|
128
129
|
# account]($m/LoyaltyAccount) ID to which to add the points.
|
129
130
|
# @param [AccumulateLoyaltyPointsRequest] body Required parameter: An object
|
@@ -329,7 +330,7 @@ module Square
|
|
329
330
|
)
|
330
331
|
end
|
331
332
|
|
332
|
-
# Calculates the points a purchase earns.
|
333
|
+
# Calculates the points a purchase earns from the base loyalty program.
|
333
334
|
# - If you are using the Orders API to manage orders, you provide the
|
334
335
|
# `order_id` in the request. The
|
335
336
|
# endpoint calculates the points by reading the order.
|
@@ -5,9 +5,7 @@ module Square
|
|
5
5
|
super(config, http_call_back: http_call_back)
|
6
6
|
end
|
7
7
|
|
8
|
-
# Creates a Terminal action request and sends it to the specified device
|
9
|
-
# take a payment
|
10
|
-
# for the requested amount.
|
8
|
+
# Creates a Terminal action request and sends it to the specified device.
|
11
9
|
# @param [CreateTerminalActionRequest] body Required parameter: An object
|
12
10
|
# containing the fields to POST for the request. See the corresponding
|
13
11
|
# object definition for field details.
|
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
|
-
'20.
|
7
|
+
'20.1.0.20220616'
|
8
8
|
end
|
9
9
|
|
10
10
|
def square_version
|
@@ -231,16 +231,17 @@ module Square
|
|
231
231
|
@vendors ||= VendorsApi.new config
|
232
232
|
end
|
233
233
|
|
234
|
-
def initialize(connection: nil,
|
235
|
-
|
234
|
+
def initialize(connection: nil, adapter: Faraday.default_adapter,
|
235
|
+
timeout: 60, max_retries: 0, retry_interval: 1,
|
236
|
+
backoff_factor: 2,
|
236
237
|
retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
|
237
238
|
retry_methods: %i[get put], environment: 'production',
|
238
239
|
custom_url: 'https://connect.squareup.com',
|
239
|
-
square_version: '2022-
|
240
|
+
square_version: '2022-06-16', access_token: '',
|
240
241
|
user_agent_detail: '', additional_headers: {}, config: nil)
|
241
242
|
@config = if config.nil?
|
242
|
-
Configuration.new(connection: connection,
|
243
|
-
max_retries: max_retries,
|
243
|
+
Configuration.new(connection: connection, adapter: adapter,
|
244
|
+
timeout: timeout, max_retries: max_retries,
|
244
245
|
retry_interval: retry_interval,
|
245
246
|
backoff_factor: backoff_factor,
|
246
247
|
retry_statuses: retry_statuses,
|
data/lib/square/configuration.rb
CHANGED
@@ -3,9 +3,9 @@ module Square
|
|
3
3
|
# are configured in this class.
|
4
4
|
class Configuration
|
5
5
|
# The attribute readers for properties.
|
6
|
-
attr_reader :http_client, :connection, :timeout, :max_retries, :retry_interval,
|
7
|
-
:retry_statuses, :retry_methods, :environment, :custom_url,
|
8
|
-
:access_token, :user_agent_detail
|
6
|
+
attr_reader :http_client, :connection, :adapter, :timeout, :max_retries, :retry_interval,
|
7
|
+
:backoff_factor, :retry_statuses, :retry_methods, :environment, :custom_url,
|
8
|
+
:square_version, :access_token, :user_agent_detail
|
9
9
|
|
10
10
|
def additional_headers
|
11
11
|
@additional_headers.clone
|
@@ -15,16 +15,20 @@ module Square
|
|
15
15
|
attr_reader :environments
|
16
16
|
end
|
17
17
|
|
18
|
-
def initialize(connection: nil,
|
19
|
-
|
18
|
+
def initialize(connection: nil, adapter: Faraday.default_adapter,
|
19
|
+
timeout: 60, max_retries: 0, retry_interval: 1,
|
20
|
+
backoff_factor: 2,
|
20
21
|
retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
|
21
22
|
retry_methods: %i[get put], environment: 'production',
|
22
23
|
custom_url: 'https://connect.squareup.com',
|
23
|
-
square_version: '2022-
|
24
|
+
square_version: '2022-06-16', access_token: '',
|
24
25
|
user_agent_detail: '', additional_headers: {})
|
25
26
|
# The Faraday connection object passed by the SDK user for making requests
|
26
27
|
@connection = connection
|
27
28
|
|
29
|
+
# The Faraday adapter object passed by the SDK user for performing http requests
|
30
|
+
@adapter = adapter
|
31
|
+
|
28
32
|
# The value to use for connection timeout
|
29
33
|
@timeout = timeout
|
30
34
|
|
@@ -66,12 +70,13 @@ module Square
|
|
66
70
|
@user_agent_detail = get_user_agent(user_agent_detail)
|
67
71
|
end
|
68
72
|
|
69
|
-
def clone_with(connection: nil,
|
70
|
-
retry_interval: nil, backoff_factor: nil,
|
73
|
+
def clone_with(connection: nil, adapter: nil, timeout: nil,
|
74
|
+
max_retries: nil, retry_interval: nil, backoff_factor: nil,
|
71
75
|
retry_statuses: nil, retry_methods: nil, environment: nil,
|
72
76
|
custom_url: nil, square_version: nil, access_token: nil,
|
73
77
|
user_agent_detail: nil, additional_headers: nil)
|
74
78
|
connection ||= self.connection
|
79
|
+
adapter ||= self.adapter
|
75
80
|
timeout ||= self.timeout
|
76
81
|
max_retries ||= self.max_retries
|
77
82
|
retry_interval ||= self.retry_interval
|
@@ -85,8 +90,8 @@ module Square
|
|
85
90
|
user_agent_detail ||= self.user_agent_detail
|
86
91
|
additional_headers ||= self.additional_headers
|
87
92
|
|
88
|
-
Configuration.new(connection: connection,
|
89
|
-
max_retries: max_retries,
|
93
|
+
Configuration.new(connection: connection, adapter: adapter,
|
94
|
+
timeout: timeout, max_retries: max_retries,
|
90
95
|
retry_interval: retry_interval,
|
91
96
|
backoff_factor: backoff_factor,
|
92
97
|
retry_statuses: retry_statuses,
|
@@ -102,7 +107,8 @@ module Square
|
|
102
107
|
retry_interval: retry_interval,
|
103
108
|
backoff_factor: backoff_factor,
|
104
109
|
retry_statuses: retry_statuses,
|
105
|
-
retry_methods: retry_methods, connection: connection
|
110
|
+
retry_methods: retry_methods, connection: connection,
|
111
|
+
adapter: adapter)
|
106
112
|
end
|
107
113
|
|
108
114
|
def get_user_agent(user_agent_detail)
|
@@ -18,16 +18,14 @@ module Square
|
|
18
18
|
@request = http_response.request
|
19
19
|
@errors = errors
|
20
20
|
|
21
|
-
if data.is_a? Hash
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
end.new(*data.values)
|
21
|
+
if (data.is_a? Hash) && data.keys.any?
|
22
|
+
@body = Struct.new(*data.keys) do
|
23
|
+
define_method(:to_s) { http_response.raw_body }
|
24
|
+
end.new(*data.values)
|
26
25
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
end
|
26
|
+
@cursor = data.fetch(:cursor, nil)
|
27
|
+
data.reject! { |k| %i[cursor errors].include?(k) }
|
28
|
+
@data = Struct.new(*data.keys).new(*data.values) if data.keys.any?
|
31
29
|
else
|
32
30
|
@data = data
|
33
31
|
@body = data
|
@@ -13,12 +13,12 @@ module Square
|
|
13
13
|
# The constructor.
|
14
14
|
def initialize(timeout:, max_retries:, retry_interval:,
|
15
15
|
backoff_factor:, retry_statuses:, retry_methods:,
|
16
|
-
connection
|
16
|
+
connection:, adapter:, cache: false, verify: true)
|
17
17
|
@connection = if connection.nil?
|
18
18
|
create_connection(timeout: timeout, max_retries: max_retries,
|
19
19
|
retry_interval: retry_interval, backoff_factor: backoff_factor,
|
20
20
|
retry_statuses: retry_statuses, retry_methods: retry_methods,
|
21
|
-
cache: cache, verify: verify)
|
21
|
+
adapter: adapter, cache: cache, verify: verify)
|
22
22
|
else
|
23
23
|
connection
|
24
24
|
end
|
@@ -27,7 +27,7 @@ module Square
|
|
27
27
|
# Method to initialize connection.
|
28
28
|
def create_connection(timeout:, max_retries:, retry_interval:,
|
29
29
|
backoff_factor:, retry_statuses:, retry_methods:,
|
30
|
-
cache: false, verify: true)
|
30
|
+
adapter:, cache: false, verify: true)
|
31
31
|
Faraday.new do |faraday|
|
32
32
|
faraday.use Faraday::HttpCache, serializer: Marshal if cache
|
33
33
|
faraday.use Faraday::FollowRedirects::Middleware
|
@@ -43,7 +43,7 @@ module Square
|
|
43
43
|
retry_if: proc { |env, _exc|
|
44
44
|
env.request.context['forced_retry'] ||= false
|
45
45
|
}
|
46
|
-
faraday.adapter
|
46
|
+
faraday.adapter adapter
|
47
47
|
faraday.options[:params_encoder] = Faraday::FlatParamsEncoder
|
48
48
|
faraday.options[:timeout] = timeout if timeout.positive?
|
49
49
|
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: 20.
|
4
|
+
version: 20.1.0.20220616
|
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-06-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logging
|