square.rb 26.0.0.20221214 → 26.1.0.20230119
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/LICENSE +1 -1
- data/lib/square/api/base_api.rb +1 -1
- data/lib/square/api/location_custom_attributes_api.rb +584 -0
- data/lib/square/client.rb +8 -2
- data/lib/square/configuration.rb +1 -1
- data/lib/square/http/http_client.rb +1 -1
- data/lib/square.rb +1 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac8d00e1d947c816019d207e36e19a85ef2f8d66e3b5c4295e3e19f6cfcd5af6
|
4
|
+
data.tar.gz: ba91ef39e6e11e16af9a859abe126cd8f25e0d0751a65a101e63dfb0bbbf4718
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23f2218d4d9757a648c69c5d6d21eb764f121695c6a11ac80607f24bb86301745f410b1103937ad49a157f150784ea1d396ea57393d0743c0742848b8beba0fa
|
7
|
+
data.tar.gz: fc4af83a8b04a151839c45f6f0c632f2b6b5b65abfcde66027d89714ac8566770b5f70407d021337d7cae3daa67957b06ca373eaf4b3b6791aef13ae1029ca87
|
data/LICENSE
CHANGED
data/lib/square/api/base_api.rb
CHANGED
@@ -45,7 +45,7 @@ module Square
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def get_user_agent
|
48
|
-
user_agent = 'Square-Ruby-SDK/26.
|
48
|
+
user_agent = 'Square-Ruby-SDK/26.1.0.20230119 ({api-version}) {engine}/{engine-version} ({os-info}) {detail}'
|
49
49
|
user_agent['{engine}'] = RUBY_ENGINE
|
50
50
|
user_agent['{engine-version}'] = RUBY_ENGINE_VERSION
|
51
51
|
user_agent['{os-info}'] = RUBY_PLATFORM
|
@@ -0,0 +1,584 @@
|
|
1
|
+
module Square
|
2
|
+
# LocationCustomAttributesApi
|
3
|
+
class LocationCustomAttributesApi < BaseApi
|
4
|
+
def initialize(config, http_call_back: nil)
|
5
|
+
super(config, http_call_back: http_call_back)
|
6
|
+
end
|
7
|
+
|
8
|
+
# Lists the location-related [custom attribute
|
9
|
+
# definitions]($m/CustomAttributeDefinition) that belong to a Square seller
|
10
|
+
# account.
|
11
|
+
# When all response pages are retrieved, the results include all custom
|
12
|
+
# attribute definitions
|
13
|
+
# that are visible to the requesting application, including those that are
|
14
|
+
# created by other
|
15
|
+
# applications and set to `VISIBILITY_READ_ONLY` or
|
16
|
+
# `VISIBILITY_READ_WRITE_VALUES`.
|
17
|
+
# @param [VisibilityFilter] visibility_filter Optional parameter: Filters
|
18
|
+
# the `CustomAttributeDefinition` results by their `visibility` values.
|
19
|
+
# @param [Integer] limit Optional parameter: The maximum number of results
|
20
|
+
# to return in a single paged response. This limit is advisory. The response
|
21
|
+
# might contain more or fewer results. The minimum value is 1 and the
|
22
|
+
# maximum value is 100. The default value is 20. For more information, see
|
23
|
+
# [Pagination](https://developer.squareup.com/docs/build-basics/common-api-p
|
24
|
+
# atterns/pagination).
|
25
|
+
# @param [String] cursor Optional parameter: The cursor returned in the
|
26
|
+
# paged response from the previous call to this endpoint. Provide this
|
27
|
+
# cursor to retrieve the next page of results for your original request. For
|
28
|
+
# more information, see
|
29
|
+
# [Pagination](https://developer.squareup.com/docs/build-basics/common-api-p
|
30
|
+
# atterns/pagination).
|
31
|
+
# @return [ListLocationCustomAttributeDefinitionsResponse Hash] response from the API call
|
32
|
+
def list_location_custom_attribute_definitions(visibility_filter: nil,
|
33
|
+
limit: nil,
|
34
|
+
cursor: nil)
|
35
|
+
# Prepare query url.
|
36
|
+
_query_builder = config.get_base_uri
|
37
|
+
_query_builder << '/v2/locations/custom-attribute-definitions'
|
38
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
39
|
+
_query_builder,
|
40
|
+
'visibility_filter' => visibility_filter,
|
41
|
+
'limit' => limit,
|
42
|
+
'cursor' => cursor
|
43
|
+
)
|
44
|
+
_query_url = APIHelper.clean_url _query_builder
|
45
|
+
|
46
|
+
# Prepare headers.
|
47
|
+
_headers = {
|
48
|
+
'accept' => 'application/json'
|
49
|
+
}
|
50
|
+
|
51
|
+
# Prepare and execute HttpRequest.
|
52
|
+
_request = config.http_client.get(
|
53
|
+
_query_url,
|
54
|
+
headers: _headers
|
55
|
+
)
|
56
|
+
OAuth2.apply(config, _request)
|
57
|
+
_response = execute_request(_request)
|
58
|
+
|
59
|
+
# Return appropriate response type.
|
60
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
61
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
62
|
+
ApiResponse.new(
|
63
|
+
_response, data: decoded, errors: _errors
|
64
|
+
)
|
65
|
+
end
|
66
|
+
|
67
|
+
# Creates a location-related [custom attribute
|
68
|
+
# definition]($m/CustomAttributeDefinition) for a Square seller account.
|
69
|
+
# Use this endpoint to define a custom attribute that can be associated with
|
70
|
+
# locations.
|
71
|
+
# A custom attribute definition specifies the `key`, `visibility`, `schema`,
|
72
|
+
# and other properties
|
73
|
+
# for a custom attribute. After the definition is created, you can call
|
74
|
+
# [UpsertLocationCustomAttribute]($e/LocationCustomAttributes/UpsertLocation
|
75
|
+
# CustomAttribute) or
|
76
|
+
# [BulkUpsertLocationCustomAttributes]($e/LocationCustomAttributes/BulkUpser
|
77
|
+
# tLocationCustomAttributes)
|
78
|
+
# to set the custom attribute for locations.
|
79
|
+
# @param [CreateLocationCustomAttributeDefinitionRequest] body Required
|
80
|
+
# parameter: An object containing the fields to POST for the request. See
|
81
|
+
# the corresponding object definition for field details.
|
82
|
+
# @return [CreateLocationCustomAttributeDefinitionResponse Hash] response from the API call
|
83
|
+
def create_location_custom_attribute_definition(body:)
|
84
|
+
# Prepare query url.
|
85
|
+
_query_builder = config.get_base_uri
|
86
|
+
_query_builder << '/v2/locations/custom-attribute-definitions'
|
87
|
+
_query_url = APIHelper.clean_url _query_builder
|
88
|
+
|
89
|
+
# Prepare headers.
|
90
|
+
_headers = {
|
91
|
+
'accept' => 'application/json',
|
92
|
+
'Content-Type' => 'application/json'
|
93
|
+
}
|
94
|
+
|
95
|
+
# Prepare and execute HttpRequest.
|
96
|
+
_request = config.http_client.post(
|
97
|
+
_query_url,
|
98
|
+
headers: _headers,
|
99
|
+
parameters: body.to_json
|
100
|
+
)
|
101
|
+
OAuth2.apply(config, _request)
|
102
|
+
_response = execute_request(_request)
|
103
|
+
|
104
|
+
# Return appropriate response type.
|
105
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
106
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
107
|
+
ApiResponse.new(
|
108
|
+
_response, data: decoded, errors: _errors
|
109
|
+
)
|
110
|
+
end
|
111
|
+
|
112
|
+
# Deletes a location-related [custom attribute
|
113
|
+
# definition]($m/CustomAttributeDefinition) from a Square seller account.
|
114
|
+
# Deleting a custom attribute definition also deletes the corresponding
|
115
|
+
# custom attribute from
|
116
|
+
# all locations.
|
117
|
+
# Only the definition owner can delete a custom attribute definition.
|
118
|
+
# @param [String] key Required parameter: The key of the custom attribute
|
119
|
+
# definition to delete.
|
120
|
+
# @return [DeleteLocationCustomAttributeDefinitionResponse Hash] response from the API call
|
121
|
+
def delete_location_custom_attribute_definition(key:)
|
122
|
+
# Prepare query url.
|
123
|
+
_query_builder = config.get_base_uri
|
124
|
+
_query_builder << '/v2/locations/custom-attribute-definitions/{key}'
|
125
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
126
|
+
_query_builder,
|
127
|
+
'key' => { 'value' => key, 'encode' => true }
|
128
|
+
)
|
129
|
+
_query_url = APIHelper.clean_url _query_builder
|
130
|
+
|
131
|
+
# Prepare headers.
|
132
|
+
_headers = {
|
133
|
+
'accept' => 'application/json'
|
134
|
+
}
|
135
|
+
|
136
|
+
# Prepare and execute HttpRequest.
|
137
|
+
_request = config.http_client.delete(
|
138
|
+
_query_url,
|
139
|
+
headers: _headers
|
140
|
+
)
|
141
|
+
OAuth2.apply(config, _request)
|
142
|
+
_response = execute_request(_request)
|
143
|
+
|
144
|
+
# Return appropriate response type.
|
145
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
146
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
147
|
+
ApiResponse.new(
|
148
|
+
_response, data: decoded, errors: _errors
|
149
|
+
)
|
150
|
+
end
|
151
|
+
|
152
|
+
# Retrieves a location-related [custom attribute
|
153
|
+
# definition]($m/CustomAttributeDefinition) from a Square seller account.
|
154
|
+
# To retrieve a custom attribute definition created by another application,
|
155
|
+
# the `visibility`
|
156
|
+
# setting must be `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`.
|
157
|
+
# @param [String] key Required parameter: The key of the custom attribute
|
158
|
+
# definition to retrieve. If the requesting application is not the
|
159
|
+
# definition owner, you must use the qualified key.
|
160
|
+
# @param [Integer] version Optional parameter: The current version of the
|
161
|
+
# custom attribute definition, which is used for strongly consistent reads
|
162
|
+
# to guarantee that you receive the most up-to-date data. When included in
|
163
|
+
# the request, Square returns the specified version or a higher version if
|
164
|
+
# one exists. If the specified version is higher than the current version,
|
165
|
+
# Square returns a `BAD_REQUEST` error.
|
166
|
+
# @return [RetrieveLocationCustomAttributeDefinitionResponse Hash] response from the API call
|
167
|
+
def retrieve_location_custom_attribute_definition(key:,
|
168
|
+
version: nil)
|
169
|
+
# Prepare query url.
|
170
|
+
_query_builder = config.get_base_uri
|
171
|
+
_query_builder << '/v2/locations/custom-attribute-definitions/{key}'
|
172
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
173
|
+
_query_builder,
|
174
|
+
'key' => { 'value' => key, 'encode' => true }
|
175
|
+
)
|
176
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
177
|
+
_query_builder,
|
178
|
+
'version' => version
|
179
|
+
)
|
180
|
+
_query_url = APIHelper.clean_url _query_builder
|
181
|
+
|
182
|
+
# Prepare headers.
|
183
|
+
_headers = {
|
184
|
+
'accept' => 'application/json'
|
185
|
+
}
|
186
|
+
|
187
|
+
# Prepare and execute HttpRequest.
|
188
|
+
_request = config.http_client.get(
|
189
|
+
_query_url,
|
190
|
+
headers: _headers
|
191
|
+
)
|
192
|
+
OAuth2.apply(config, _request)
|
193
|
+
_response = execute_request(_request)
|
194
|
+
|
195
|
+
# Return appropriate response type.
|
196
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
197
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
198
|
+
ApiResponse.new(
|
199
|
+
_response, data: decoded, errors: _errors
|
200
|
+
)
|
201
|
+
end
|
202
|
+
|
203
|
+
# Updates a location-related [custom attribute
|
204
|
+
# definition]($m/CustomAttributeDefinition) for a Square seller account.
|
205
|
+
# Use this endpoint to update the following fields: `name`, `description`,
|
206
|
+
# `visibility`, or the
|
207
|
+
# `schema` for a `Selection` data type.
|
208
|
+
# Only the definition owner can update a custom attribute definition.
|
209
|
+
# @param [String] key Required parameter: The key of the custom attribute
|
210
|
+
# definition to update.
|
211
|
+
# @param [UpdateLocationCustomAttributeDefinitionRequest] body Required
|
212
|
+
# parameter: An object containing the fields to POST for the request. See
|
213
|
+
# the corresponding object definition for field details.
|
214
|
+
# @return [UpdateLocationCustomAttributeDefinitionResponse Hash] response from the API call
|
215
|
+
def update_location_custom_attribute_definition(key:,
|
216
|
+
body:)
|
217
|
+
# Prepare query url.
|
218
|
+
_query_builder = config.get_base_uri
|
219
|
+
_query_builder << '/v2/locations/custom-attribute-definitions/{key}'
|
220
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
221
|
+
_query_builder,
|
222
|
+
'key' => { 'value' => key, 'encode' => true }
|
223
|
+
)
|
224
|
+
_query_url = APIHelper.clean_url _query_builder
|
225
|
+
|
226
|
+
# Prepare headers.
|
227
|
+
_headers = {
|
228
|
+
'accept' => 'application/json',
|
229
|
+
'Content-Type' => 'application/json'
|
230
|
+
}
|
231
|
+
|
232
|
+
# Prepare and execute HttpRequest.
|
233
|
+
_request = config.http_client.put(
|
234
|
+
_query_url,
|
235
|
+
headers: _headers,
|
236
|
+
parameters: body.to_json
|
237
|
+
)
|
238
|
+
OAuth2.apply(config, _request)
|
239
|
+
_response = execute_request(_request)
|
240
|
+
|
241
|
+
# Return appropriate response type.
|
242
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
243
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
244
|
+
ApiResponse.new(
|
245
|
+
_response, data: decoded, errors: _errors
|
246
|
+
)
|
247
|
+
end
|
248
|
+
|
249
|
+
# Deletes [custom attributes]($m/CustomAttribute) for locations as a bulk
|
250
|
+
# operation.
|
251
|
+
# To delete a custom attribute owned by another application, the
|
252
|
+
# `visibility` setting must be
|
253
|
+
# `VISIBILITY_READ_WRITE_VALUES`.
|
254
|
+
# @param [BulkDeleteLocationCustomAttributesRequest] body Required
|
255
|
+
# parameter: An object containing the fields to POST for the request. See
|
256
|
+
# the corresponding object definition for field details.
|
257
|
+
# @return [BulkDeleteLocationCustomAttributesResponse Hash] response from the API call
|
258
|
+
def bulk_delete_location_custom_attributes(body:)
|
259
|
+
# Prepare query url.
|
260
|
+
_query_builder = config.get_base_uri
|
261
|
+
_query_builder << '/v2/locations/custom-attributes/bulk-delete'
|
262
|
+
_query_url = APIHelper.clean_url _query_builder
|
263
|
+
|
264
|
+
# Prepare headers.
|
265
|
+
_headers = {
|
266
|
+
'accept' => 'application/json',
|
267
|
+
'Content-Type' => 'application/json'
|
268
|
+
}
|
269
|
+
|
270
|
+
# Prepare and execute HttpRequest.
|
271
|
+
_request = config.http_client.post(
|
272
|
+
_query_url,
|
273
|
+
headers: _headers,
|
274
|
+
parameters: body.to_json
|
275
|
+
)
|
276
|
+
OAuth2.apply(config, _request)
|
277
|
+
_response = execute_request(_request)
|
278
|
+
|
279
|
+
# Return appropriate response type.
|
280
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
281
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
282
|
+
ApiResponse.new(
|
283
|
+
_response, data: decoded, errors: _errors
|
284
|
+
)
|
285
|
+
end
|
286
|
+
|
287
|
+
# Creates or updates [custom attributes]($m/CustomAttribute) for locations
|
288
|
+
# as a bulk operation.
|
289
|
+
# Use this endpoint to set the value of one or more custom attributes for
|
290
|
+
# one or more locations.
|
291
|
+
# A custom attribute is based on a custom attribute definition in a Square
|
292
|
+
# seller account, which is
|
293
|
+
# created using the
|
294
|
+
# [CreateLocationCustomAttributeDefinition]($e/LocationCustomAttributes/Crea
|
295
|
+
# teLocationCustomAttributeDefinition) endpoint.
|
296
|
+
# This `BulkUpsertLocationCustomAttributes` endpoint accepts a map of 1 to
|
297
|
+
# 25 individual upsert
|
298
|
+
# requests and returns a map of individual upsert responses. Each upsert
|
299
|
+
# request has a unique ID
|
300
|
+
# and provides a location ID and custom attribute. Each upsert response is
|
301
|
+
# returned with the ID
|
302
|
+
# of the corresponding request.
|
303
|
+
# To create or update a custom attribute owned by another application, the
|
304
|
+
# `visibility` setting
|
305
|
+
# must be `VISIBILITY_READ_WRITE_VALUES`.
|
306
|
+
# @param [BulkUpsertLocationCustomAttributesRequest] body Required
|
307
|
+
# parameter: An object containing the fields to POST for the request. See
|
308
|
+
# the corresponding object definition for field details.
|
309
|
+
# @return [BulkUpsertLocationCustomAttributesResponse Hash] response from the API call
|
310
|
+
def bulk_upsert_location_custom_attributes(body:)
|
311
|
+
# Prepare query url.
|
312
|
+
_query_builder = config.get_base_uri
|
313
|
+
_query_builder << '/v2/locations/custom-attributes/bulk-upsert'
|
314
|
+
_query_url = APIHelper.clean_url _query_builder
|
315
|
+
|
316
|
+
# Prepare headers.
|
317
|
+
_headers = {
|
318
|
+
'accept' => 'application/json',
|
319
|
+
'Content-Type' => 'application/json'
|
320
|
+
}
|
321
|
+
|
322
|
+
# Prepare and execute HttpRequest.
|
323
|
+
_request = config.http_client.post(
|
324
|
+
_query_url,
|
325
|
+
headers: _headers,
|
326
|
+
parameters: body.to_json
|
327
|
+
)
|
328
|
+
OAuth2.apply(config, _request)
|
329
|
+
_response = execute_request(_request)
|
330
|
+
|
331
|
+
# Return appropriate response type.
|
332
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
333
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
334
|
+
ApiResponse.new(
|
335
|
+
_response, data: decoded, errors: _errors
|
336
|
+
)
|
337
|
+
end
|
338
|
+
|
339
|
+
# Lists the [custom attributes]($m/CustomAttribute) associated with a
|
340
|
+
# location.
|
341
|
+
# You can use the `with_definitions` query parameter to also retrieve custom
|
342
|
+
# attribute definitions
|
343
|
+
# in the same call.
|
344
|
+
# When all response pages are retrieved, the results include all custom
|
345
|
+
# attributes that are
|
346
|
+
# visible to the requesting application, including those that are owned by
|
347
|
+
# other applications
|
348
|
+
# and set to `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`.
|
349
|
+
# @param [String] location_id Required parameter: The ID of the target
|
350
|
+
# [location]($m/Location).
|
351
|
+
# @param [VisibilityFilter] visibility_filter Optional parameter: Filters
|
352
|
+
# the `CustomAttributeDefinition` results by their `visibility` values.
|
353
|
+
# @param [Integer] limit Optional parameter: The maximum number of results
|
354
|
+
# to return in a single paged response. This limit is advisory. The response
|
355
|
+
# might contain more or fewer results. The minimum value is 1 and the
|
356
|
+
# maximum value is 100. The default value is 20. For more information, see
|
357
|
+
# [Pagination](https://developer.squareup.com/docs/build-basics/common-api-p
|
358
|
+
# atterns/pagination).
|
359
|
+
# @param [String] cursor Optional parameter: The cursor returned in the
|
360
|
+
# paged response from the previous call to this endpoint. Provide this
|
361
|
+
# cursor to retrieve the next page of results for your original request. For
|
362
|
+
# more information, see
|
363
|
+
# [Pagination](https://developer.squareup.com/docs/build-basics/common-api-p
|
364
|
+
# atterns/pagination).
|
365
|
+
# @param [TrueClass|FalseClass] with_definitions Optional parameter:
|
366
|
+
# Indicates whether to return the [custom attribute
|
367
|
+
# definition]($m/CustomAttributeDefinition) in the `definition` field of
|
368
|
+
# each custom attribute. Set this parameter to `true` to get the name and
|
369
|
+
# description of each custom attribute, information about the data type, or
|
370
|
+
# other definition details. The default value is `false`.
|
371
|
+
# @return [ListLocationCustomAttributesResponse Hash] response from the API call
|
372
|
+
def list_location_custom_attributes(location_id:,
|
373
|
+
visibility_filter: nil,
|
374
|
+
limit: nil,
|
375
|
+
cursor: nil,
|
376
|
+
with_definitions: false)
|
377
|
+
# Prepare query url.
|
378
|
+
_query_builder = config.get_base_uri
|
379
|
+
_query_builder << '/v2/locations/{location_id}/custom-attributes'
|
380
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
381
|
+
_query_builder,
|
382
|
+
'location_id' => { 'value' => location_id, 'encode' => true }
|
383
|
+
)
|
384
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
385
|
+
_query_builder,
|
386
|
+
'visibility_filter' => visibility_filter,
|
387
|
+
'limit' => limit,
|
388
|
+
'cursor' => cursor,
|
389
|
+
'with_definitions' => with_definitions
|
390
|
+
)
|
391
|
+
_query_url = APIHelper.clean_url _query_builder
|
392
|
+
|
393
|
+
# Prepare headers.
|
394
|
+
_headers = {
|
395
|
+
'accept' => 'application/json'
|
396
|
+
}
|
397
|
+
|
398
|
+
# Prepare and execute HttpRequest.
|
399
|
+
_request = config.http_client.get(
|
400
|
+
_query_url,
|
401
|
+
headers: _headers
|
402
|
+
)
|
403
|
+
OAuth2.apply(config, _request)
|
404
|
+
_response = execute_request(_request)
|
405
|
+
|
406
|
+
# Return appropriate response type.
|
407
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
408
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
409
|
+
ApiResponse.new(
|
410
|
+
_response, data: decoded, errors: _errors
|
411
|
+
)
|
412
|
+
end
|
413
|
+
|
414
|
+
# Deletes a [custom attribute]($m/CustomAttribute) associated with a
|
415
|
+
# location.
|
416
|
+
# To delete a custom attribute owned by another application, the
|
417
|
+
# `visibility` setting must be
|
418
|
+
# `VISIBILITY_READ_WRITE_VALUES`.
|
419
|
+
# @param [String] location_id Required parameter: The ID of the target
|
420
|
+
# [location]($m/Location).
|
421
|
+
# @param [String] key Required parameter: The key of the custom attribute to
|
422
|
+
# delete. This key must match the `key` of a custom attribute definition in
|
423
|
+
# the Square seller account. If the requesting application is not the
|
424
|
+
# definition owner, you must use the qualified key.
|
425
|
+
# @return [DeleteLocationCustomAttributeResponse Hash] response from the API call
|
426
|
+
def delete_location_custom_attribute(location_id:,
|
427
|
+
key:)
|
428
|
+
# Prepare query url.
|
429
|
+
_query_builder = config.get_base_uri
|
430
|
+
_query_builder << '/v2/locations/{location_id}/custom-attributes/{key}'
|
431
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
432
|
+
_query_builder,
|
433
|
+
'location_id' => { 'value' => location_id, 'encode' => true },
|
434
|
+
'key' => { 'value' => key, 'encode' => true }
|
435
|
+
)
|
436
|
+
_query_url = APIHelper.clean_url _query_builder
|
437
|
+
|
438
|
+
# Prepare headers.
|
439
|
+
_headers = {
|
440
|
+
'accept' => 'application/json'
|
441
|
+
}
|
442
|
+
|
443
|
+
# Prepare and execute HttpRequest.
|
444
|
+
_request = config.http_client.delete(
|
445
|
+
_query_url,
|
446
|
+
headers: _headers
|
447
|
+
)
|
448
|
+
OAuth2.apply(config, _request)
|
449
|
+
_response = execute_request(_request)
|
450
|
+
|
451
|
+
# Return appropriate response type.
|
452
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
453
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
454
|
+
ApiResponse.new(
|
455
|
+
_response, data: decoded, errors: _errors
|
456
|
+
)
|
457
|
+
end
|
458
|
+
|
459
|
+
# Retrieves a [custom attribute]($m/CustomAttribute) associated with a
|
460
|
+
# location.
|
461
|
+
# You can use the `with_definition` query parameter to also retrieve the
|
462
|
+
# custom attribute definition
|
463
|
+
# in the same call.
|
464
|
+
# To retrieve a custom attribute owned by another application, the
|
465
|
+
# `visibility` setting must be
|
466
|
+
# `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`.
|
467
|
+
# @param [String] location_id Required parameter: The ID of the target
|
468
|
+
# [location]($m/Location).
|
469
|
+
# @param [String] key Required parameter: The key of the custom attribute to
|
470
|
+
# retrieve. This key must match the `key` of a custom attribute definition
|
471
|
+
# in the Square seller account. If the requesting application is not the
|
472
|
+
# definition owner, you must use the qualified key.
|
473
|
+
# @param [TrueClass|FalseClass] with_definition Optional parameter:
|
474
|
+
# Indicates whether to return the [custom attribute
|
475
|
+
# definition]($m/CustomAttributeDefinition) in the `definition` field of the
|
476
|
+
# custom attribute. Set this parameter to `true` to get the name and
|
477
|
+
# description of the custom attribute, information about the data type, or
|
478
|
+
# other definition details. The default value is `false`.
|
479
|
+
# @param [Integer] version Optional parameter: The current version of the
|
480
|
+
# custom attribute, which is used for strongly consistent reads to guarantee
|
481
|
+
# that you receive the most up-to-date data. When included in the request,
|
482
|
+
# Square returns the specified version or a higher version if one exists. If
|
483
|
+
# the specified version is higher than the current version, Square returns a
|
484
|
+
# `BAD_REQUEST` error.
|
485
|
+
# @return [RetrieveLocationCustomAttributeResponse Hash] response from the API call
|
486
|
+
def retrieve_location_custom_attribute(location_id:,
|
487
|
+
key:,
|
488
|
+
with_definition: false,
|
489
|
+
version: nil)
|
490
|
+
# Prepare query url.
|
491
|
+
_query_builder = config.get_base_uri
|
492
|
+
_query_builder << '/v2/locations/{location_id}/custom-attributes/{key}'
|
493
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
494
|
+
_query_builder,
|
495
|
+
'location_id' => { 'value' => location_id, 'encode' => true },
|
496
|
+
'key' => { 'value' => key, 'encode' => true }
|
497
|
+
)
|
498
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
499
|
+
_query_builder,
|
500
|
+
'with_definition' => with_definition,
|
501
|
+
'version' => version
|
502
|
+
)
|
503
|
+
_query_url = APIHelper.clean_url _query_builder
|
504
|
+
|
505
|
+
# Prepare headers.
|
506
|
+
_headers = {
|
507
|
+
'accept' => 'application/json'
|
508
|
+
}
|
509
|
+
|
510
|
+
# Prepare and execute HttpRequest.
|
511
|
+
_request = config.http_client.get(
|
512
|
+
_query_url,
|
513
|
+
headers: _headers
|
514
|
+
)
|
515
|
+
OAuth2.apply(config, _request)
|
516
|
+
_response = execute_request(_request)
|
517
|
+
|
518
|
+
# Return appropriate response type.
|
519
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
520
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
521
|
+
ApiResponse.new(
|
522
|
+
_response, data: decoded, errors: _errors
|
523
|
+
)
|
524
|
+
end
|
525
|
+
|
526
|
+
# Creates or updates a [custom attribute]($m/CustomAttribute) for a
|
527
|
+
# location.
|
528
|
+
# Use this endpoint to set the value of a custom attribute for a specified
|
529
|
+
# location.
|
530
|
+
# A custom attribute is based on a custom attribute definition in a Square
|
531
|
+
# seller account, which
|
532
|
+
# is created using the
|
533
|
+
# [CreateLocationCustomAttributeDefinition]($e/LocationCustomAttributes/Crea
|
534
|
+
# teLocationCustomAttributeDefinition) endpoint.
|
535
|
+
# To create or update a custom attribute owned by another application, the
|
536
|
+
# `visibility` setting
|
537
|
+
# must be `VISIBILITY_READ_WRITE_VALUES`.
|
538
|
+
# @param [String] location_id Required parameter: The ID of the target
|
539
|
+
# [location]($m/Location).
|
540
|
+
# @param [String] key Required parameter: The key of the custom attribute to
|
541
|
+
# create or update. This key must match the `key` of a custom attribute
|
542
|
+
# definition in the Square seller account. If the requesting application is
|
543
|
+
# not the definition owner, you must use the qualified key.
|
544
|
+
# @param [UpsertLocationCustomAttributeRequest] body Required parameter: An
|
545
|
+
# object containing the fields to POST for the request. See the
|
546
|
+
# corresponding object definition for field details.
|
547
|
+
# @return [UpsertLocationCustomAttributeResponse Hash] response from the API call
|
548
|
+
def upsert_location_custom_attribute(location_id:,
|
549
|
+
key:,
|
550
|
+
body:)
|
551
|
+
# Prepare query url.
|
552
|
+
_query_builder = config.get_base_uri
|
553
|
+
_query_builder << '/v2/locations/{location_id}/custom-attributes/{key}'
|
554
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
555
|
+
_query_builder,
|
556
|
+
'location_id' => { 'value' => location_id, 'encode' => true },
|
557
|
+
'key' => { 'value' => key, 'encode' => true }
|
558
|
+
)
|
559
|
+
_query_url = APIHelper.clean_url _query_builder
|
560
|
+
|
561
|
+
# Prepare headers.
|
562
|
+
_headers = {
|
563
|
+
'accept' => 'application/json',
|
564
|
+
'Content-Type' => 'application/json'
|
565
|
+
}
|
566
|
+
|
567
|
+
# Prepare and execute HttpRequest.
|
568
|
+
_request = config.http_client.post(
|
569
|
+
_query_url,
|
570
|
+
headers: _headers,
|
571
|
+
parameters: body.to_json
|
572
|
+
)
|
573
|
+
OAuth2.apply(config, _request)
|
574
|
+
_response = execute_request(_request)
|
575
|
+
|
576
|
+
# Return appropriate response type.
|
577
|
+
decoded = APIHelper.json_deserialize(_response.raw_body)
|
578
|
+
_errors = APIHelper.map_response(decoded, ['errors'])
|
579
|
+
ApiResponse.new(
|
580
|
+
_response, data: decoded, errors: _errors
|
581
|
+
)
|
582
|
+
end
|
583
|
+
end
|
584
|
+
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
|
-
'26.
|
7
|
+
'26.1.0.20230119'
|
8
8
|
end
|
9
9
|
|
10
10
|
def square_version
|
@@ -153,6 +153,12 @@ module Square
|
|
153
153
|
@locations ||= LocationsApi.new config
|
154
154
|
end
|
155
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
|
+
|
156
162
|
# Access to checkout controller.
|
157
163
|
# @return [CheckoutApi] Returns the controller instance.
|
158
164
|
def checkout
|
@@ -254,7 +260,7 @@ module Square
|
|
254
260
|
retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
|
255
261
|
retry_methods: %i[get put], environment: 'production',
|
256
262
|
custom_url: 'https://connect.squareup.com',
|
257
|
-
square_version: '
|
263
|
+
square_version: '2023-01-19', access_token: '',
|
258
264
|
user_agent_detail: '', additional_headers: {}, config: nil)
|
259
265
|
@config = if config.nil?
|
260
266
|
Configuration.new(connection: connection, adapter: adapter,
|
data/lib/square/configuration.rb
CHANGED
@@ -20,7 +20,7 @@ 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: '
|
23
|
+
square_version: '2023-01-19', access_token: '',
|
24
24
|
user_agent_detail: '', additional_headers: {})
|
25
25
|
# The Faraday connection object passed by the SDK user for making requests
|
26
26
|
@connection = connection
|
data/lib/square.rb
CHANGED
@@ -54,6 +54,7 @@ require_relative 'square/api/inventory_api'
|
|
54
54
|
require_relative 'square/api/invoices_api'
|
55
55
|
require_relative 'square/api/labor_api'
|
56
56
|
require_relative 'square/api/locations_api'
|
57
|
+
require_relative 'square/api/location_custom_attributes_api'
|
57
58
|
require_relative 'square/api/checkout_api'
|
58
59
|
require_relative 'square/api/transactions_api'
|
59
60
|
require_relative 'square/api/loyalty_api'
|
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: 26.
|
4
|
+
version: 26.1.0.20230119
|
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:
|
11
|
+
date: 2023-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: logging
|
@@ -213,6 +213,7 @@ files:
|
|
213
213
|
- lib/square/api/inventory_api.rb
|
214
214
|
- lib/square/api/invoices_api.rb
|
215
215
|
- lib/square/api/labor_api.rb
|
216
|
+
- lib/square/api/location_custom_attributes_api.rb
|
216
217
|
- lib/square/api/locations_api.rb
|
217
218
|
- lib/square/api/loyalty_api.rb
|
218
219
|
- lib/square/api/merchants_api.rb
|