square.rb 8.0.0.20201216 → 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/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,555 @@
|
|
1
|
+
module Square
|
2
|
+
# BookingCustomAttributesApi
|
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
|
+
# Get all bookings custom attribute definitions.
|
9
|
+
# To call this endpoint with buyer-level permissions, set
|
10
|
+
# `APPOINTMENTS_READ` for the OAuth scope.
|
11
|
+
# To call this endpoint with seller-level permissions, set
|
12
|
+
# `APPOINTMENTS_ALL_READ` and `APPOINTMENTS_READ` for the OAuth scope.
|
13
|
+
# @param [Integer] limit Optional parameter: The maximum number of results
|
14
|
+
# to return in a single paged response. This limit is advisory. The response
|
15
|
+
# might contain more or fewer results. The minimum value is 1 and the
|
16
|
+
# maximum value is 100. The default value is 20. For more information, see
|
17
|
+
# [Pagination](https://developer.squareup.com/docs/build-basics/common-api-p
|
18
|
+
# atterns/pagination).
|
19
|
+
# @param [String] cursor Optional parameter: The cursor returned in the
|
20
|
+
# paged response from the previous call to this endpoint. Provide this
|
21
|
+
# cursor to retrieve the next page of results for your original request. For
|
22
|
+
# more information, see
|
23
|
+
# [Pagination](https://developer.squareup.com/docs/build-basics/common-api-p
|
24
|
+
# atterns/pagination).
|
25
|
+
# @return [ListBookingCustomAttributeDefinitionsResponse Hash] response from the API call
|
26
|
+
def list_booking_custom_attribute_definitions(limit: nil,
|
27
|
+
cursor: nil)
|
28
|
+
# Prepare query url.
|
29
|
+
_query_builder = config.get_base_uri
|
30
|
+
_query_builder << '/v2/bookings/custom-attribute-definitions'
|
31
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
32
|
+
_query_builder,
|
33
|
+
'limit' => limit,
|
34
|
+
'cursor' => cursor
|
35
|
+
)
|
36
|
+
_query_url = APIHelper.clean_url _query_builder
|
37
|
+
|
38
|
+
# Prepare headers.
|
39
|
+
_headers = {
|
40
|
+
'accept' => 'application/json'
|
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
|
+
)
|
57
|
+
end
|
58
|
+
|
59
|
+
# Creates a bookings custom attribute definition.
|
60
|
+
# To call this endpoint with buyer-level permissions, set
|
61
|
+
# `APPOINTMENTS_WRITE` for the OAuth scope.
|
62
|
+
# To call this endpoint with seller-level permissions, set
|
63
|
+
# `APPOINTMENTS_ALL_WRITE` and `APPOINTMENTS_WRITE` for the OAuth scope.
|
64
|
+
# For calls to this endpoint with seller-level permissions to succeed, the
|
65
|
+
# seller must have subscribed to *Appointments Plus*
|
66
|
+
# or *Appointments Premium*.
|
67
|
+
# @param [CreateBookingCustomAttributeDefinitionRequest] body Required
|
68
|
+
# parameter: An object containing the fields to POST for the request. See
|
69
|
+
# the corresponding object definition for field details.
|
70
|
+
# @return [CreateBookingCustomAttributeDefinitionResponse Hash] response from the API call
|
71
|
+
def create_booking_custom_attribute_definition(body:)
|
72
|
+
# Prepare query url.
|
73
|
+
_query_builder = config.get_base_uri
|
74
|
+
_query_builder << '/v2/bookings/custom-attribute-definitions'
|
75
|
+
_query_url = APIHelper.clean_url _query_builder
|
76
|
+
|
77
|
+
# Prepare headers.
|
78
|
+
_headers = {
|
79
|
+
'accept' => 'application/json',
|
80
|
+
'Content-Type' => 'application/json'
|
81
|
+
}
|
82
|
+
|
83
|
+
# Prepare and execute HttpRequest.
|
84
|
+
_request = config.http_client.post(
|
85
|
+
_query_url,
|
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
|
+
)
|
98
|
+
end
|
99
|
+
|
100
|
+
# Deletes a bookings custom attribute definition.
|
101
|
+
# To call this endpoint with buyer-level permissions, set
|
102
|
+
# `APPOINTMENTS_WRITE` for the OAuth scope.
|
103
|
+
# To call this endpoint with seller-level permissions, set
|
104
|
+
# `APPOINTMENTS_ALL_WRITE` and `APPOINTMENTS_WRITE` for the OAuth scope.
|
105
|
+
# For calls to this endpoint with seller-level permissions to succeed, the
|
106
|
+
# seller must have subscribed to *Appointments Plus*
|
107
|
+
# or *Appointments Premium*.
|
108
|
+
# @param [String] key Required parameter: The key of the custom attribute
|
109
|
+
# definition to delete.
|
110
|
+
# @return [DeleteBookingCustomAttributeDefinitionResponse Hash] response from the API call
|
111
|
+
def delete_booking_custom_attribute_definition(key:)
|
112
|
+
# Prepare query url.
|
113
|
+
_query_builder = config.get_base_uri
|
114
|
+
_query_builder << '/v2/bookings/custom-attribute-definitions/{key}'
|
115
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
116
|
+
_query_builder,
|
117
|
+
'key' => { 'value' => key, 'encode' => true }
|
118
|
+
)
|
119
|
+
_query_url = APIHelper.clean_url _query_builder
|
120
|
+
|
121
|
+
# Prepare headers.
|
122
|
+
_headers = {
|
123
|
+
'accept' => 'application/json'
|
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
|
+
)
|
140
|
+
end
|
141
|
+
|
142
|
+
# Retrieves a bookings custom attribute definition.
|
143
|
+
# To call this endpoint with buyer-level permissions, set
|
144
|
+
# `APPOINTMENTS_READ` for the OAuth scope.
|
145
|
+
# To call this endpoint with seller-level permissions, set
|
146
|
+
# `APPOINTMENTS_ALL_READ` and `APPOINTMENTS_READ` for the OAuth scope.
|
147
|
+
# @param [String] key Required parameter: The key of the custom attribute
|
148
|
+
# definition to retrieve. If the requesting application is not the
|
149
|
+
# definition owner, you must use the qualified key.
|
150
|
+
# @param [Integer] version Optional parameter: The current version of the
|
151
|
+
# custom attribute definition, which is used for strongly consistent reads
|
152
|
+
# to guarantee that you receive the most up-to-date data. When included in
|
153
|
+
# the request, Square returns the specified version or a higher version if
|
154
|
+
# one exists. If the specified version is higher than the current version,
|
155
|
+
# Square returns a `BAD_REQUEST` error.
|
156
|
+
# @return [RetrieveBookingCustomAttributeDefinitionResponse Hash] response from the API call
|
157
|
+
def retrieve_booking_custom_attribute_definition(key:,
|
158
|
+
version: nil)
|
159
|
+
# Prepare query url.
|
160
|
+
_query_builder = config.get_base_uri
|
161
|
+
_query_builder << '/v2/bookings/custom-attribute-definitions/{key}'
|
162
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
163
|
+
_query_builder,
|
164
|
+
'key' => { 'value' => key, 'encode' => true }
|
165
|
+
)
|
166
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
167
|
+
_query_builder,
|
168
|
+
'version' => version
|
169
|
+
)
|
170
|
+
_query_url = APIHelper.clean_url _query_builder
|
171
|
+
|
172
|
+
# Prepare headers.
|
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
|
+
)
|
191
|
+
end
|
192
|
+
|
193
|
+
# Updates a bookings custom attribute definition.
|
194
|
+
# To call this endpoint with buyer-level permissions, set
|
195
|
+
# `APPOINTMENTS_WRITE` for the OAuth scope.
|
196
|
+
# To call this endpoint with seller-level permissions, set
|
197
|
+
# `APPOINTMENTS_ALL_WRITE` and `APPOINTMENTS_WRITE` for the OAuth scope.
|
198
|
+
# For calls to this endpoint with seller-level permissions to succeed, the
|
199
|
+
# seller must have subscribed to *Appointments Plus*
|
200
|
+
# or *Appointments Premium*.
|
201
|
+
# @param [String] key Required parameter: The key of the custom attribute
|
202
|
+
# definition to update.
|
203
|
+
# @param [UpdateBookingCustomAttributeDefinitionRequest] body Required
|
204
|
+
# parameter: An object containing the fields to POST for the request. See
|
205
|
+
# the corresponding object definition for field details.
|
206
|
+
# @return [UpdateBookingCustomAttributeDefinitionResponse Hash] response from the API call
|
207
|
+
def update_booking_custom_attribute_definition(key:,
|
208
|
+
body:)
|
209
|
+
# Prepare query url.
|
210
|
+
_query_builder = config.get_base_uri
|
211
|
+
_query_builder << '/v2/bookings/custom-attribute-definitions/{key}'
|
212
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
213
|
+
_query_builder,
|
214
|
+
'key' => { 'value' => key, 'encode' => true }
|
215
|
+
)
|
216
|
+
_query_url = APIHelper.clean_url _query_builder
|
217
|
+
|
218
|
+
# Prepare headers.
|
219
|
+
_headers = {
|
220
|
+
'accept' => 'application/json',
|
221
|
+
'Content-Type' => 'application/json'
|
222
|
+
}
|
223
|
+
|
224
|
+
# Prepare and execute HttpRequest.
|
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
|
+
)
|
239
|
+
end
|
240
|
+
|
241
|
+
# Bulk deletes bookings custom attributes.
|
242
|
+
# To call this endpoint with buyer-level permissions, set
|
243
|
+
# `APPOINTMENTS_WRITE` for the OAuth scope.
|
244
|
+
# To call this endpoint with seller-level permissions, set
|
245
|
+
# `APPOINTMENTS_ALL_WRITE` and `APPOINTMENTS_WRITE` for the OAuth scope.
|
246
|
+
# For calls to this endpoint with seller-level permissions to succeed, the
|
247
|
+
# seller must have subscribed to *Appointments Plus*
|
248
|
+
# or *Appointments Premium*.
|
249
|
+
# @param [BulkDeleteBookingCustomAttributesRequest] body Required parameter:
|
250
|
+
# An object containing the fields to POST for the request. See the
|
251
|
+
# corresponding object definition for field details.
|
252
|
+
# @return [BulkDeleteBookingCustomAttributesResponse Hash] response from the API call
|
253
|
+
def bulk_delete_booking_custom_attributes(body:)
|
254
|
+
# Prepare query url.
|
255
|
+
_query_builder = config.get_base_uri
|
256
|
+
_query_builder << '/v2/bookings/custom-attributes/bulk-delete'
|
257
|
+
_query_url = APIHelper.clean_url _query_builder
|
258
|
+
|
259
|
+
# Prepare headers.
|
260
|
+
_headers = {
|
261
|
+
'accept' => 'application/json',
|
262
|
+
'Content-Type' => 'application/json'
|
263
|
+
}
|
264
|
+
|
265
|
+
# Prepare and execute HttpRequest.
|
266
|
+
_request = config.http_client.post(
|
267
|
+
_query_url,
|
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
|
+
)
|
280
|
+
end
|
281
|
+
|
282
|
+
# Bulk upserts bookings custom attributes.
|
283
|
+
# To call this endpoint with buyer-level permissions, set
|
284
|
+
# `APPOINTMENTS_WRITE` for the OAuth scope.
|
285
|
+
# To call this endpoint with seller-level permissions, set
|
286
|
+
# `APPOINTMENTS_ALL_WRITE` and `APPOINTMENTS_WRITE` for the OAuth scope.
|
287
|
+
# For calls to this endpoint with seller-level permissions to succeed, the
|
288
|
+
# seller must have subscribed to *Appointments Plus*
|
289
|
+
# or *Appointments Premium*.
|
290
|
+
# @param [BulkUpsertBookingCustomAttributesRequest] body Required parameter:
|
291
|
+
# An object containing the fields to POST for the request. See the
|
292
|
+
# corresponding object definition for field details.
|
293
|
+
# @return [BulkUpsertBookingCustomAttributesResponse Hash] response from the API call
|
294
|
+
def bulk_upsert_booking_custom_attributes(body:)
|
295
|
+
# Prepare query url.
|
296
|
+
_query_builder = config.get_base_uri
|
297
|
+
_query_builder << '/v2/bookings/custom-attributes/bulk-upsert'
|
298
|
+
_query_url = APIHelper.clean_url _query_builder
|
299
|
+
|
300
|
+
# Prepare headers.
|
301
|
+
_headers = {
|
302
|
+
'accept' => 'application/json',
|
303
|
+
'Content-Type' => 'application/json'
|
304
|
+
}
|
305
|
+
|
306
|
+
# Prepare and execute HttpRequest.
|
307
|
+
_request = config.http_client.post(
|
308
|
+
_query_url,
|
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
|
+
)
|
321
|
+
end
|
322
|
+
|
323
|
+
# Lists a booking's custom attributes.
|
324
|
+
# To call this endpoint with buyer-level permissions, set
|
325
|
+
# `APPOINTMENTS_READ` for the OAuth scope.
|
326
|
+
# To call this endpoint with seller-level permissions, set
|
327
|
+
# `APPOINTMENTS_ALL_READ` and `APPOINTMENTS_READ` for the OAuth scope.
|
328
|
+
# @param [String] booking_id Required parameter: The ID of the target
|
329
|
+
# [booking]($m/Booking).
|
330
|
+
# @param [Integer] limit Optional parameter: The maximum number of results
|
331
|
+
# to return in a single paged response. This limit is advisory. The response
|
332
|
+
# might contain more or fewer results. The minimum value is 1 and the
|
333
|
+
# maximum value is 100. The default value is 20. For more information, see
|
334
|
+
# [Pagination](https://developer.squareup.com/docs/build-basics/common-api-p
|
335
|
+
# atterns/pagination).
|
336
|
+
# @param [String] cursor Optional parameter: The cursor returned in the
|
337
|
+
# paged response from the previous call to this endpoint. Provide this
|
338
|
+
# cursor to retrieve the next page of results for your original request. For
|
339
|
+
# more information, see
|
340
|
+
# [Pagination](https://developer.squareup.com/docs/build-basics/common-api-p
|
341
|
+
# atterns/pagination).
|
342
|
+
# @param [TrueClass|FalseClass] with_definitions Optional parameter:
|
343
|
+
# Indicates whether to return the [custom attribute
|
344
|
+
# definition]($m/CustomAttributeDefinition) in the `definition` field of
|
345
|
+
# each custom attribute. Set this parameter to `true` to get the name and
|
346
|
+
# description of each custom attribute, information about the data type, or
|
347
|
+
# other definition details. The default value is `false`.
|
348
|
+
# @return [ListBookingCustomAttributesResponse Hash] response from the API call
|
349
|
+
def list_booking_custom_attributes(booking_id:,
|
350
|
+
limit: nil,
|
351
|
+
cursor: nil,
|
352
|
+
with_definitions: false)
|
353
|
+
# Prepare query url.
|
354
|
+
_query_builder = config.get_base_uri
|
355
|
+
_query_builder << '/v2/bookings/{booking_id}/custom-attributes'
|
356
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
357
|
+
_query_builder,
|
358
|
+
'booking_id' => { 'value' => booking_id, 'encode' => true }
|
359
|
+
)
|
360
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
361
|
+
_query_builder,
|
362
|
+
'limit' => limit,
|
363
|
+
'cursor' => cursor,
|
364
|
+
'with_definitions' => with_definitions
|
365
|
+
)
|
366
|
+
_query_url = APIHelper.clean_url _query_builder
|
367
|
+
|
368
|
+
# Prepare headers.
|
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
|
+
)
|
387
|
+
end
|
388
|
+
|
389
|
+
# Deletes a bookings custom attribute.
|
390
|
+
# To call this endpoint with buyer-level permissions, set
|
391
|
+
# `APPOINTMENTS_WRITE` for the OAuth scope.
|
392
|
+
# To call this endpoint with seller-level permissions, set
|
393
|
+
# `APPOINTMENTS_ALL_WRITE` and `APPOINTMENTS_WRITE` for the OAuth scope.
|
394
|
+
# For calls to this endpoint with seller-level permissions to succeed, the
|
395
|
+
# seller must have subscribed to *Appointments Plus*
|
396
|
+
# or *Appointments Premium*.
|
397
|
+
# @param [String] booking_id Required parameter: The ID of the target
|
398
|
+
# [booking]($m/Booking).
|
399
|
+
# @param [String] key Required parameter: The key of the custom attribute to
|
400
|
+
# delete. This key must match the `key` of a custom attribute definition in
|
401
|
+
# the Square seller account. If the requesting application is not the
|
402
|
+
# definition owner, you must use the qualified key.
|
403
|
+
# @return [DeleteBookingCustomAttributeResponse Hash] response from the API call
|
404
|
+
def delete_booking_custom_attribute(booking_id:,
|
405
|
+
key:)
|
406
|
+
# Prepare query url.
|
407
|
+
_query_builder = config.get_base_uri
|
408
|
+
_query_builder << '/v2/bookings/{booking_id}/custom-attributes/{key}'
|
409
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
410
|
+
_query_builder,
|
411
|
+
'booking_id' => { 'value' => booking_id, 'encode' => true },
|
412
|
+
'key' => { 'value' => key, 'encode' => true }
|
413
|
+
)
|
414
|
+
_query_url = APIHelper.clean_url _query_builder
|
415
|
+
|
416
|
+
# Prepare headers.
|
417
|
+
_headers = {
|
418
|
+
'accept' => 'application/json'
|
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
|
+
)
|
435
|
+
end
|
436
|
+
|
437
|
+
# Retrieves a bookings custom attribute.
|
438
|
+
# To call this endpoint with buyer-level permissions, set
|
439
|
+
# `APPOINTMENTS_READ` for the OAuth scope.
|
440
|
+
# To call this endpoint with seller-level permissions, set
|
441
|
+
# `APPOINTMENTS_ALL_READ` and `APPOINTMENTS_READ` for the OAuth scope.
|
442
|
+
# @param [String] booking_id Required parameter: The ID of the target
|
443
|
+
# [booking]($m/Booking).
|
444
|
+
# @param [String] key Required parameter: The key of the custom attribute to
|
445
|
+
# retrieve. This key must match the `key` of a custom attribute definition
|
446
|
+
# in the Square seller account. If the requesting application is not the
|
447
|
+
# definition owner, you must use the qualified key.
|
448
|
+
# @param [TrueClass|FalseClass] with_definition Optional parameter:
|
449
|
+
# Indicates whether to return the [custom attribute
|
450
|
+
# definition]($m/CustomAttributeDefinition) in the `definition` field of the
|
451
|
+
# custom attribute. Set this parameter to `true` to get the name and
|
452
|
+
# description of the custom attribute, information about the data type, or
|
453
|
+
# other definition details. The default value is `false`.
|
454
|
+
# @param [Integer] version Optional parameter: The current version of the
|
455
|
+
# custom attribute, which is used for strongly consistent reads to guarantee
|
456
|
+
# that you receive the most up-to-date data. When included in the request,
|
457
|
+
# Square returns the specified version or a higher version if one exists. If
|
458
|
+
# the specified version is higher than the current version, Square returns a
|
459
|
+
# `BAD_REQUEST` error.
|
460
|
+
# @return [RetrieveBookingCustomAttributeResponse Hash] response from the API call
|
461
|
+
def retrieve_booking_custom_attribute(booking_id:,
|
462
|
+
key:,
|
463
|
+
with_definition: false,
|
464
|
+
version: nil)
|
465
|
+
# Prepare query url.
|
466
|
+
_query_builder = config.get_base_uri
|
467
|
+
_query_builder << '/v2/bookings/{booking_id}/custom-attributes/{key}'
|
468
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
469
|
+
_query_builder,
|
470
|
+
'booking_id' => { 'value' => booking_id, 'encode' => true },
|
471
|
+
'key' => { 'value' => key, 'encode' => true }
|
472
|
+
)
|
473
|
+
_query_builder = APIHelper.append_url_with_query_parameters(
|
474
|
+
_query_builder,
|
475
|
+
'with_definition' => with_definition,
|
476
|
+
'version' => version
|
477
|
+
)
|
478
|
+
_query_url = APIHelper.clean_url _query_builder
|
479
|
+
|
480
|
+
# Prepare headers.
|
481
|
+
_headers = {
|
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
|
+
)
|
499
|
+
end
|
500
|
+
|
501
|
+
# Upserts a bookings custom attribute.
|
502
|
+
# To call this endpoint with buyer-level permissions, set
|
503
|
+
# `APPOINTMENTS_WRITE` for the OAuth scope.
|
504
|
+
# To call this endpoint with seller-level permissions, set
|
505
|
+
# `APPOINTMENTS_ALL_WRITE` and `APPOINTMENTS_WRITE` for the OAuth scope.
|
506
|
+
# For calls to this endpoint with seller-level permissions to succeed, the
|
507
|
+
# seller must have subscribed to *Appointments Plus*
|
508
|
+
# or *Appointments Premium*.
|
509
|
+
# @param [String] booking_id Required parameter: The ID of the target
|
510
|
+
# [booking]($m/Booking).
|
511
|
+
# @param [String] key Required parameter: The key of the custom attribute to
|
512
|
+
# create or update. This key must match the `key` of a custom attribute
|
513
|
+
# definition in the Square seller account. If the requesting application is
|
514
|
+
# not the definition owner, you must use the qualified key.
|
515
|
+
# @param [UpsertBookingCustomAttributeRequest] body Required parameter: An
|
516
|
+
# object containing the fields to POST for the request. See the
|
517
|
+
# corresponding object definition for field details.
|
518
|
+
# @return [UpsertBookingCustomAttributeResponse Hash] response from the API call
|
519
|
+
def upsert_booking_custom_attribute(booking_id:,
|
520
|
+
key:,
|
521
|
+
body:)
|
522
|
+
# Prepare query url.
|
523
|
+
_query_builder = config.get_base_uri
|
524
|
+
_query_builder << '/v2/bookings/{booking_id}/custom-attributes/{key}'
|
525
|
+
_query_builder = APIHelper.append_url_with_template_parameters(
|
526
|
+
_query_builder,
|
527
|
+
'booking_id' => { 'value' => booking_id, 'encode' => true },
|
528
|
+
'key' => { 'value' => key, 'encode' => true }
|
529
|
+
)
|
530
|
+
_query_url = APIHelper.clean_url _query_builder
|
531
|
+
|
532
|
+
# Prepare headers.
|
533
|
+
_headers = {
|
534
|
+
'accept' => 'application/json',
|
535
|
+
'Content-Type' => 'application/json'
|
536
|
+
}
|
537
|
+
|
538
|
+
# Prepare and execute HttpRequest.
|
539
|
+
_request = config.http_client.put(
|
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
|
+
)
|
553
|
+
end
|
554
|
+
end
|
555
|
+
end
|