square.rb 24.0.0.20221019 → 26.0.0.20221214

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.
@@ -168,5 +168,52 @@ module Square
168
168
  _response, data: decoded, errors: _errors
169
169
  )
170
170
  end
171
+
172
+ # Returns information about an [OAuth access
173
+ # token](https://developer.squareup.com/docs/build-basics/access-tokens#get-
174
+ # an-oauth-access-token) or an application’s [personal access
175
+ # token](https://developer.squareup.com/docs/build-basics/access-tokens#get-
176
+ # a-personal-access-token).
177
+ # Add the access token to the Authorization header of the request.
178
+ # __Important:__ The `Authorization` header you provide to this endpoint
179
+ # must have the following format:
180
+ # ```
181
+ # Authorization: Bearer ACCESS_TOKEN
182
+ # ```
183
+ # where `ACCESS_TOKEN` is a
184
+ # [valid production authorization
185
+ # credential](https://developer.squareup.com/docs/build-basics/access-tokens
186
+ # ).
187
+ # If the access token is expired or not a valid access token, the endpoint
188
+ # returns an `UNAUTHORIZED` error.
189
+ # @param [String] authorization Required parameter: Client
190
+ # APPLICATION_SECRET
191
+ # @return [RetrieveTokenStatusResponse Hash] response from the API call
192
+ def retrieve_token_status(authorization:)
193
+ # Prepare query url.
194
+ _query_builder = config.get_base_uri
195
+ _query_builder << '/oauth2/token/status'
196
+ _query_url = APIHelper.clean_url _query_builder
197
+
198
+ # Prepare headers.
199
+ _headers = {
200
+ 'accept' => 'application/json',
201
+ 'Authorization' => authorization
202
+ }
203
+
204
+ # Prepare and execute HttpRequest.
205
+ _request = config.http_client.post(
206
+ _query_url,
207
+ headers: _headers
208
+ )
209
+ _response = execute_request(_request)
210
+
211
+ # Return appropriate response type.
212
+ decoded = APIHelper.json_deserialize(_response.raw_body)
213
+ _errors = APIHelper.map_response(decoded, ['errors'])
214
+ ApiResponse.new(
215
+ _response, data: decoded, errors: _errors
216
+ )
217
+ end
171
218
  end
172
219
  end
