square.rb 26.1.0.20230119 → 26.2.0.20230315
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/apple_pay_api.rb +14 -30
- data/lib/square/api/bank_accounts_api.rb +40 -90
- data/lib/square/api/base_api.rb +42 -42
- data/lib/square/api/booking_custom_attributes_api.rb +164 -329
- data/lib/square/api/bookings_api.rb +135 -260
- data/lib/square/api/cards_api.rb +56 -118
- data/lib/square/api/cash_drawers_api.rb +47 -103
- data/lib/square/api/catalog_api.rb +197 -423
- data/lib/square/api/checkout_api.rb +85 -175
- data/lib/square/api/customer_custom_attributes_api.rb +150 -303
- data/lib/square/api/customer_groups_api.rb +69 -145
- data/lib/square/api/customer_segments_api.rb +26 -61
- data/lib/square/api/customers_api.rb +147 -294
- data/lib/square/api/devices_api.rb +42 -89
- data/lib/square/api/disputes_api.rb +130 -288
- data/lib/square/api/employees_api.rb +28 -63
- data/lib/square/api/gift_card_activities_api.rb +33 -65
- data/lib/square/api/gift_cards_api.rb +103 -202
- data/lib/square/api/inventory_api.rb +179 -366
- data/lib/square/api/invoices_api.rb +118 -237
- data/lib/square/api/labor_api.rb +223 -459
- data/lib/square/api/location_custom_attributes_api.rb +166 -331
- data/lib/square/api/locations_api.rb +54 -112
- data/lib/square/api/loyalty_api.rb +259 -512
- data/lib/square/api/merchants_api.rb +25 -60
- data/lib/square/api/mobile_authorization_api.rb +14 -30
- data/lib/square/api/o_auth_api.rb +54 -109
- data/lib/square/api/order_custom_attributes_api.rb +168 -333
- data/lib/square/api/orders_api.rb +115 -222
- data/lib/square/api/payments_api.rb +106 -208
- data/lib/square/api/payouts_api.rb +47 -100
- data/lib/square/api/refunds_api.rb +46 -93
- data/lib/square/api/sites_api.rb +11 -28
- data/lib/square/api/snippets_api.rb +42 -90
- data/lib/square/api/subscriptions_api.rb +150 -299
- data/lib/square/api/team_api.rb +114 -224
- data/lib/square/api/terminal_api.rb +162 -328
- data/lib/square/api/transactions_api.rb +62 -126
- data/lib/square/api/v1_transactions_api.rb +155 -296
- data/lib/square/api/vendors_api.rb +99 -192
- data/lib/square/api/webhook_subscriptions_api.rb +115 -235
- data/lib/square/api_helper.rb +1 -437
- data/lib/square/client.rb +77 -47
- data/lib/square/configuration.rb +28 -53
- data/lib/square/exceptions/api_exception.rb +1 -11
- data/lib/square/http/api_response.rb +13 -19
- data/lib/square/http/auth/o_auth2.rb +14 -7
- data/lib/square/http/http_call_back.rb +1 -15
- data/lib/square/http/http_method_enum.rb +1 -4
- data/lib/square/http/http_request.rb +1 -45
- data/lib/square/http/http_response.rb +1 -20
- data/lib/square/utilities/date_time_helper.rb +1 -146
- data/lib/square/utilities/file_wrapper.rb +5 -5
- data/lib/square.rb +6 -6
- data/spec/user_journey_spec.rb +2 -2
- data/test/api/api_test_base.rb +13 -5
- data/test/api/test_catalog_api.rb +5 -4
- data/test/api/test_customers_api.rb +3 -2
- data/test/api/test_employees_api.rb +4 -3
- data/test/api/test_labor_api.rb +6 -5
- data/test/api/test_locations_api.rb +3 -2
- data/test/api/test_merchants_api.rb +4 -3
- data/test/api/test_payments_api.rb +4 -3
- data/test/api/test_refunds_api.rb +4 -3
- metadata +11 -111
- data/lib/square/exceptions/validation_exception.rb +0 -13
- data/lib/square/http/faraday_client.rb +0 -93
- data/lib/square/http/http_client.rb +0 -118
- data/test/test_helper.rb +0 -89
@@ -1,10 +1,6 @@
|
|
1
1
|
module Square
|
2
2
|
# LocationCustomAttributesApi
|
3
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
4
|
# Lists the location-related [custom attribute
|
9
5
|
# definitions]($m/CustomAttributeDefinition) that belong to a Square seller
|
10
6
|
# account.
|
@@ -32,36 +28,20 @@ module Square
|
|
32
28
|
def list_location_custom_attribute_definitions(visibility_filter: nil,
|
33
29
|
limit: nil,
|
34
30
|
cursor: nil)
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
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
|
-
)
|
31
|
+
new_api_call_builder
|
32
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
33
|
+
'/v2/locations/custom-attribute-definitions',
|
34
|
+
'default')
|
35
|
+
.query_param(new_parameter(visibility_filter, key: 'visibility_filter'))
|
36
|
+
.query_param(new_parameter(limit, key: 'limit'))
|
37
|
+
.query_param(new_parameter(cursor, key: 'cursor'))
|
38
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
39
|
+
.auth(Single.new('global')))
|
40
|
+
.response(new_response_handler
|
41
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
42
|
+
.is_api_response(true)
|
43
|
+
.convertor(ApiResponse.method(:create)))
|
44
|
+
.execute
|
65
45
|
end
|
66
46
|
|
67
47
|
# Creates a location-related [custom attribute
|
@@ -81,32 +61,20 @@ module Square
|
|
81
61
|
# the corresponding object definition for field details.
|
82
62
|
# @return [CreateLocationCustomAttributeDefinitionResponse Hash] response from the API call
|
83
63
|
def create_location_custom_attribute_definition(body:)
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
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
|
-
)
|
64
|
+
new_api_call_builder
|
65
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
66
|
+
'/v2/locations/custom-attribute-definitions',
|
67
|
+
'default')
|
68
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
69
|
+
.body_param(new_parameter(body))
|
70
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
71
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
72
|
+
.auth(Single.new('global')))
|
73
|
+
.response(new_response_handler
|
74
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
75
|
+
.is_api_response(true)
|
76
|
+
.convertor(ApiResponse.method(:create)))
|
77
|
+
.execute
|
110
78
|
end
|
111
79
|
|
112
80
|
# Deletes a location-related [custom attribute
|
@@ -119,34 +87,19 @@ module Square
|
|
119
87
|
# definition to delete.
|
120
88
|
# @return [DeleteLocationCustomAttributeDefinitionResponse Hash] response from the API call
|
121
89
|
def delete_location_custom_attribute_definition(key:)
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
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
|
-
)
|
90
|
+
new_api_call_builder
|
91
|
+
.request(new_request_builder(HttpMethodEnum::DELETE,
|
92
|
+
'/v2/locations/custom-attribute-definitions/{key}',
|
93
|
+
'default')
|
94
|
+
.template_param(new_parameter(key, key: 'key')
|
95
|
+
.should_encode(true))
|
96
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
97
|
+
.auth(Single.new('global')))
|
98
|
+
.response(new_response_handler
|
99
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
100
|
+
.is_api_response(true)
|
101
|
+
.convertor(ApiResponse.method(:create)))
|
102
|
+
.execute
|
150
103
|
end
|
151
104
|
|
152
105
|
# Retrieves a location-related [custom attribute
|
@@ -166,38 +119,20 @@ module Square
|
|
166
119
|
# @return [RetrieveLocationCustomAttributeDefinitionResponse Hash] response from the API call
|
167
120
|
def retrieve_location_custom_attribute_definition(key:,
|
168
121
|
version: nil)
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
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
|
-
)
|
122
|
+
new_api_call_builder
|
123
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
124
|
+
'/v2/locations/custom-attribute-definitions/{key}',
|
125
|
+
'default')
|
126
|
+
.template_param(new_parameter(key, key: 'key')
|
127
|
+
.should_encode(true))
|
128
|
+
.query_param(new_parameter(version, key: 'version'))
|
129
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
130
|
+
.auth(Single.new('global')))
|
131
|
+
.response(new_response_handler
|
132
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
133
|
+
.is_api_response(true)
|
134
|
+
.convertor(ApiResponse.method(:create)))
|
135
|
+
.execute
|
201
136
|
end
|
202
137
|
|
203
138
|
# Updates a location-related [custom attribute
|
@@ -214,36 +149,22 @@ module Square
|
|
214
149
|
# @return [UpdateLocationCustomAttributeDefinitionResponse Hash] response from the API call
|
215
150
|
def update_location_custom_attribute_definition(key:,
|
216
151
|
body:)
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
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
|
-
)
|
152
|
+
new_api_call_builder
|
153
|
+
.request(new_request_builder(HttpMethodEnum::PUT,
|
154
|
+
'/v2/locations/custom-attribute-definitions/{key}',
|
155
|
+
'default')
|
156
|
+
.template_param(new_parameter(key, key: 'key')
|
157
|
+
.should_encode(true))
|
158
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
159
|
+
.body_param(new_parameter(body))
|
160
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
161
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
162
|
+
.auth(Single.new('global')))
|
163
|
+
.response(new_response_handler
|
164
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
165
|
+
.is_api_response(true)
|
166
|
+
.convertor(ApiResponse.method(:create)))
|
167
|
+
.execute
|
247
168
|
end
|
248
169
|
|
249
170
|
# Deletes [custom attributes]($m/CustomAttribute) for locations as a bulk
|
@@ -256,32 +177,20 @@ module Square
|
|
256
177
|
# the corresponding object definition for field details.
|
257
178
|
# @return [BulkDeleteLocationCustomAttributesResponse Hash] response from the API call
|
258
179
|
def bulk_delete_location_custom_attributes(body:)
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
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
|
-
)
|
180
|
+
new_api_call_builder
|
181
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
182
|
+
'/v2/locations/custom-attributes/bulk-delete',
|
183
|
+
'default')
|
184
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
185
|
+
.body_param(new_parameter(body))
|
186
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
187
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
188
|
+
.auth(Single.new('global')))
|
189
|
+
.response(new_response_handler
|
190
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
191
|
+
.is_api_response(true)
|
192
|
+
.convertor(ApiResponse.method(:create)))
|
193
|
+
.execute
|
285
194
|
end
|
286
195
|
|
287
196
|
# Creates or updates [custom attributes]($m/CustomAttribute) for locations
|
@@ -308,32 +217,20 @@ module Square
|
|
308
217
|
# the corresponding object definition for field details.
|
309
218
|
# @return [BulkUpsertLocationCustomAttributesResponse Hash] response from the API call
|
310
219
|
def bulk_upsert_location_custom_attributes(body:)
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
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
|
-
)
|
220
|
+
new_api_call_builder
|
221
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
222
|
+
'/v2/locations/custom-attributes/bulk-upsert',
|
223
|
+
'default')
|
224
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
225
|
+
.body_param(new_parameter(body))
|
226
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
227
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
228
|
+
.auth(Single.new('global')))
|
229
|
+
.response(new_response_handler
|
230
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
231
|
+
.is_api_response(true)
|
232
|
+
.convertor(ApiResponse.method(:create)))
|
233
|
+
.execute
|
337
234
|
end
|
338
235
|
|
339
236
|
# Lists the [custom attributes]($m/CustomAttribute) associated with a
|
@@ -374,41 +271,23 @@ module Square
|
|
374
271
|
limit: nil,
|
375
272
|
cursor: nil,
|
376
273
|
with_definitions: false)
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
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
|
-
)
|
274
|
+
new_api_call_builder
|
275
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
276
|
+
'/v2/locations/{location_id}/custom-attributes',
|
277
|
+
'default')
|
278
|
+
.template_param(new_parameter(location_id, key: 'location_id')
|
279
|
+
.should_encode(true))
|
280
|
+
.query_param(new_parameter(visibility_filter, key: 'visibility_filter'))
|
281
|
+
.query_param(new_parameter(limit, key: 'limit'))
|
282
|
+
.query_param(new_parameter(cursor, key: 'cursor'))
|
283
|
+
.query_param(new_parameter(with_definitions, key: 'with_definitions'))
|
284
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
285
|
+
.auth(Single.new('global')))
|
286
|
+
.response(new_response_handler
|
287
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
288
|
+
.is_api_response(true)
|
289
|
+
.convertor(ApiResponse.method(:create)))
|
290
|
+
.execute
|
412
291
|
end
|
413
292
|
|
414
293
|
# Deletes a [custom attribute]($m/CustomAttribute) associated with a
|
@@ -425,35 +304,21 @@ module Square
|
|
425
304
|
# @return [DeleteLocationCustomAttributeResponse Hash] response from the API call
|
426
305
|
def delete_location_custom_attribute(location_id:,
|
427
306
|
key:)
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
|
438
|
-
|
439
|
-
|
440
|
-
|
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
|
-
)
|
307
|
+
new_api_call_builder
|
308
|
+
.request(new_request_builder(HttpMethodEnum::DELETE,
|
309
|
+
'/v2/locations/{location_id}/custom-attributes/{key}',
|
310
|
+
'default')
|
311
|
+
.template_param(new_parameter(location_id, key: 'location_id')
|
312
|
+
.should_encode(true))
|
313
|
+
.template_param(new_parameter(key, key: 'key')
|
314
|
+
.should_encode(true))
|
315
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
316
|
+
.auth(Single.new('global')))
|
317
|
+
.response(new_response_handler
|
318
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
319
|
+
.is_api_response(true)
|
320
|
+
.convertor(ApiResponse.method(:create)))
|
321
|
+
.execute
|
457
322
|
end
|
458
323
|
|
459
324
|
# Retrieves a [custom attribute]($m/CustomAttribute) associated with a
|
@@ -487,40 +352,23 @@ module Square
|
|
487
352
|
key:,
|
488
353
|
with_definition: false,
|
489
354
|
version: nil)
|
490
|
-
|
491
|
-
|
492
|
-
|
493
|
-
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
|
498
|
-
|
499
|
-
|
500
|
-
|
501
|
-
|
502
|
-
|
503
|
-
|
504
|
-
|
505
|
-
|
506
|
-
|
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
|
-
)
|
355
|
+
new_api_call_builder
|
356
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
357
|
+
'/v2/locations/{location_id}/custom-attributes/{key}',
|
358
|
+
'default')
|
359
|
+
.template_param(new_parameter(location_id, key: 'location_id')
|
360
|
+
.should_encode(true))
|
361
|
+
.template_param(new_parameter(key, key: 'key')
|
362
|
+
.should_encode(true))
|
363
|
+
.query_param(new_parameter(with_definition, key: 'with_definition'))
|
364
|
+
.query_param(new_parameter(version, key: 'version'))
|
365
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
366
|
+
.auth(Single.new('global')))
|
367
|
+
.response(new_response_handler
|
368
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
369
|
+
.is_api_response(true)
|
370
|
+
.convertor(ApiResponse.method(:create)))
|
371
|
+
.execute
|
524
372
|
end
|
525
373
|
|
526
374
|
# Creates or updates a [custom attribute]($m/CustomAttribute) for a
|
@@ -548,37 +396,24 @@ module Square
|
|
548
396
|
def upsert_location_custom_attribute(location_id:,
|
549
397
|
key:,
|
550
398
|
body:)
|
551
|
-
|
552
|
-
|
553
|
-
|
554
|
-
|
555
|
-
|
556
|
-
|
557
|
-
|
558
|
-
|
559
|
-
|
560
|
-
|
561
|
-
|
562
|
-
|
563
|
-
|
564
|
-
|
565
|
-
|
566
|
-
|
567
|
-
|
568
|
-
|
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
|
-
)
|
399
|
+
new_api_call_builder
|
400
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
401
|
+
'/v2/locations/{location_id}/custom-attributes/{key}',
|
402
|
+
'default')
|
403
|
+
.template_param(new_parameter(location_id, key: 'location_id')
|
404
|
+
.should_encode(true))
|
405
|
+
.template_param(new_parameter(key, key: 'key')
|
406
|
+
.should_encode(true))
|
407
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
408
|
+
.body_param(new_parameter(body))
|
409
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
410
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
411
|
+
.auth(Single.new('global')))
|
412
|
+
.response(new_response_handler
|
413
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
414
|
+
.is_api_response(true)
|
415
|
+
.convertor(ApiResponse.method(:create)))
|
416
|
+
.execute
|
582
417
|
end
|
583
418
|
end
|
584
419
|
end
|