square.rb 16.0.1.20211117 → 17.0.0.20211215
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 +7 -1
- data/lib/square/api/catalog_api.rb +101 -26
- data/lib/square/api/locations_api.rb +18 -10
- data/lib/square/api/mobile_authorization_api.rb +3 -3
- data/lib/square/api/o_auth_api.rb +7 -7
- data/lib/square/client.rb +8 -3
- data/lib/square/configuration.rb +6 -4
- data/test/api/test_locations_api.rb +2 -5
- 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: 28048e0ca738b0ca2de7579b8dc077c0307266afa1ff42c1ee6808eb64c79f43
|
4
|
+
data.tar.gz: 7ba3afdb67a42eb41864d5fe5839b8b74f525eebac2b6348e51aee92c9399328
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2bf8bcf75bf6558596e20c1f9d3c82d579aa20f4964047c94bc43592b2e1b0f28445d1f788ba30e1272095380a07a5350fc4c2f8082097b12ef29eb424b33bfd
|
7
|
+
data.tar.gz: 4b09ca82e2b15e60b7ae1a7c217bf445cfb8dd0f6ceb60d6e835d08a5ef08657054d15cc58124d85a1be2f30a8d67630a55caaf58c0942cb92de81ec426cfe6d
|
data/lib/square/api/base_api.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'erb'
|
1
2
|
module Square
|
2
3
|
# BaseApi.
|
3
4
|
class BaseApi
|
@@ -8,7 +9,7 @@ module Square
|
|
8
9
|
@http_call_back = http_call_back
|
9
10
|
|
10
11
|
@global_headers = {
|
11
|
-
'user-agent' =>
|
12
|
+
'user-agent' => get_user_agent,
|
12
13
|
'Square-Version' => config.square_version
|
13
14
|
}
|
14
15
|
end
|
@@ -35,5 +36,10 @@ module Square
|
|
35
36
|
|
36
37
|
response
|
37
38
|
end
|
39
|
+
|
40
|
+
def get_user_agent
|
41
|
+
user_agent = 'Square-Ruby-SDK/17.0.0.20211215'
|
42
|
+
user_agent
|
43
|
+
end
|
38
44
|
end
|
39
45
|
end
|
@@ -136,10 +136,10 @@ module Square
|
|
136
136
|
end
|
137
137
|
|
138
138
|
# Uploads an image file to be represented by a
|
139
|
-
# [CatalogImage]($m/CatalogImage) object linked to an existing
|
140
|
-
# [CatalogObject]($m/CatalogObject) instance.
|
141
|
-
#
|
142
|
-
#
|
139
|
+
# [CatalogImage]($m/CatalogImage) object that can be linked to an existing
|
140
|
+
# [CatalogObject]($m/CatalogObject) instance. The resulting `CatalogImage`
|
141
|
+
# is unattached to any `CatalogObject` if the `object_id`
|
142
|
+
# is not specified.
|
143
143
|
# This `CreateCatalogImage` endpoint accepts HTTP multipart/form-data
|
144
144
|
# requests with a JSON part and an image file part in
|
145
145
|
# JPEG, PJPEG, PNG, or GIF format. The maximum file size is 15MB.
|
@@ -196,6 +196,71 @@ module Square
|
|
196
196
|
)
|
197
197
|
end
|
198
198
|
|
199
|
+
# Uploads a new image file to replace the existing one in the specified
|
200
|
+
# [CatalogImage]($m/CatalogImage) object.
|
201
|
+
# This `UpdateCatalogImage` endpoint accepts HTTP multipart/form-data
|
202
|
+
# requests with a JSON part and an image file part in
|
203
|
+
# JPEG, PJPEG, PNG, or GIF format. The maximum file size is 15MB.
|
204
|
+
# @param [String] image_id Required parameter: The ID of the `CatalogImage`
|
205
|
+
# object to update the encapsulated image file.
|
206
|
+
# @param [UpdateCatalogImageRequest] request Optional parameter: Example:
|
207
|
+
# @param [File | UploadIO] image_file Optional parameter: Example:
|
208
|
+
# @return [UpdateCatalogImageResponse Hash] response from the API call
|
209
|
+
def update_catalog_image(image_id:,
|
210
|
+
request: nil,
|
211
|
+
image_file: nil)
|
212
|
+
# Prepare query url.
|
213
|
+
_query_builder = config.get_base_uri
|
214
|
+
_query_builder << '/v2/catalog/images/{image_id}'
|
215
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
216
|
+
_query_builder,
|
217
|
+
'image_id' => { 'value' => image_id, 'encode' => true }
|
218
|
+
)
|
219
|
+
_query_url = APIHelper.clean_url _query_builder
|
220
|
+
|
221
|
+
if image_file.is_a? FileWrapper
|
222
|
+
image_file_wrapper = image_file.file
|
223
|
+
image_file_content_type = image_file.content_type
|
224
|
+
else
|
225
|
+
image_file_wrapper = image_file
|
226
|
+
image_file_content_type = 'image/jpeg'
|
227
|
+
end
|
228
|
+
|
229
|
+
# Prepare headers.
|
230
|
+
_headers = {
|
231
|
+
'accept' => 'application/json'
|
232
|
+
}
|
233
|
+
|
234
|
+
# Prepare form parameters.
|
235
|
+
_parameters = {
|
236
|
+
'request' => Faraday::UploadIO.new(
|
237
|
+
StringIO.new(request.to_json),
|
238
|
+
'application/json'
|
239
|
+
),
|
240
|
+
'image_file' => Faraday::UploadIO.new(
|
241
|
+
image_file_wrapper,
|
242
|
+
image_file_content_type
|
243
|
+
)
|
244
|
+
}
|
245
|
+
_parameters = APIHelper.form_encode_parameters(_parameters)
|
246
|
+
|
247
|
+
# Prepare and execute HttpRequest.
|
248
|
+
_request = config.http_client.put(
|
249
|
+
_query_url,
|
250
|
+
headers: _headers,
|
251
|
+
parameters: _parameters
|
252
|
+
)
|
253
|
+
OAuth2.apply(config, _request)
|
254
|
+
_response = execute_request(_request)
|
255
|
+
|
256
|
+
# Return appropriate response type.
|
257
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
258
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
259
|
+
ApiResponse.new(
|
260
|
+
_response, data: decoded, errors: _errors
|
261
|
+
)
|
262
|
+
end
|
263
|
+
|
199
264
|
# Retrieves information about the Square Catalog API, such as batch size
|
200
265
|
# limits that can be used by the `BatchUpsertCatalogObjects` endpoint.
|
201
266
|
# @return [CatalogInfoResponse Hash] response from the API call
|
@@ -226,15 +291,12 @@ module Square
|
|
226
291
|
)
|
227
292
|
end
|
228
293
|
|
229
|
-
# Returns a list of [CatalogObject]($m/CatalogObject)s
|
230
|
-
#
|
231
|
-
#
|
232
|
-
#
|
233
|
-
#
|
234
|
-
#
|
235
|
-
# [CatalogObject]($m/CatalogObject) types:
|
236
|
-
# `ITEM`, `ITEM_VARIATION`, `MODIFIER`, `MODIFIER_LIST`, `CATEGORY`,
|
237
|
-
# `DISCOUNT`, `TAX`, `IMAGE`.
|
294
|
+
# Returns a list of all [CatalogObject]($m/CatalogObject)s of the specified
|
295
|
+
# types in the catalog.
|
296
|
+
# The `types` parameter is specified as a comma-separated list of the
|
297
|
+
# [CatalogObjectType]($m/CatalogObjectType) values,
|
298
|
+
# for example, "`ITEM`, `ITEM_VARIATION`, `MODIFIER`, `MODIFIER_LIST`,
|
299
|
+
# `CATEGORY`, `DISCOUNT`, `TAX`, `IMAGE`".
|
238
300
|
# __Important:__ ListCatalog does not return deleted catalog items. To
|
239
301
|
# retrieve
|
240
302
|
# deleted catalog items, use
|
@@ -247,16 +309,22 @@ module Square
|
|
247
309
|
# for more information.
|
248
310
|
# @param [String] types Optional parameter: An optional case-insensitive,
|
249
311
|
# comma-separated list of object types to retrieve. The valid values are
|
250
|
-
# defined in the [CatalogObjectType]($m/CatalogObjectType) enum,
|
251
|
-
# `ITEM`, `ITEM_VARIATION`, `CATEGORY`, `DISCOUNT`, `TAX`,
|
252
|
-
# `MODIFIER_LIST`,
|
253
|
-
# returns objects of all the types at the version of the
|
254
|
-
# make the request.
|
312
|
+
# defined in the [CatalogObjectType]($m/CatalogObjectType) enum, for
|
313
|
+
# example, `ITEM`, `ITEM_VARIATION`, `CATEGORY`, `DISCOUNT`, `TAX`,
|
314
|
+
# `MODIFIER`, `MODIFIER_LIST`, `IMAGE`, etc. If this is unspecified, the
|
315
|
+
# operation returns objects of all the top level types at the version of the
|
316
|
+
# Square API used to make the request. Object types that are nested onto
|
317
|
+
# other object types are not included in the defaults. At the current API
|
318
|
+
# version the default object types are: ITEM, CATEGORY, TAX, DISCOUNT,
|
319
|
+
# MODIFIER_LIST, DINING_OPTION, TAX_EXEMPTION, SERVICE_CHARGE, PRICING_RULE,
|
320
|
+
# PRODUCT_SET, TIME_PERIOD, MEASUREMENT_UNIT, SUBSCRIPTION_PLAN,
|
321
|
+
# ITEM_OPTION, CUSTOM_ATTRIBUTE_DEFINITION, QUICK_AMOUNT_SETTINGS.
|
255
322
|
# @param [Long] catalog_version Optional parameter: The specific version of
|
256
323
|
# the catalog objects to be included in the response. This allows you to
|
257
324
|
# retrieve historical versions of objects. The specified version value is
|
258
325
|
# matched against the [CatalogObject]($m/CatalogObject)s' `version`
|
259
|
-
# attribute.
|
326
|
+
# attribute. If not included, results will be from the current version of
|
327
|
+
# the catalog.
|
260
328
|
# @return [ListCatalogResponse Hash] response from the API call
|
261
329
|
def list_catalog(cursor: nil,
|
262
330
|
types: nil,
|
@@ -382,17 +450,24 @@ module Square
|
|
382
450
|
# catalog objects to be retrieved.
|
383
451
|
# @param [Boolean] include_related_objects Optional parameter: If `true`,
|
384
452
|
# the response will include additional objects that are related to the
|
385
|
-
# requested
|
386
|
-
#
|
387
|
-
#
|
388
|
-
#
|
389
|
-
#
|
390
|
-
# be
|
391
|
-
#
|
453
|
+
# requested objects. Related objects are defined as any objects referenced
|
454
|
+
# by ID by the results in the `objects` field of the response. These objects
|
455
|
+
# are put in the `related_objects` field. Setting this to `true` is helpful
|
456
|
+
# when the objects are needed for immediate display to a user. This process
|
457
|
+
# only goes one level deep. Objects referenced by the related objects will
|
458
|
+
# not be included. For example, if the `objects` field of the response
|
459
|
+
# contains a CatalogItem, its associated CatalogCategory objects, CatalogTax
|
460
|
+
# objects, CatalogImage objects and CatalogModifierLists will be returned in
|
461
|
+
# the `related_objects` field of the response. If the `objects` field of the
|
462
|
+
# response contains a CatalogItemVariation, its parent CatalogItem will be
|
463
|
+
# returned in the `related_objects` field of the response. Default value:
|
464
|
+
# `false`
|
392
465
|
# @param [Long] catalog_version Optional parameter: Requests objects as of a
|
393
466
|
# specific version of the catalog. This allows you to retrieve historical
|
394
467
|
# versions of objects. The value to retrieve a specific version of an object
|
395
468
|
# can be found in the version field of [CatalogObject]($m/CatalogObject)s.
|
469
|
+
# If not included, results will be from the current version of the
|
470
|
+
# catalog.
|
396
471
|
# @return [RetrieveCatalogObjectResponse Hash] response from the API call
|
397
472
|
def retrieve_catalog_object(object_id:,
|
398
473
|
include_related_objects: false,
|
@@ -5,10 +5,8 @@ module Square
|
|
5
5
|
super(config, http_call_back: http_call_back)
|
6
6
|
end
|
7
7
|
|
8
|
-
# Provides
|
9
|
-
#
|
10
|
-
# The `id` field of the [`Location`]($m/Location) objects returned by this
|
11
|
-
# endpoint correspond to that `location_id` parameter.
|
8
|
+
# Provides details about all of the seller's locations,
|
9
|
+
# including those with an inactive status.
|
12
10
|
# @return [ListLocationsResponse Hash] response from the API call
|
13
11
|
def list_locations
|
14
12
|
# Prepare query url.
|
@@ -37,7 +35,17 @@ module Square
|
|
37
35
|
)
|
38
36
|
end
|
39
37
|
|
40
|
-
# Creates a location.
|
38
|
+
# Creates a [location](https://developer.squareup.com/docs/locations-api).
|
39
|
+
# Creating new locations allows for separate configuration of receipt
|
40
|
+
# layouts, item prices,
|
41
|
+
# and sales reports. Developers can use locations to separate sales activity
|
42
|
+
# via applications
|
43
|
+
# that integrate with Square from sales activity elsewhere in a seller's
|
44
|
+
# account.
|
45
|
+
# Locations created programmatically with the Locations API will last
|
46
|
+
# forever and
|
47
|
+
# are visible to the seller for their own management, so ensure that
|
48
|
+
# each location has a sensible and unique name.
|
41
49
|
# @param [CreateLocationRequest] body Required parameter: An object
|
42
50
|
# containing the fields to POST for the request. See the corresponding
|
43
51
|
# object definition for field details.
|
@@ -71,12 +79,12 @@ module Square
|
|
71
79
|
)
|
72
80
|
end
|
73
81
|
|
74
|
-
# Retrieves details of a location.
|
75
|
-
# as the location ID to retrieve details of the
|
76
|
-
#
|
82
|
+
# Retrieves details of a single location. Specify "main"
|
83
|
+
# as the location ID to retrieve details of the [main
|
84
|
+
# location](https://developer.squareup.com/docs/locations-api#about-the-main
|
85
|
+
# -location).
|
77
86
|
# @param [String] location_id Required parameter: The ID of the location to
|
78
|
-
# retrieve.
|
79
|
-
# main location.
|
87
|
+
# retrieve. Specify the string "main" to return the main location.
|
80
88
|
# @return [RetrieveLocationResponse Hash] response from the API call
|
81
89
|
def retrieve_location(location_id:)
|
82
90
|
# Prepare query url.
|
@@ -6,9 +6,9 @@ module Square
|
|
6
6
|
end
|
7
7
|
|
8
8
|
# Generates code to authorize a mobile application to connect to a Square
|
9
|
-
# card reader
|
10
|
-
# Authorization codes are one-time-use and expire
|
11
|
-
# issued.
|
9
|
+
# card reader.
|
10
|
+
# Authorization codes are one-time-use codes and expire 60 minutes after
|
11
|
+
# being issued.
|
12
12
|
# __Important:__ The `Authorization` header you provide to this endpoint
|
13
13
|
# must have the following format:
|
14
14
|
# ```
|
@@ -12,11 +12,11 @@ module Square
|
|
12
12
|
# okens).
|
13
13
|
# Renews an OAuth access token before it expires.
|
14
14
|
# OAuth access tokens besides your application's personal access token
|
15
|
-
# expire after
|
16
|
-
# You can also renew expired tokens within
|
15
|
+
# expire after 30 days.
|
16
|
+
# You can also renew expired tokens within 15 days of their expiration.
|
17
17
|
# You cannot renew an access token that has been expired for more than 15
|
18
18
|
# days.
|
19
|
-
# Instead, the associated user must
|
19
|
+
# Instead, the associated user must recomplete the OAuth flow from the
|
20
20
|
# beginning.
|
21
21
|
# __Important:__ The `Authorization` header for this endpoint must have the
|
22
22
|
# following format:
|
@@ -25,10 +25,10 @@ module Square
|
|
25
25
|
# ```
|
26
26
|
# Replace `APPLICATION_SECRET` with the application secret on the
|
27
27
|
# Credentials
|
28
|
-
# page in the [
|
29
|
-
# @param [String] client_id Required parameter: Your application ID,
|
30
|
-
# available
|
31
|
-
# Dashboard.
|
28
|
+
# page in the [Developer Dashboard](https://developer.squareup.com/apps).
|
29
|
+
# @param [String] client_id Required parameter: Your application ID, which
|
30
|
+
# is available in the OAuth page in the [Developer
|
31
|
+
# Dashboard](https://developer.squareup.com/apps).
|
32
32
|
# @param [RenewTokenRequest] body Required parameter: An object containing
|
33
33
|
# the fields to POST for the request. See the corresponding object
|
34
34
|
# definition for field details.
|
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.0.0.20211215'
|
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: '2021-
|
218
|
-
additional_headers: {}, config: nil)
|
221
|
+
square_version: '2021-12-15', 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: '2021-
|
24
|
-
additional_headers: {})
|
23
|
+
square_version: '2021-12-15', 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
|
|
@@ -67,7 +67,7 @@ module Square
|
|
67
67
|
retry_interval: nil, backoff_factor: nil,
|
68
68
|
retry_statuses: nil, retry_methods: nil, environment: nil,
|
69
69
|
custom_url: nil, square_version: nil, access_token: nil,
|
70
|
-
additional_headers: nil)
|
70
|
+
user_agent_detail: nil, additional_headers: nil)
|
71
71
|
http_client_instance ||= self.http_client_instance
|
72
72
|
timeout ||= self.timeout
|
73
73
|
max_retries ||= self.max_retries
|
@@ -79,6 +79,7 @@ module Square
|
|
79
79
|
custom_url ||= self.custom_url
|
80
80
|
square_version ||= self.square_version
|
81
81
|
access_token ||= self.access_token
|
82
|
+
user_agent_detail ||= self.user_agent_detail
|
82
83
|
additional_headers ||= self.additional_headers
|
83
84
|
|
84
85
|
Configuration.new(http_client_instance: http_client_instance,
|
@@ -89,6 +90,7 @@ module Square
|
|
89
90
|
retry_methods: retry_methods, environment: environment,
|
90
91
|
custom_url: custom_url, square_version: square_version,
|
91
92
|
access_token: access_token,
|
93
|
+
user_agent_detail: user_agent_detail,
|
92
94
|
additional_headers: additional_headers)
|
93
95
|
end
|
94
96
|
|
@@ -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,
|
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
|
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.0.0.20211215
|
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-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logging
|