@@ -0,0 +1,601 @@
1
+ module Square
2
+ # OrderCustomAttributesApi
3
+ class OrderCustomAttributesApi < BaseApi
4
+ def initialize(config, http_call_back: nil)
5
+ super(config, http_call_back: http_call_back)
6
+ end
7
+
8
+ # Lists the order-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`. Note that
17
+ # seller-defined custom attributes (also known as custom fields) are always
18
+ # set to `VISIBILITY_READ_WRITE_VALUES`.
19
+ # @param [VisibilityFilter] visibility_filter Optional parameter: Requests
20
+ # that all of the custom attributes be returned, or only those that are
21
+ # read-only or read-write.
22
+ # @param [String] cursor Optional parameter: The cursor returned in the
23
+ # paged response from the previous call to this endpoint. Provide this
24
+ # cursor to retrieve the next page of results for your original request.
25
+ # For more information, see
26
+ # [Pagination](https://developer.squareup.com/docs/working-with-apis/paginat
27
+ # ion).
28
+ # @param [Integer] limit Optional parameter: The maximum number of results
29
+ # to return in a single paged response. This limit is advisory. The
30
+ # response might contain more or fewer results. The minimum value is 1 and
31
+ # the maximum value is 100. The default value is 20. For more information,
32
+ # see
33
+ # [Pagination](https://developer.squareup.com/docs/working-with-apis/paginat
34
+ # ion).
35
+ # @return [ListOrderCustomAttributeDefinitionsResponse Hash] response from the API call
36
+ def list_order_custom_attribute_definitions(visibility_filter: nil,
37
+ cursor: nil,
38
+ limit: nil)
39
+ # Prepare query url.
40
+ _query_builder = config.get_base_uri
41
+ _query_builder << '/v2/orders/custom-attribute-definitions'
42
+ _query_builder = APIHelper.append_url_with_query_parameters(
43
+ _query_builder,
44
+ 'visibility_filter' => visibility_filter,
45
+ 'cursor' => cursor,
46
+ 'limit' => limit
47
+ )
48
+ _query_url = APIHelper.clean_url _query_builder
49
+
50
+ # Prepare headers.
51
+ _headers = {
52
+ 'accept' => 'application/json'
53
+ }
54
+
55
+ # Prepare and execute HttpRequest.
56
+ _request = config.http_client.get(
57
+ _query_url,
58
+ headers: _headers
59
+ )
60
+ OAuth2.apply(config, _request)
61
+ _response = execute_request(_request)
62
+
63
+ # Return appropriate response type.
64
+ decoded = APIHelper.json_deserialize(_response.raw_body)
65
+ _errors = APIHelper.map_response(decoded, ['errors'])
66
+ ApiResponse.new(
67
+ _response, data: decoded, errors: _errors
68
+ )
69
+ end
70
+
71
+ # Creates an order-related custom attribute definition. Use this endpoint
72
+ # to
73
+ # define a custom attribute that can be associated with orders.
74
+ # After creating a custom attribute definition, you can set the custom
75
+ # attribute for orders
76
+ # in the Square seller account.
77
+ # @param [CreateOrderCustomAttributeDefinitionRequest] body Required
78
+ # parameter: An object containing the fields to POST for the request. See
79
+ # the corresponding object definition for field details.
80
+ # @return [CreateOrderCustomAttributeDefinitionResponse Hash] response from the API call
81
+ def create_order_custom_attribute_definition(body:)
82
+ # Prepare query url.
83
+ _query_builder = config.get_base_uri
84
+ _query_builder << '/v2/orders/custom-attribute-definitions'
85
+ _query_url = APIHelper.clean_url _query_builder
86
+
87
+ # Prepare headers.
88
+ _headers = {
89
+ 'accept' => 'application/json',
90
+ 'Content-Type' => 'application/json'
91
+ }
92
+
93
+ # Prepare and execute HttpRequest.
94
+ _request = config.http_client.post(
95
+ _query_url,
96
+ headers: _headers,
97
+ parameters: body.to_json
98
+ )
99
+ OAuth2.apply(config, _request)
100
+ _response = execute_request(_request)
101
+
102
+ # Return appropriate response type.
103
+ decoded = APIHelper.json_deserialize(_response.raw_body)
104
+ _errors = APIHelper.map_response(decoded, ['errors'])
105
+ ApiResponse.new(
106
+ _response, data: decoded, errors: _errors
107
+ )
108
+ end
109
+
110
+ # Deletes an order-related [custom attribute
111
+ # definition]($m/CustomAttributeDefinition) from a Square seller account.
112
+ # Only the definition owner can delete a custom attribute definition.
113
+ # @param [String] key Required parameter: The key of the custom attribute
114
+ # definition to delete.
115
+ # @return [DeleteOrderCustomAttributeDefinitionResponse Hash] response from the API call
116
+ def delete_order_custom_attribute_definition(key:)
117
+ # Prepare query url.
118
+ _query_builder = config.get_base_uri
119
+ _query_builder << '/v2/orders/custom-attribute-definitions/{key}'
120
+ _query_builder = APIHelper.append_url_with_template_parameters(
121
+ _query_builder,
122
+ 'key' => { 'value' => key, 'encode' => true }
123
+ )
124
+ _query_url = APIHelper.clean_url _query_builder
125
+
126
+ # Prepare headers.
127
+ _headers = {
128
+ 'accept' => 'application/json'
129
+ }
130
+
131
+ # Prepare and execute HttpRequest.
132
+ _request = config.http_client.delete(
133
+ _query_url,
134
+ headers: _headers
135
+ )
136
+ OAuth2.apply(config, _request)
137
+ _response = execute_request(_request)
138
+
139
+ # Return appropriate response type.
140
+ decoded = APIHelper.json_deserialize(_response.raw_body)
141
+ _errors = APIHelper.map_response(decoded, ['errors'])
142
+ ApiResponse.new(
143
+ _response, data: decoded, errors: _errors
144
+ )
145
+ end
146
+
147
+ # Retrieves an order-related [custom attribute
148
+ # definition]($m/CustomAttributeDefinition) from a Square seller account.
149
+ # To retrieve a custom attribute definition created by another application,
150
+ # the `visibility`
151
+ # setting must be `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`.
152
+ # Note that seller-defined custom attributes
153
+ # (also known as custom fields) are always set to
154
+ # `VISIBILITY_READ_WRITE_VALUES`.
155
+ # @param [String] key Required parameter: The key of the custom attribute
156
+ # definition to retrieve.
157
+ # @param [Integer] version Optional parameter: To enable [optimistic
158
+ # concurrency](https://developer.squareup.com/docs/build-basics/common-api-p
159
+ # atterns/optimistic-concurrency) control, include this optional field and
160
+ # specify the current version of the custom attribute.
161
+ # @return [RetrieveOrderCustomAttributeDefinitionResponse Hash] response from the API call
162
+ def retrieve_order_custom_attribute_definition(key:,
163
+ version: nil)
164
+ # Prepare query url.
165
+ _query_builder = config.get_base_uri
166
+ _query_builder << '/v2/orders/custom-attribute-definitions/{key}'
167
+ _query_builder = APIHelper.append_url_with_template_parameters(
168
+ _query_builder,
169
+ 'key' => { 'value' => key, 'encode' => true }
170
+ )
171
+ _query_builder = APIHelper.append_url_with_query_parameters(
172
+ _query_builder,
173
+ 'version' => version
174
+ )
175
+ _query_url = APIHelper.clean_url _query_builder
176
+
177
+ # Prepare headers.
178
+ _headers = {
179
+ 'accept' => 'application/json'
180
+ }
181
+
182
+ # Prepare and execute HttpRequest.
183
+ _request = config.http_client.get(
184
+ _query_url,
185
+ headers: _headers
186
+ )
187
+ OAuth2.apply(config, _request)
188
+ _response = execute_request(_request)
189
+
190
+ # Return appropriate response type.
191
+ decoded = APIHelper.json_deserialize(_response.raw_body)
192
+ _errors = APIHelper.map_response(decoded, ['errors'])
193
+ ApiResponse.new(
194
+ _response, data: decoded, errors: _errors
195
+ )
196
+ end
197
+
198
+ # Updates an order-related custom attribute definition for a Square seller
199
+ # account.
200
+ # Only the definition owner can update a custom attribute definition. Note
201
+ # that sellers can view all custom attributes in exported customer data,
202
+ # including those set to `VISIBILITY_HIDDEN`.
203
+ # @param [String] key Required parameter: The key of the custom attribute
204
+ # definition to update.
205
+ # @param [UpdateOrderCustomAttributeDefinitionRequest] body Required
206
+ # parameter: An object containing the fields to POST for the request. See
207
+ # the corresponding object definition for field details.
208
+ # @return [UpdateOrderCustomAttributeDefinitionResponse Hash] response from the API call
209
+ def update_order_custom_attribute_definition(key:,
210
+ body:)
211
+ # Prepare query url.
212
+ _query_builder = config.get_base_uri
213
+ _query_builder << '/v2/orders/custom-attribute-definitions/{key}'
214
+ _query_builder = APIHelper.append_url_with_template_parameters(
215
+ _query_builder,
216
+ 'key' => { 'value' => key, 'encode' => true }
217
+ )
218
+ _query_url = APIHelper.clean_url _query_builder
219
+
220
+ # Prepare headers.
221
+ _headers = {
222
+ 'accept' => 'application/json',
223
+ 'Content-Type' => 'application/json'
224
+ }
225
+
226
+ # Prepare and execute HttpRequest.
227
+ _request = config.http_client.put(
228
+ _query_url,
229
+ headers: _headers,
230
+ parameters: body.to_json
231
+ )
232
+ OAuth2.apply(config, _request)
233
+ _response = execute_request(_request)
234
+
235
+ # Return appropriate response type.
236
+ decoded = APIHelper.json_deserialize(_response.raw_body)
237
+ _errors = APIHelper.map_response(decoded, ['errors'])
238
+ ApiResponse.new(
239
+ _response, data: decoded, errors: _errors
240
+ )
241
+ end
242
+
243
+ # Deletes order [custom attributes]($m/CustomAttribute) as a bulk operation.
244
+ # Use this endpoint to delete one or more custom attributes from one or more
245
+ # orders.
246
+ # A custom attribute is based on a custom attribute definition in a Square
247
+ # seller account. (To create a
248
+ # custom attribute definition, use the
249
+ # [CreateOrderCustomAttributeDefinition]($e/OrderCustomAttributes/CreateOrde
250
+ # rCustomAttributeDefinition) endpoint.)
251
+ # This `BulkDeleteOrderCustomAttributes` endpoint accepts a map of 1 to 25
252
+ # individual delete
253
+ # requests and returns a map of individual delete responses. Each delete
254
+ # request has a unique ID
255
+ # and provides an order ID and custom attribute. Each delete response is
256
+ # returned with the ID
257
+ # of the corresponding request.
258
+ # To delete a custom attribute owned by another application, the
259
+ # `visibility` setting
260
+ # must be `VISIBILITY_READ_WRITE_VALUES`. Note that seller-defined custom
261
+ # attributes
262
+ # (also known as custom fields) are always set to
263
+ # `VISIBILITY_READ_WRITE_VALUES`.
264
+ # @param [BulkDeleteOrderCustomAttributesRequest] body Required parameter:
265
+ # An object containing the fields to POST for the request. See the
266
+ # corresponding object definition for field details.
267
+ # @return [BulkDeleteOrderCustomAttributesResponse Hash] response from the API call
268
+ def bulk_delete_order_custom_attributes(body:)
269
+ # Prepare query url.
270
+ _query_builder = config.get_base_uri
271
+ _query_builder << '/v2/orders/custom-attributes/bulk-delete'
272
+ _query_url = APIHelper.clean_url _query_builder
273
+
274
+ # Prepare headers.
275
+ _headers = {
276
+ 'accept' => 'application/json',
277
+ 'Content-Type' => 'application/json'
278
+ }
279
+
280
+ # Prepare and execute HttpRequest.
281
+ _request = config.http_client.post(
282
+ _query_url,
283
+ headers: _headers,
284
+ parameters: body.to_json
285
+ )
286
+ OAuth2.apply(config, _request)
287
+ _response = execute_request(_request)
288
+
289
+ # Return appropriate response type.
290
+ decoded = APIHelper.json_deserialize(_response.raw_body)
291
+ _errors = APIHelper.map_response(decoded, ['errors'])
292
+ ApiResponse.new(
293
+ _response, data: decoded, errors: _errors
294
+ )
295
+ end
296
+
297
+ # Creates or updates order [custom attributes]($m/CustomAttribute) as a bulk
298
+ # operation.
299
+ # Use this endpoint to delete one or more custom attributes from one or more
300
+ # orders.
301
+ # A custom attribute is based on a custom attribute definition in a Square
302
+ # seller account. (To create a
303
+ # custom attribute definition, use the
304
+ # [CreateOrderCustomAttributeDefinition]($e/OrderCustomAttributes/CreateOrde
305
+ # rCustomAttributeDefinition) endpoint.)
306
+ # This `BulkUpsertOrderCustomAttributes` endpoint accepts a map of 1 to 25
307
+ # individual upsert
308
+ # requests and returns a map of individual upsert responses. Each upsert
309
+ # request has a unique ID
310
+ # and provides an order ID and custom attribute. Each upsert response is
311
+ # returned with the ID
312
+ # of the corresponding request.
313
+ # To create or update a custom attribute owned by another application, the
314
+ # `visibility` setting
315
+ # must be `VISIBILITY_READ_WRITE_VALUES`. Note that seller-defined custom
316
+ # attributes
317
+ # (also known as custom fields) are always set to
318
+ # `VISIBILITY_READ_WRITE_VALUES`.
319
+ # @param [BulkUpsertOrderCustomAttributesRequest] body Required parameter:
320
+ # An object containing the fields to POST for the request. See the
321
+ # corresponding object definition for field details.
322
+ # @return [BulkUpsertOrderCustomAttributesResponse Hash] response from the API call
323
+ def bulk_upsert_order_custom_attributes(body:)
324
+ # Prepare query url.
325
+ _query_builder = config.get_base_uri
326
+ _query_builder << '/v2/orders/custom-attributes/bulk-upsert'
327
+ _query_url = APIHelper.clean_url _query_builder
328
+
329
+ # Prepare headers.
330
+ _headers = {
331
+ 'accept' => 'application/json',
332
+ 'Content-Type' => 'application/json'
333
+ }
334
+
335
+ # Prepare and execute HttpRequest.
336
+ _request = config.http_client.post(
337
+ _query_url,
338
+ headers: _headers,
339
+ parameters: body.to_json
340
+ )
341
+ OAuth2.apply(config, _request)
342
+ _response = execute_request(_request)
343
+
344
+ # Return appropriate response type.
345
+ decoded = APIHelper.json_deserialize(_response.raw_body)
346
+ _errors = APIHelper.map_response(decoded, ['errors'])
347
+ ApiResponse.new(
348
+ _response, data: decoded, errors: _errors
349
+ )
350
+ end
351
+
352
+ # Lists the [custom attributes]($m/CustomAttribute) associated with an
353
+ # order.
354
+ # You can use the `with_definitions` query parameter to also retrieve custom
355
+ # attribute definitions
356
+ # in the same call.
357
+ # When all response pages are retrieved, the results include all custom
358
+ # attributes that are
359
+ # visible to the requesting application, including those that are owned by
360
+ # other applications
361
+ # and set to `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`.
362
+ # @param [String] order_id Required parameter: The ID of the target
363
+ # [order]($m/Order).
364
+ # @param [VisibilityFilter] visibility_filter Optional parameter: Requests
365
+ # that all of the custom attributes be returned, or only those that are
366
+ # read-only or read-write.
367
+ # @param [String] cursor Optional parameter: The cursor returned in the
368
+ # paged response from the previous call to this endpoint. Provide this
369
+ # cursor to retrieve the next page of results for your original request.
370
+ # For more information, see
371
+ # [Pagination](https://developer.squareup.com/docs/working-with-apis/paginat
372
+ # ion).
373
+ # @param [Integer] limit Optional parameter: The maximum number of results
374
+ # to return in a single paged response. This limit is advisory. The
375
+ # response might contain more or fewer results. The minimum value is 1 and
376
+ # the maximum value is 100. The default value is 20. For more information,
377
+ # see
378
+ # [Pagination](https://developer.squareup.com/docs/working-with-apis/paginat
379
+ # ion).
380
+ # @param [TrueClass|FalseClass] with_definitions Optional parameter:
381
+ # Indicates whether to return the [custom attribute
382
+ # definition]($m/CustomAttributeDefinition) in the `definition` field of
383
+ # each custom attribute. Set this parameter to `true` to get the name and
384
+ # description of each custom attribute, information about the data type, or
385
+ # other definition details. The default value is `false`.
386
+ # @return [ListOrderCustomAttributesResponse Hash] response from the API call
387
+ def list_order_custom_attributes(order_id:,
388
+ visibility_filter: nil,
389
+ cursor: nil,
390
+ limit: nil,
391
+ with_definitions: false)
392
+ # Prepare query url.
393
+ _query_builder = config.get_base_uri
394
+ _query_builder << '/v2/orders/{order_id}/custom-attributes'
395
+ _query_builder = APIHelper.append_url_with_template_parameters(
396
+ _query_builder,
397
+ 'order_id' => { 'value' => order_id, 'encode' => true }
398
+ )
399
+ _query_builder = APIHelper.append_url_with_query_parameters(
400
+ _query_builder,
401
+ 'visibility_filter' => visibility_filter,
402
+ 'cursor' => cursor,
403
+ 'limit' => limit,
404
+ 'with_definitions' => with_definitions
405
+ )
406
+ _query_url = APIHelper.clean_url _query_builder
407
+
408
+ # Prepare headers.
409
+ _headers = {
410
+ 'accept' => 'application/json'
411
+ }
412
+
413
+ # Prepare and execute HttpRequest.
414
+ _request = config.http_client.get(
415
+ _query_url,
416
+ headers: _headers
417
+ )
418
+ OAuth2.apply(config, _request)
419
+ _response = execute_request(_request)
420
+
421
+ # Return appropriate response type.
422
+ decoded = APIHelper.json_deserialize(_response.raw_body)
423
+ _errors = APIHelper.map_response(decoded, ['errors'])
424
+ ApiResponse.new(
425
+ _response, data: decoded, errors: _errors
426
+ )
427
+ end
428
+
429
+ # Deletes a [custom attribute]($m/CustomAttribute) associated with a
430
+ # customer profile.
431
+ # To delete a custom attribute owned by another application, the
432
+ # `visibility` setting must be
433
+ # `VISIBILITY_READ_WRITE_VALUES`. Note that seller-defined custom attributes
434
+ # (also known as custom fields) are always set to
435
+ # `VISIBILITY_READ_WRITE_VALUES`.
436
+ # @param [String] order_id Required parameter: The ID of the target
437
+ # [order]($m/Order).
438
+ # @param [String] custom_attribute_key Required parameter: The key of the
439
+ # custom attribute to delete. This key must match the key of an existing
440
+ # custom attribute definition.
441
+ # @return [DeleteOrderCustomAttributeResponse Hash] response from the API call
442
+ def delete_order_custom_attribute(order_id:,
443
+ custom_attribute_key:)
444
+ # Prepare query url.
445
+ _query_builder = config.get_base_uri
446
+ _query_builder << '/v2/orders/{order_id}/custom-attributes/{custom_attribute_key}'
447
+ _query_builder = APIHelper.append_url_with_template_parameters(
448
+ _query_builder,
449
+ 'order_id' => { 'value' => order_id, 'encode' => true },
450
+ 'custom_attribute_key' => { 'value' => custom_attribute_key, 'encode' => true }
451
+ )
452
+ _query_url = APIHelper.clean_url _query_builder
453
+
454
+ # Prepare headers.
455
+ _headers = {
456
+ 'accept' => 'application/json'
457
+ }
458
+
459
+ # Prepare and execute HttpRequest.
460
+ _request = config.http_client.delete(
461
+ _query_url,
462
+ headers: _headers
463
+ )
464
+ OAuth2.apply(config, _request)
465
+ _response = execute_request(_request)
466
+
467
+ # Return appropriate response type.
468
+ decoded = APIHelper.json_deserialize(_response.raw_body)
469
+ _errors = APIHelper.map_response(decoded, ['errors'])
470
+ ApiResponse.new(
471
+ _response, data: decoded, errors: _errors
472
+ )
473
+ end
474
+
475
+ # Retrieves a [custom attribute]($m/CustomAttribute) associated with an
476
+ # order.
477
+ # You can use the `with_definition` query parameter to also retrieve the
478
+ # custom attribute definition
479
+ # in the same call.
480
+ # To retrieve a custom attribute owned by another application, the
481
+ # `visibility` setting must be
482
+ # `VISIBILITY_READ_ONLY` or `VISIBILITY_READ_WRITE_VALUES`. Note that
483
+ # seller-defined custom attributes
484
+ # also known as custom fields) are always set to
485
+ # `VISIBILITY_READ_WRITE_VALUES`.
486
+ # @param [String] order_id Required parameter: The ID of the target
487
+ # [order]($m/Order).
488
+ # @param [String] custom_attribute_key Required parameter: The key of the
489
+ # custom attribute to retrieve. This key must match the key of an existing
490
+ # custom attribute definition.
491
+ # @param [Integer] version Optional parameter: To enable [optimistic
492
+ # concurrency](https://developer.squareup.com/docs/build-basics/common-api-p
493
+ # atterns/optimistic-concurrency) control, include this optional field and
494
+ # specify the current version of the custom attribute.
495
+ # @param [TrueClass|FalseClass] with_definition Optional parameter:
496
+ # Indicates whether to return the [custom attribute
497
+ # definition]($m/CustomAttributeDefinition) in the `definition` field of
498
+ # each custom attribute. Set this parameter to `true` to get the name and
499
+ # description of each custom attribute, information about the data type, or
500
+ # other definition details. The default value is `false`.
501
+ # @return [RetrieveOrderCustomAttributeResponse Hash] response from the API call
502
+ def retrieve_order_custom_attribute(order_id:,
503
+ custom_attribute_key:,
504
+ version: nil,
505
+ with_definition: false)
506
+ # Prepare query url.
507
+ _query_builder = config.get_base_uri
508
+ _query_builder << '/v2/orders/{order_id}/custom-attributes/{custom_attribute_key}'
509
+ _query_builder = APIHelper.append_url_with_template_parameters(
510
+ _query_builder,
511
+ 'order_id' => { 'value' => order_id, 'encode' => true },
512
+ 'custom_attribute_key' => { 'value' => custom_attribute_key, 'encode' => true }
513
+ )
514
+ _query_builder = APIHelper.append_url_with_query_parameters(
515
+ _query_builder,
516
+ 'version' => version,
517
+ 'with_definition' => with_definition
518
+ )
519
+ _query_url = APIHelper.clean_url _query_builder
520
+
521
+ # Prepare headers.
522
+ _headers = {
523
+ 'accept' => 'application/json'
524
+ }
525
+
526
+ # Prepare and execute HttpRequest.
527
+ _request = config.http_client.get(
528
+ _query_url,
529
+ headers: _headers
530
+ )
531
+ OAuth2.apply(config, _request)
532
+ _response = execute_request(_request)
533
+
534
+ # Return appropriate response type.
535
+ decoded = APIHelper.json_deserialize(_response.raw_body)
536
+ _errors = APIHelper.map_response(decoded, ['errors'])
537
+ ApiResponse.new(
538
+ _response, data: decoded, errors: _errors
539
+ )
540
+ end
541
+
542
+ # Creates or updates a [custom attribute]($m/CustomAttribute) for an order.
543
+ # Use this endpoint to set the value of a custom attribute for a specific
544
+ # order.
545
+ # A custom attribute is based on a custom attribute definition in a Square
546
+ # seller account. (To create a
547
+ # custom attribute definition, use the
548
+ # [CreateOrderCustomAttributeDefinition]($e/OrderCustomAttributes/CreateOrde
549
+ # rCustomAttributeDefinition) endpoint.)
550
+ # To create or update a custom attribute owned by another application, the
551
+ # `visibility` setting
552
+ # must be `VISIBILITY_READ_WRITE_VALUES`. Note that seller-defined custom
553
+ # attributes
554
+ # (also known as custom fields) are always set to
555
+ # `VISIBILITY_READ_WRITE_VALUES`.
556
+ # @param [String] order_id Required parameter: The ID of the target
557
+ # [order]($m/Order).
558
+ # @param [String] custom_attribute_key Required parameter: The key of the
559
+ # custom attribute to create or update. This key must match the key of an
560
+ # existing custom attribute definition.
561
+ # @param [UpsertOrderCustomAttributeRequest] body Required parameter: An
562
+ # object containing the fields to POST for the request. See the
563
+ # corresponding object definition for field details.
564
+ # @return [UpsertOrderCustomAttributeResponse Hash] response from the API call
565
+ def upsert_order_custom_attribute(order_id:,
566
+ custom_attribute_key:,
567
+ body:)
568
+ # Prepare query url.
569
+ _query_builder = config.get_base_uri
570
+ _query_builder << '/v2/orders/{order_id}/custom-attributes/{custom_attribute_key}'
571
+ _query_builder = APIHelper.append_url_with_template_parameters(
572
+ _query_builder,
573
+ 'order_id' => { 'value' => order_id, 'encode' => true },
574
+ 'custom_attribute_key' => { 'value' => custom_attribute_key, 'encode' => true }
575
+ )
576
+ _query_url = APIHelper.clean_url _query_builder
577
+
578
+ # Prepare headers.
579
+ _headers = {
580
+ 'accept' => 'application/json',
581
+ 'Content-Type' => 'application/json'
582
+ }
583
+
584
+ # Prepare and execute HttpRequest.
585
+ _request = config.http_client.post(
586
+ _query_url,
587
+ headers: _headers,
588
+ parameters: body.to_json
589
+ )
590
+ OAuth2.apply(config, _request)
591
+ _response = execute_request(_request)
592
+
593
+ # Return appropriate response type.
594
+ decoded = APIHelper.json_deserialize(_response.raw_body)
595
+ _errors = APIHelper.map_response(decoded, ['errors'])
596
+ ApiResponse.new(
597
+ _response, data: decoded, errors: _errors
598
+ )
599
+ end
600
+ end
601
+ end
@@ -250,8 +250,8 @@ module Square
250
250
  # is
251
251
  # being applied.
252
252
  # - If deleting fields, the [dot notation
253
- # paths](https://developer.squareup.com/docs/orders-api/manage-orders#on-dot
254
- # -notation)
253
+ # paths](https://developer.squareup.com/docs/orders-api/manage-orders/update
254
+ # -orders#identifying-fields-to-delete)
255
255
  # identifying the fields to clear.
256
256
  # To pay for an order, see
257
257
  # [Pay for