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
@@ -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
|
@@ -5,11 +5,9 @@ module Square
|
|
5
5
|
super(config, http_call_back: http_call_back)
|
6
6
|
end
|
7
7
|
|
8
|
-
# Provides
|
9
|
-
#
|
10
|
-
#
|
11
|
-
# this
|
12
|
-
# endpoint correspond to that `location_id` parameter.
|
8
|
+
# Provides details about all of the seller's
|
9
|
+
# [locations](https://developer.squareup.com/docs/locations-api),
|
10
|
+
# including those with an inactive status.
|
13
11
|
# @return [ListLocationsResponse Hash] response from the API call
|
14
12
|
def list_locations
|
15
13
|
# Prepare query url.
|
@@ -38,7 +36,16 @@ module Square
|
|
38
36
|
)
|
39
37
|
end
|
40
38
|
|
41
|
-
# Creates a location.
|
39
|
+
# Creates a [location](https://developer.squareup.com/docs/locations-api).
|
40
|
+
# Creating new locations allows for separate configuration of receipt
|
41
|
+
# layouts, item prices,
|
42
|
+
# and sales reports. Developers can use locations to separate sales activity
|
43
|
+
# through applications
|
44
|
+
# that integrate with Square from sales activity elsewhere in a seller's
|
45
|
+
# account.
|
46
|
+
# Locations created programmatically with the Locations API last forever and
|
47
|
+
# are visible to the seller for their own management. Therefore, ensure that
|
48
|
+
# each location has a sensible and unique name.
|
42
49
|
# @param [CreateLocationRequest] body Required parameter: An object
|
43
50
|
# containing the fields to POST for the request. See the corresponding
|
44
51
|
# object definition for field details.
|
@@ -52,7 +59,7 @@ module Square
|
|
52
59
|
# Prepare headers.
|
53
60
|
_headers = {
|
54
61
|
'accept' => 'application/json',
|
55
|
-
'
|
62
|
+
'Content-Type' => 'application/json'
|
56
63
|
}
|
57
64
|
|
58
65
|
# Prepare and execute HttpRequest.
|
@@ -72,12 +79,12 @@ module Square
|
|
72
79
|
)
|
73
80
|
end
|
74
81
|
|
75
|
-
# Retrieves details of a location.
|
76
|
-
# as the location ID to retrieve details of the
|
77
|
-
#
|
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).
|
78
86
|
# @param [String] location_id Required parameter: The ID of the location to
|
79
|
-
# retrieve.
|
80
|
-
# main location.
|
87
|
+
# retrieve. Specify the string "main" to return the main location.
|
81
88
|
# @return [RetrieveLocationResponse Hash] response from the API call
|
82
89
|
def retrieve_location(location_id:)
|
83
90
|
# Prepare query url.
|
@@ -110,7 +117,7 @@ module Square
|
|
110
117
|
)
|
111
118
|
end
|
112
119
|
|
113
|
-
# Updates a location.
|
120
|
+
# Updates a [location](https://developer.squareup.com/docs/locations-api).
|
114
121
|
# @param [String] location_id Required parameter: The ID of the location to
|
115
122
|
# update.
|
116
123
|
# @param [UpdateLocationRequest] body Required parameter: An object
|
@@ -131,7 +138,7 @@ module Square
|
|
131
138
|
# Prepare headers.
|
132
139
|
_headers = {
|
133
140
|
'accept' => 'application/json',
|
134
|
-
'
|
141
|
+
'Content-Type' => 'application/json'
|
135
142
|
}
|
136
143
|
|
137
144
|
# Prepare and execute HttpRequest.
|