square.rb 26.1.0.20230119 → 26.2.0.20230315
Sign up to get free protection for your applications and to get access to all the features.
- 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
|
# BookingCustomAttributesApi
|
3
3
|
class BookingCustomAttributesApi < BaseApi
|
4
|
-
def initialize(config, http_call_back: nil)
|
5
|
-
super(config, http_call_back: http_call_back)
|
6
|
-
end
|
7
|
-
|
8
4
|
# Get all bookings custom attribute definitions.
|
9
5
|
# To call this endpoint with buyer-level permissions, set
|
10
6
|
# `APPOINTMENTS_READ` for the OAuth scope.
|
@@ -25,35 +21,19 @@ module Square
|
|
25
21
|
# @return [ListBookingCustomAttributeDefinitionsResponse Hash] response from the API call
|
26
22
|
def list_booking_custom_attribute_definitions(limit: nil,
|
27
23
|
cursor: nil)
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
}
|
42
|
-
|
43
|
-
# Prepare and execute HttpRequest.
|
44
|
-
_request = config.http_client.get(
|
45
|
-
_query_url,
|
46
|
-
headers: _headers
|
47
|
-
)
|
48
|
-
OAuth2.apply(config, _request)
|
49
|
-
_response = execute_request(_request)
|
50
|
-
|
51
|
-
# Return appropriate response type.
|
52
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
53
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
54
|
-
ApiResponse.new(
|
55
|
-
_response, data: decoded, errors: _errors
|
56
|
-
)
|
24
|
+
new_api_call_builder
|
25
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
26
|
+
'/v2/bookings/custom-attribute-definitions',
|
27
|
+
'default')
|
28
|
+
.query_param(new_parameter(limit, key: 'limit'))
|
29
|
+
.query_param(new_parameter(cursor, key: 'cursor'))
|
30
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
31
|
+
.auth(Single.new('global')))
|
32
|
+
.response(new_response_handler
|
33
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
34
|
+
.is_api_response(true)
|
35
|
+
.convertor(ApiResponse.method(:create)))
|
36
|
+
.execute
|
57
37
|
end
|
58
38
|
|
59
39
|
# Creates a bookings custom attribute definition.
|
@@ -69,32 +49,20 @@ module Square
|
|
69
49
|
# the corresponding object definition for field details.
|
70
50
|
# @return [CreateBookingCustomAttributeDefinitionResponse Hash] response from the API call
|
71
51
|
def create_booking_custom_attribute_definition(body:)
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
headers: _headers,
|
87
|
-
parameters: body.to_json
|
88
|
-
)
|
89
|
-
OAuth2.apply(config, _request)
|
90
|
-
_response = execute_request(_request)
|
91
|
-
|
92
|
-
# Return appropriate response type.
|
93
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
94
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
95
|
-
ApiResponse.new(
|
96
|
-
_response, data: decoded, errors: _errors
|
97
|
-
)
|
52
|
+
new_api_call_builder
|
53
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
54
|
+
'/v2/bookings/custom-attribute-definitions',
|
55
|
+
'default')
|
56
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
57
|
+
.body_param(new_parameter(body))
|
58
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
59
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
60
|
+
.auth(Single.new('global')))
|
61
|
+
.response(new_response_handler
|
62
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
63
|
+
.is_api_response(true)
|
64
|
+
.convertor(ApiResponse.method(:create)))
|
65
|
+
.execute
|
98
66
|
end
|
99
67
|
|
100
68
|
# Deletes a bookings custom attribute definition.
|
@@ -109,34 +77,19 @@ module Square
|
|
109
77
|
# definition to delete.
|
110
78
|
# @return [DeleteBookingCustomAttributeDefinitionResponse Hash] response from the API call
|
111
79
|
def delete_booking_custom_attribute_definition(key:)
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
# Prepare and execute HttpRequest.
|
127
|
-
_request = config.http_client.delete(
|
128
|
-
_query_url,
|
129
|
-
headers: _headers
|
130
|
-
)
|
131
|
-
OAuth2.apply(config, _request)
|
132
|
-
_response = execute_request(_request)
|
133
|
-
|
134
|
-
# Return appropriate response type.
|
135
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
136
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
137
|
-
ApiResponse.new(
|
138
|
-
_response, data: decoded, errors: _errors
|
139
|
-
)
|
80
|
+
new_api_call_builder
|
81
|
+
.request(new_request_builder(HttpMethodEnum::DELETE,
|
82
|
+
'/v2/bookings/custom-attribute-definitions/{key}',
|
83
|
+
'default')
|
84
|
+
.template_param(new_parameter(key, key: 'key')
|
85
|
+
.should_encode(true))
|
86
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
87
|
+
.auth(Single.new('global')))
|
88
|
+
.response(new_response_handler
|
89
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
90
|
+
.is_api_response(true)
|
91
|
+
.convertor(ApiResponse.method(:create)))
|
92
|
+
.execute
|
140
93
|
end
|
141
94
|
|
142
95
|
# Retrieves a bookings custom attribute definition.
|
@@ -156,38 +109,20 @@ module Square
|
|
156
109
|
# @return [RetrieveBookingCustomAttributeDefinitionResponse Hash] response from the API call
|
157
110
|
def retrieve_booking_custom_attribute_definition(key:,
|
158
111
|
version: nil)
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
_headers = {
|
174
|
-
'accept' => 'application/json'
|
175
|
-
}
|
176
|
-
|
177
|
-
# Prepare and execute HttpRequest.
|
178
|
-
_request = config.http_client.get(
|
179
|
-
_query_url,
|
180
|
-
headers: _headers
|
181
|
-
)
|
182
|
-
OAuth2.apply(config, _request)
|
183
|
-
_response = execute_request(_request)
|
184
|
-
|
185
|
-
# Return appropriate response type.
|
186
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
187
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
188
|
-
ApiResponse.new(
|
189
|
-
_response, data: decoded, errors: _errors
|
190
|
-
)
|
112
|
+
new_api_call_builder
|
113
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
114
|
+
'/v2/bookings/custom-attribute-definitions/{key}',
|
115
|
+
'default')
|
116
|
+
.template_param(new_parameter(key, key: 'key')
|
117
|
+
.should_encode(true))
|
118
|
+
.query_param(new_parameter(version, key: 'version'))
|
119
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
120
|
+
.auth(Single.new('global')))
|
121
|
+
.response(new_response_handler
|
122
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
123
|
+
.is_api_response(true)
|
124
|
+
.convertor(ApiResponse.method(:create)))
|
125
|
+
.execute
|
191
126
|
end
|
192
127
|
|
193
128
|
# Updates a bookings custom attribute definition.
|
@@ -206,36 +141,22 @@ module Square
|
|
206
141
|
# @return [UpdateBookingCustomAttributeDefinitionResponse Hash] response from the API call
|
207
142
|
def update_booking_custom_attribute_definition(key:,
|
208
143
|
body:)
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
_request = config.http_client.put(
|
226
|
-
_query_url,
|
227
|
-
headers: _headers,
|
228
|
-
parameters: body.to_json
|
229
|
-
)
|
230
|
-
OAuth2.apply(config, _request)
|
231
|
-
_response = execute_request(_request)
|
232
|
-
|
233
|
-
# Return appropriate response type.
|
234
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
235
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
236
|
-
ApiResponse.new(
|
237
|
-
_response, data: decoded, errors: _errors
|
238
|
-
)
|
144
|
+
new_api_call_builder
|
145
|
+
.request(new_request_builder(HttpMethodEnum::PUT,
|
146
|
+
'/v2/bookings/custom-attribute-definitions/{key}',
|
147
|
+
'default')
|
148
|
+
.template_param(new_parameter(key, key: 'key')
|
149
|
+
.should_encode(true))
|
150
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
151
|
+
.body_param(new_parameter(body))
|
152
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
153
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
154
|
+
.auth(Single.new('global')))
|
155
|
+
.response(new_response_handler
|
156
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
157
|
+
.is_api_response(true)
|
158
|
+
.convertor(ApiResponse.method(:create)))
|
159
|
+
.execute
|
239
160
|
end
|
240
161
|
|
241
162
|
# Bulk deletes bookings custom attributes.
|
@@ -251,32 +172,20 @@ module Square
|
|
251
172
|
# corresponding object definition for field details.
|
252
173
|
# @return [BulkDeleteBookingCustomAttributesResponse Hash] response from the API call
|
253
174
|
def bulk_delete_booking_custom_attributes(body:)
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
headers: _headers,
|
269
|
-
parameters: body.to_json
|
270
|
-
)
|
271
|
-
OAuth2.apply(config, _request)
|
272
|
-
_response = execute_request(_request)
|
273
|
-
|
274
|
-
# Return appropriate response type.
|
275
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
276
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
277
|
-
ApiResponse.new(
|
278
|
-
_response, data: decoded, errors: _errors
|
279
|
-
)
|
175
|
+
new_api_call_builder
|
176
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
177
|
+
'/v2/bookings/custom-attributes/bulk-delete',
|
178
|
+
'default')
|
179
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
180
|
+
.body_param(new_parameter(body))
|
181
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
182
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
183
|
+
.auth(Single.new('global')))
|
184
|
+
.response(new_response_handler
|
185
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
186
|
+
.is_api_response(true)
|
187
|
+
.convertor(ApiResponse.method(:create)))
|
188
|
+
.execute
|
280
189
|
end
|
281
190
|
|
282
191
|
# Bulk upserts bookings custom attributes.
|
@@ -292,32 +201,20 @@ module Square
|
|
292
201
|
# corresponding object definition for field details.
|
293
202
|
# @return [BulkUpsertBookingCustomAttributesResponse Hash] response from the API call
|
294
203
|
def bulk_upsert_booking_custom_attributes(body:)
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
headers: _headers,
|
310
|
-
parameters: body.to_json
|
311
|
-
)
|
312
|
-
OAuth2.apply(config, _request)
|
313
|
-
_response = execute_request(_request)
|
314
|
-
|
315
|
-
# Return appropriate response type.
|
316
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
317
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
318
|
-
ApiResponse.new(
|
319
|
-
_response, data: decoded, errors: _errors
|
320
|
-
)
|
204
|
+
new_api_call_builder
|
205
|
+
.request(new_request_builder(HttpMethodEnum::POST,
|
206
|
+
'/v2/bookings/custom-attributes/bulk-upsert',
|
207
|
+
'default')
|
208
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
209
|
+
.body_param(new_parameter(body))
|
210
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
211
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
212
|
+
.auth(Single.new('global')))
|
213
|
+
.response(new_response_handler
|
214
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
215
|
+
.is_api_response(true)
|
216
|
+
.convertor(ApiResponse.method(:create)))
|
217
|
+
.execute
|
321
218
|
end
|
322
219
|
|
323
220
|
# Lists a booking's custom attributes.
|
@@ -350,40 +247,22 @@ module Square
|
|
350
247
|
limit: nil,
|
351
248
|
cursor: nil,
|
352
249
|
with_definitions: false)
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
_headers = {
|
370
|
-
'accept' => 'application/json'
|
371
|
-
}
|
372
|
-
|
373
|
-
# Prepare and execute HttpRequest.
|
374
|
-
_request = config.http_client.get(
|
375
|
-
_query_url,
|
376
|
-
headers: _headers
|
377
|
-
)
|
378
|
-
OAuth2.apply(config, _request)
|
379
|
-
_response = execute_request(_request)
|
380
|
-
|
381
|
-
# Return appropriate response type.
|
382
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
383
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
384
|
-
ApiResponse.new(
|
385
|
-
_response, data: decoded, errors: _errors
|
386
|
-
)
|
250
|
+
new_api_call_builder
|
251
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
252
|
+
'/v2/bookings/{booking_id}/custom-attributes',
|
253
|
+
'default')
|
254
|
+
.template_param(new_parameter(booking_id, key: 'booking_id')
|
255
|
+
.should_encode(true))
|
256
|
+
.query_param(new_parameter(limit, key: 'limit'))
|
257
|
+
.query_param(new_parameter(cursor, key: 'cursor'))
|
258
|
+
.query_param(new_parameter(with_definitions, key: 'with_definitions'))
|
259
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
260
|
+
.auth(Single.new('global')))
|
261
|
+
.response(new_response_handler
|
262
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
263
|
+
.is_api_response(true)
|
264
|
+
.convertor(ApiResponse.method(:create)))
|
265
|
+
.execute
|
387
266
|
end
|
388
267
|
|
389
268
|
# Deletes a bookings custom attribute.
|
@@ -403,35 +282,21 @@ module Square
|
|
403
282
|
# @return [DeleteBookingCustomAttributeResponse Hash] response from the API call
|
404
283
|
def delete_booking_custom_attribute(booking_id:,
|
405
284
|
key:)
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
|
416
|
-
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
# Prepare and execute HttpRequest.
|
422
|
-
_request = config.http_client.delete(
|
423
|
-
_query_url,
|
424
|
-
headers: _headers
|
425
|
-
)
|
426
|
-
OAuth2.apply(config, _request)
|
427
|
-
_response = execute_request(_request)
|
428
|
-
|
429
|
-
# Return appropriate response type.
|
430
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
431
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
432
|
-
ApiResponse.new(
|
433
|
-
_response, data: decoded, errors: _errors
|
434
|
-
)
|
285
|
+
new_api_call_builder
|
286
|
+
.request(new_request_builder(HttpMethodEnum::DELETE,
|
287
|
+
'/v2/bookings/{booking_id}/custom-attributes/{key}',
|
288
|
+
'default')
|
289
|
+
.template_param(new_parameter(booking_id, key: 'booking_id')
|
290
|
+
.should_encode(true))
|
291
|
+
.template_param(new_parameter(key, key: 'key')
|
292
|
+
.should_encode(true))
|
293
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
294
|
+
.auth(Single.new('global')))
|
295
|
+
.response(new_response_handler
|
296
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
297
|
+
.is_api_response(true)
|
298
|
+
.convertor(ApiResponse.method(:create)))
|
299
|
+
.execute
|
435
300
|
end
|
436
301
|
|
437
302
|
# Retrieves a bookings custom attribute.
|
@@ -462,40 +327,23 @@ module Square
|
|
462
327
|
key:,
|
463
328
|
with_definition: false,
|
464
329
|
version: nil)
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
-
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
'accept' => 'application/json'
|
483
|
-
}
|
484
|
-
|
485
|
-
# Prepare and execute HttpRequest.
|
486
|
-
_request = config.http_client.get(
|
487
|
-
_query_url,
|
488
|
-
headers: _headers
|
489
|
-
)
|
490
|
-
OAuth2.apply(config, _request)
|
491
|
-
_response = execute_request(_request)
|
492
|
-
|
493
|
-
# Return appropriate response type.
|
494
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
495
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
496
|
-
ApiResponse.new(
|
497
|
-
_response, data: decoded, errors: _errors
|
498
|
-
)
|
330
|
+
new_api_call_builder
|
331
|
+
.request(new_request_builder(HttpMethodEnum::GET,
|
332
|
+
'/v2/bookings/{booking_id}/custom-attributes/{key}',
|
333
|
+
'default')
|
334
|
+
.template_param(new_parameter(booking_id, key: 'booking_id')
|
335
|
+
.should_encode(true))
|
336
|
+
.template_param(new_parameter(key, key: 'key')
|
337
|
+
.should_encode(true))
|
338
|
+
.query_param(new_parameter(with_definition, key: 'with_definition'))
|
339
|
+
.query_param(new_parameter(version, key: 'version'))
|
340
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
341
|
+
.auth(Single.new('global')))
|
342
|
+
.response(new_response_handler
|
343
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
344
|
+
.is_api_response(true)
|
345
|
+
.convertor(ApiResponse.method(:create)))
|
346
|
+
.execute
|
499
347
|
end
|
500
348
|
|
501
349
|
# Upserts a bookings custom attribute.
|
@@ -519,37 +367,24 @@ module Square
|
|
519
367
|
def upsert_booking_custom_attribute(booking_id:,
|
520
368
|
key:,
|
521
369
|
body:)
|
522
|
-
|
523
|
-
|
524
|
-
|
525
|
-
|
526
|
-
|
527
|
-
|
528
|
-
|
529
|
-
|
530
|
-
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
_query_url,
|
541
|
-
headers: _headers,
|
542
|
-
parameters: body.to_json
|
543
|
-
)
|
544
|
-
OAuth2.apply(config, _request)
|
545
|
-
_response = execute_request(_request)
|
546
|
-
|
547
|
-
# Return appropriate response type.
|
548
|
-
decoded = APIHelper.json_deserialize(_response.raw_body)
|
549
|
-
_errors = APIHelper.map_response(decoded, ['errors'])
|
550
|
-
ApiResponse.new(
|
551
|
-
_response, data: decoded, errors: _errors
|
552
|
-
)
|
370
|
+
new_api_call_builder
|
371
|
+
.request(new_request_builder(HttpMethodEnum::PUT,
|
372
|
+
'/v2/bookings/{booking_id}/custom-attributes/{key}',
|
373
|
+
'default')
|
374
|
+
.template_param(new_parameter(booking_id, key: 'booking_id')
|
375
|
+
.should_encode(true))
|
376
|
+
.template_param(new_parameter(key, key: 'key')
|
377
|
+
.should_encode(true))
|
378
|
+
.header_param(new_parameter('application/json', key: 'Content-Type'))
|
379
|
+
.body_param(new_parameter(body))
|
380
|
+
.header_param(new_parameter('application/json', key: 'accept'))
|
381
|
+
.body_serializer(proc do |param| param.to_json unless param.nil? end)
|
382
|
+
.auth(Single.new('global')))
|
383
|
+
.response(new_response_handler
|
384
|
+
.deserializer(APIHelper.method(:json_deserialize))
|
385
|
+
.is_api_response(true)
|
386
|
+
.convertor(ApiResponse.method(:create)))
|
387
|
+
.execute
|
553
388
|
end
|
554
389
|
end
|
555
390
|
end
|