fangkuai.rb 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +10 -0
  3. data/README.md +1 -0
  4. data/lib/square.rb +61 -0
  5. data/lib/square/api/apple_pay_api.rb +50 -0
  6. data/lib/square/api/bank_accounts_api.rb +136 -0
  7. data/lib/square/api/base_api.rb +43 -0
  8. data/lib/square/api/cash_drawers_api.rb +150 -0
  9. data/lib/square/api/catalog_api.rb +572 -0
  10. data/lib/square/api/checkout_api.rb +49 -0
  11. data/lib/square/api/customer_groups_api.rb +182 -0
  12. data/lib/square/api/customer_segments_api.rb +78 -0
  13. data/lib/square/api/customers_api.rb +418 -0
  14. data/lib/square/api/devices_api.rb +120 -0
  15. data/lib/square/api/disputes_api.rb +398 -0
  16. data/lib/square/api/employees_api.rb +87 -0
  17. data/lib/square/api/inventory_api.rb +296 -0
  18. data/lib/square/api/invoices_api.rb +358 -0
  19. data/lib/square/api/labor_api.rb +630 -0
  20. data/lib/square/api/locations_api.rb +151 -0
  21. data/lib/square/api/loyalty_api.rb +543 -0
  22. data/lib/square/api/merchants_api.rb +83 -0
  23. data/lib/square/api/mobile_authorization_api.rb +52 -0
  24. data/lib/square/api/o_auth_api.rb +163 -0
  25. data/lib/square/api/orders_api.rb +280 -0
  26. data/lib/square/api/payments_api.rb +279 -0
  27. data/lib/square/api/refunds_api.rb +145 -0
  28. data/lib/square/api/subscriptions_api.rb +251 -0
  29. data/lib/square/api/team_api.rb +326 -0
  30. data/lib/square/api/terminal_api.rb +141 -0
  31. data/lib/square/api/transactions_api.rb +369 -0
  32. data/lib/square/api/v1_employees_api.rb +723 -0
  33. data/lib/square/api/v1_items_api.rb +1686 -0
  34. data/lib/square/api/v1_locations_api.rb +65 -0
  35. data/lib/square/api/v1_transactions_api.rb +572 -0
  36. data/lib/square/api_helper.rb +276 -0
  37. data/lib/square/client.rb +211 -0
  38. data/lib/square/configuration.rb +101 -0
  39. data/lib/square/exceptions/api_exception.rb +15 -0
  40. data/lib/square/http/api_response.rb +45 -0
  41. data/lib/square/http/auth/o_auth2.rb +12 -0
  42. data/lib/square/http/faraday_client.rb +55 -0
  43. data/lib/square/http/http_call_back.rb +19 -0
  44. data/lib/square/http/http_client.rb +99 -0
  45. data/lib/square/http/http_method_enum.rb +8 -0
  46. data/lib/square/http/http_request.rb +45 -0
  47. data/lib/square/http/http_response.rb +24 -0
  48. data/lib/square/utilities/file_wrapper.rb +12 -0
  49. data/spec/user_journey_spec.rb +148 -0
  50. data/test/api/api_test_base.rb +24 -0
  51. data/test/api/test_catalog_api.rb +59 -0
  52. data/test/api/test_customers_api.rb +45 -0
  53. data/test/api/test_employees_api.rb +36 -0
  54. data/test/api/test_labor_api.rb +74 -0
  55. data/test/api/test_locations_api.rb +35 -0
  56. data/test/api/test_merchants_api.rb +40 -0
  57. data/test/api/test_payments_api.rb +42 -0
  58. data/test/api/test_refunds_api.rb +41 -0
  59. data/test/http_response_catcher.rb +19 -0
  60. data/test/test_helper.rb +94 -0
  61. metadata +199 -0
@@ -0,0 +1,572 @@
1
+ module Square
2
+ # CatalogApi
3
+ class CatalogApi < BaseApi
4
+ def initialize(config, http_call_back: nil)
5
+ super(config, http_call_back: http_call_back)
6
+ end
7
+
8
+ # Deletes a set of [CatalogItem](#type-catalogitem)s based on the
9
+ # provided list of target IDs and returns a set of successfully deleted IDs
10
+ # in
11
+ # the response. Deletion is a cascading event such that all children of the
12
+ # targeted object are also deleted. For example, deleting a CatalogItem will
13
+ # also delete all of its [CatalogItemVariation](#type-catalogitemvariation)
14
+ # children.
15
+ # `BatchDeleteCatalogObjects` succeeds even if only a portion of the
16
+ # targeted
17
+ # IDs can be deleted. The response will only include IDs that were
18
+ # actually deleted.
19
+ # @param [BatchDeleteCatalogObjectsRequest] body Required parameter: An
20
+ # object containing the fields to POST for the request. See the
21
+ # corresponding object definition for field details.
22
+ # @return [BatchDeleteCatalogObjectsResponse Hash] response from the API call
23
+ def batch_delete_catalog_objects(body:)
24
+ # Prepare query url.
25
+ _query_builder = config.get_base_uri
26
+ _query_builder << '/v2/catalog/batch-delete'
27
+ _query_url = APIHelper.clean_url _query_builder
28
+
29
+ # Prepare headers.
30
+ _headers = {
31
+ 'accept' => 'application/json',
32
+ 'content-type' => 'application/json; charset=utf-8'
33
+ }
34
+
35
+ # Prepare and execute HttpRequest.
36
+ _request = config.http_client.post(
37
+ _query_url,
38
+ headers: _headers,
39
+ parameters: body.to_json
40
+ )
41
+ OAuth2.apply(config, _request)
42
+ _response = execute_request(_request)
43
+
44
+ # Return appropriate response type.
45
+ decoded = APIHelper.json_deserialize(_response.raw_body)
46
+ _errors = APIHelper.map_response(decoded, ['errors'])
47
+ ApiResponse.new(_response, data: decoded, errors: _errors)
48
+ end
49
+
50
+ # Returns a set of objects based on the provided ID.
51
+ # Each [CatalogItem](#type-catalogitem) returned in the set includes all of
52
+ # its
53
+ # child information including: all of its
54
+ # [CatalogItemVariation](#type-catalogitemvariation) objects, references to
55
+ # its [CatalogModifierList](#type-catalogmodifierlist) objects, and the ids
56
+ # of
57
+ # any [CatalogTax](#type-catalogtax) objects that apply to it.
58
+ # @param [BatchRetrieveCatalogObjectsRequest] body Required parameter: An
59
+ # object containing the fields to POST for the request. See the
60
+ # corresponding object definition for field details.
61
+ # @return [BatchRetrieveCatalogObjectsResponse Hash] response from the API call
62
+ def batch_retrieve_catalog_objects(body:)
63
+ # Prepare query url.
64
+ _query_builder = config.get_base_uri
65
+ _query_builder << '/v2/catalog/batch-retrieve'
66
+ _query_url = APIHelper.clean_url _query_builder
67
+
68
+ # Prepare headers.
69
+ _headers = {
70
+ 'accept' => 'application/json',
71
+ 'content-type' => 'application/json; charset=utf-8'
72
+ }
73
+
74
+ # Prepare and execute HttpRequest.
75
+ _request = config.http_client.post(
76
+ _query_url,
77
+ headers: _headers,
78
+ parameters: body.to_json
79
+ )
80
+ OAuth2.apply(config, _request)
81
+ _response = execute_request(_request)
82
+
83
+ # Return appropriate response type.
84
+ decoded = APIHelper.json_deserialize(_response.raw_body)
85
+ _errors = APIHelper.map_response(decoded, ['errors'])
86
+ ApiResponse.new(_response, data: decoded, errors: _errors)
87
+ end
88
+
89
+ # Creates or updates up to 10,000 target objects based on the provided
90
+ # list of objects. The target objects are grouped into batches and each
91
+ # batch is
92
+ # inserted/updated in an all-or-nothing manner. If an object within a batch
93
+ # is
94
+ # malformed in some way, or violates a database constraint, the entire batch
95
+ # containing that item will be disregarded. However, other batches in the
96
+ # same
97
+ # request may still succeed. Each batch may contain up to 1,000 objects, and
98
+ # batches will be processed in order as long as the total object count for
99
+ # the
100
+ # request (items, variations, modifier lists, discounts, and taxes) is no
101
+ # more
102
+ # than 10,000.
103
+ # @param [BatchUpsertCatalogObjectsRequest] body Required parameter: An
104
+ # object containing the fields to POST for the request. See the
105
+ # corresponding object definition for field details.
106
+ # @return [BatchUpsertCatalogObjectsResponse Hash] response from the API call
107
+ def batch_upsert_catalog_objects(body:)
108
+ # Prepare query url.
109
+ _query_builder = config.get_base_uri
110
+ _query_builder << '/v2/catalog/batch-upsert'
111
+ _query_url = APIHelper.clean_url _query_builder
112
+
113
+ # Prepare headers.
114
+ _headers = {
115
+ 'accept' => 'application/json',
116
+ 'content-type' => 'application/json; charset=utf-8'
117
+ }
118
+
119
+ # Prepare and execute HttpRequest.
120
+ _request = config.http_client.post(
121
+ _query_url,
122
+ headers: _headers,
123
+ parameters: body.to_json
124
+ )
125
+ OAuth2.apply(config, _request)
126
+ _response = execute_request(_request)
127
+
128
+ # Return appropriate response type.
129
+ decoded = APIHelper.json_deserialize(_response.raw_body)
130
+ _errors = APIHelper.map_response(decoded, ['errors'])
131
+ ApiResponse.new(_response, data: decoded, errors: _errors)
132
+ end
133
+
134
+ # Uploads an image file to be represented by an
135
+ # [CatalogImage](#type-catalogimage) object linked to an existing
136
+ # [CatalogObject](#type-catalogobject) instance. A call to this endpoint can
137
+ # upload an image, link an image to
138
+ # a catalog object, or do both.
139
+ # This `CreateCatalogImage` endpoint accepts HTTP multipart/form-data
140
+ # requests with a JSON part and an image file part in
141
+ # JPEG, PJPEG, PNG, or GIF format. The maximum file size is 15MB.
142
+ # Additional information and an example cURL request can be found in the
143
+ # [Create a Catalog Image
144
+ # recipe](https://developer.squareup.com/docs/more-apis/catalog/cookbook/cre
145
+ # ate-catalog-images).
146
+ # @param [CreateCatalogImageRequest] request Optional parameter: Example:
147
+ # @param [File | UploadIO] image_file Optional parameter: Example:
148
+ # @return [CreateCatalogImageResponse Hash] response from the API call
149
+ def create_catalog_image(request: nil,
150
+ image_file: nil)
151
+ # Prepare query url.
152
+ _query_builder = config.get_base_uri
153
+ _query_builder << '/v2/catalog/images'
154
+ _query_url = APIHelper.clean_url _query_builder
155
+
156
+ if image_file.is_a? FileWrapper
157
+ image_file_wrapper = image_file.file
158
+ image_file_content_type = image_file.content_type
159
+ else
160
+ image_file_wrapper = image_file
161
+ image_file_content_type = 'image/jpeg'
162
+ end
163
+
164
+ # Prepare headers.
165
+ _headers = {
166
+ 'accept' => 'application/json'
167
+ }
168
+
169
+ # Prepare form parameters.
170
+ _parameters = {
171
+ 'request' => Faraday::UploadIO.new(
172
+ StringIO.new(request.to_json),
173
+ 'application/json'
174
+ ),
175
+ 'image_file' => Faraday::UploadIO.new(
176
+ image_file_wrapper,
177
+ image_file_content_type
178
+ )
179
+ }
180
+ _parameters = APIHelper.form_encode_parameters(_parameters)
181
+
182
+ # Prepare and execute HttpRequest.
183
+ _request = config.http_client.post(
184
+ _query_url,
185
+ headers: _headers,
186
+ parameters: _parameters
187
+ )
188
+ OAuth2.apply(config, _request)
189
+ _response = execute_request(_request)
190
+
191
+ # Return appropriate response type.
192
+ decoded = APIHelper.json_deserialize(_response.raw_body)
193
+ _errors = APIHelper.map_response(decoded, ['errors'])
194
+ ApiResponse.new(_response, data: decoded, errors: _errors)
195
+ end
196
+
197
+ # Retrieves information about the Square Catalog API, such as batch size
198
+ # limits that can be used by the `BatchUpsertCatalogObjects` endpoint.
199
+ # @return [CatalogInfoResponse Hash] response from the API call
200
+ def catalog_info
201
+ # Prepare query url.
202
+ _query_builder = config.get_base_uri
203
+ _query_builder << '/v2/catalog/info'
204
+ _query_url = APIHelper.clean_url _query_builder
205
+
206
+ # Prepare headers.
207
+ _headers = {
208
+ 'accept' => 'application/json'
209
+ }
210
+
211
+ # Prepare and execute HttpRequest.
212
+ _request = config.http_client.get(
213
+ _query_url,
214
+ headers: _headers
215
+ )
216
+ OAuth2.apply(config, _request)
217
+ _response = execute_request(_request)
218
+
219
+ # Return appropriate response type.
220
+ decoded = APIHelper.json_deserialize(_response.raw_body)
221
+ _errors = APIHelper.map_response(decoded, ['errors'])
222
+ ApiResponse.new(_response, data: decoded, errors: _errors)
223
+ end
224
+
225
+ # Returns a list of [CatalogObject](#type-catalogobject)s that includes
226
+ # all objects of a set of desired types (for example, all
227
+ # [CatalogItem](#type-catalogitem)
228
+ # and [CatalogTax](#type-catalogtax) objects) in the catalog. The `types`
229
+ # parameter
230
+ # is specified as a comma-separated list of valid
231
+ # [CatalogObject](#type-catalogobject) types:
232
+ # `ITEM`, `ITEM_VARIATION`, `MODIFIER`, `MODIFIER_LIST`, `CATEGORY`,
233
+ # `DISCOUNT`, `TAX`, `IMAGE`.
234
+ # __Important:__ ListCatalog does not return deleted catalog items. To
235
+ # retrieve
236
+ # deleted catalog items, use SearchCatalogObjects and set
237
+ # `include_deleted_objects`
238
+ # to `true`.
239
+ # @param [String] cursor Optional parameter: The pagination cursor returned
240
+ # in the previous response. Leave unset for an initial request. See
241
+ # [Pagination](https://developer.squareup.com/docs/basics/api101/pagination)
242
+ # for more information.
243
+ # @param [String] types Optional parameter: An optional case-insensitive,
244
+ # comma-separated list of object types to retrieve, for example
245
+ # `ITEM,ITEM_VARIATION,CATEGORY,IMAGE`. The legal values are taken from the
246
+ # CatalogObjectType enum: `ITEM`, `ITEM_VARIATION`, `CATEGORY`, `DISCOUNT`,
247
+ # `TAX`, `MODIFIER`, `MODIFIER_LIST`, or `IMAGE`.
248
+ # @return [ListCatalogResponse Hash] response from the API call
249
+ def list_catalog(cursor: nil,
250
+ types: nil)
251
+ # Prepare query url.
252
+ _query_builder = config.get_base_uri
253
+ _query_builder << '/v2/catalog/list'
254
+ _query_builder = APIHelper.append_url_with_query_parameters(
255
+ _query_builder,
256
+ 'cursor' => cursor,
257
+ 'types' => types
258
+ )
259
+ _query_url = APIHelper.clean_url _query_builder
260
+
261
+ # Prepare headers.
262
+ _headers = {
263
+ 'accept' => 'application/json'
264
+ }
265
+
266
+ # Prepare and execute HttpRequest.
267
+ _request = config.http_client.get(
268
+ _query_url,
269
+ headers: _headers
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(_response, data: decoded, errors: _errors)
278
+ end
279
+
280
+ # Creates or updates the target [CatalogObject](#type-catalogobject).
281
+ # @param [UpsertCatalogObjectRequest] body Required parameter: An object
282
+ # containing the fields to POST for the request. See the corresponding
283
+ # object definition for field details.
284
+ # @return [UpsertCatalogObjectResponse Hash] response from the API call
285
+ def upsert_catalog_object(body:)
286
+ # Prepare query url.
287
+ _query_builder = config.get_base_uri
288
+ _query_builder << '/v2/catalog/object'
289
+ _query_url = APIHelper.clean_url _query_builder
290
+
291
+ # Prepare headers.
292
+ _headers = {
293
+ 'accept' => 'application/json',
294
+ 'content-type' => 'application/json; charset=utf-8'
295
+ }
296
+
297
+ # Prepare and execute HttpRequest.
298
+ _request = config.http_client.post(
299
+ _query_url,
300
+ headers: _headers,
301
+ parameters: body.to_json
302
+ )
303
+ OAuth2.apply(config, _request)
304
+ _response = execute_request(_request)
305
+
306
+ # Return appropriate response type.
307
+ decoded = APIHelper.json_deserialize(_response.raw_body)
308
+ _errors = APIHelper.map_response(decoded, ['errors'])
309
+ ApiResponse.new(_response, data: decoded, errors: _errors)
310
+ end
311
+
312
+ # Deletes a single [CatalogObject](#type-catalogobject) based on the
313
+ # provided ID and returns the set of successfully deleted IDs in the
314
+ # response.
315
+ # Deletion is a cascading event such that all children of the targeted
316
+ # object
317
+ # are also deleted. For example, deleting a [CatalogItem](#type-catalogitem)
318
+ # will also delete all of its
319
+ # [CatalogItemVariation](#type-catalogitemvariation) children.
320
+ # @param [String] object_id Required parameter: The ID of the catalog object
321
+ # to be deleted. When an object is deleted, other objects in the graph that
322
+ # depend on that object will be deleted as well (for example, deleting a
323
+ # catalog item will delete its catalog item variations).
324
+ # @return [DeleteCatalogObjectResponse Hash] response from the API call
325
+ def delete_catalog_object(object_id:)
326
+ # Prepare query url.
327
+ _query_builder = config.get_base_uri
328
+ _query_builder << '/v2/catalog/object/{object_id}'
329
+ _query_builder = APIHelper.append_url_with_template_parameters(
330
+ _query_builder,
331
+ 'object_id' => object_id
332
+ )
333
+ _query_url = APIHelper.clean_url _query_builder
334
+
335
+ # Prepare headers.
336
+ _headers = {
337
+ 'accept' => 'application/json'
338
+ }
339
+
340
+ # Prepare and execute HttpRequest.
341
+ _request = config.http_client.delete(
342
+ _query_url,
343
+ headers: _headers
344
+ )
345
+ OAuth2.apply(config, _request)
346
+ _response = execute_request(_request)
347
+
348
+ # Return appropriate response type.
349
+ decoded = APIHelper.json_deserialize(_response.raw_body)
350
+ _errors = APIHelper.map_response(decoded, ['errors'])
351
+ ApiResponse.new(_response, data: decoded, errors: _errors)
352
+ end
353
+
354
+ # Returns a single [CatalogItem](#type-catalogitem) as a
355
+ # [CatalogObject](#type-catalogobject) based on the provided ID. The
356
+ # returned
357
+ # object includes all of the relevant [CatalogItem](#type-catalogitem)
358
+ # information including: [CatalogItemVariation](#type-catalogitemvariation)
359
+ # children, references to its
360
+ # [CatalogModifierList](#type-catalogmodifierlist) objects, and the ids of
361
+ # any [CatalogTax](#type-catalogtax) objects that apply to it.
362
+ # @param [String] object_id Required parameter: The object ID of any type of
363
+ # catalog objects to be retrieved.
364
+ # @param [Boolean] include_related_objects Optional parameter: If `true`,
365
+ # the response will include additional objects that are related to the
366
+ # requested object, as follows: If the `object` field of the response
367
+ # contains a CatalogItem, its associated CatalogCategory, CatalogTax
368
+ # objects, CatalogImages and CatalogModifierLists will be returned in the
369
+ # `related_objects` field of the response. If the `object` field of the
370
+ # response contains a CatalogItemVariation, its parent CatalogItem will be
371
+ # returned in the `related_objects` field of the response. Default value:
372
+ # `false`
373
+ # @return [RetrieveCatalogObjectResponse Hash] response from the API call
374
+ def retrieve_catalog_object(object_id:,
375
+ include_related_objects: false)
376
+ # Prepare query url.
377
+ _query_builder = config.get_base_uri
378
+ _query_builder << '/v2/catalog/object/{object_id}'
379
+ _query_builder = APIHelper.append_url_with_template_parameters(
380
+ _query_builder,
381
+ 'object_id' => object_id
382
+ )
383
+ _query_builder = APIHelper.append_url_with_query_parameters(
384
+ _query_builder,
385
+ 'include_related_objects' => include_related_objects
386
+ )
387
+ _query_url = APIHelper.clean_url _query_builder
388
+
389
+ # Prepare headers.
390
+ _headers = {
391
+ 'accept' => 'application/json'
392
+ }
393
+
394
+ # Prepare and execute HttpRequest.
395
+ _request = config.http_client.get(
396
+ _query_url,
397
+ headers: _headers
398
+ )
399
+ OAuth2.apply(config, _request)
400
+ _response = execute_request(_request)
401
+
402
+ # Return appropriate response type.
403
+ decoded = APIHelper.json_deserialize(_response.raw_body)
404
+ _errors = APIHelper.map_response(decoded, ['errors'])
405
+ ApiResponse.new(_response, data: decoded, errors: _errors)
406
+ end
407
+
408
+ # Searches for [CatalogObject](#type-CatalogObject) of any types against
409
+ # supported search attribute values,
410
+ # excluding custom attribute values on items or item variations, against one
411
+ # or more of the specified query expressions,
412
+ # This (`SearchCatalogObjects`) endpoint differs from the
413
+ # [SearchCatalogItems](#endpoint-Catalog-SearchCatalogItems)
414
+ # endpoint in the following aspects:
415
+ # - `SearchCatalogItems` can only search for items or item variations,
416
+ # whereas `SearchCatalogObjects` can search for any type of catalog objects.
417
+ # - `SearchCatalogItems` supports the custom attribute query filters to
418
+ # return items or item variations that contain custom attribute values,
419
+ # where `SearchCatalogObjects` does not.
420
+ # - `SearchCatalogItems` does not support the `include_deleted_objects`
421
+ # filter to search for deleted items or item variations, whereas
422
+ # `SearchCatalogObjects` does.
423
+ # - The both endpoints have different call conventions, including the query
424
+ # filter formats.
425
+ # @param [SearchCatalogObjectsRequest] body Required parameter: An object
426
+ # containing the fields to POST for the request. See the corresponding
427
+ # object definition for field details.
428
+ # @return [SearchCatalogObjectsResponse Hash] response from the API call
429
+ def search_catalog_objects(body:)
430
+ # Prepare query url.
431
+ _query_builder = config.get_base_uri
432
+ _query_builder << '/v2/catalog/search'
433
+ _query_url = APIHelper.clean_url _query_builder
434
+
435
+ # Prepare headers.
436
+ _headers = {
437
+ 'accept' => 'application/json',
438
+ 'content-type' => 'application/json; charset=utf-8'
439
+ }
440
+
441
+ # Prepare and execute HttpRequest.
442
+ _request = config.http_client.post(
443
+ _query_url,
444
+ headers: _headers,
445
+ parameters: body.to_json
446
+ )
447
+ OAuth2.apply(config, _request)
448
+ _response = execute_request(_request)
449
+
450
+ # Return appropriate response type.
451
+ decoded = APIHelper.json_deserialize(_response.raw_body)
452
+ _errors = APIHelper.map_response(decoded, ['errors'])
453
+ ApiResponse.new(_response, data: decoded, errors: _errors)
454
+ end
455
+
456
+ # Searches for catalog items or item variations by matching supported search
457
+ # attribute values, including
458
+ # custom attribute values, against one or more of the specified query
459
+ # expressions,
460
+ # This (`SearchCatalogItems`) endpoint differs from the
461
+ # [SearchCatalogObjects](#endpoint-Catalog-SearchCatalogObjects)
462
+ # endpoint in the following aspects:
463
+ # - `SearchCatalogItems` can only search for items or item variations,
464
+ # whereas `SearchCatalogObjects` can search for any type of catalog objects.
465
+ # - `SearchCatalogItems` supports the custom attribute query filters to
466
+ # return items or item variations that contain custom attribute values,
467
+ # where `SearchCatalogObjects` does not.
468
+ # - `SearchCatalogItems` does not support the `include_deleted_objects`
469
+ # filter to search for deleted items or item variations, whereas
470
+ # `SearchCatalogObjects` does.
471
+ # - The both endpoints use different call conventions, including the query
472
+ # filter formats.
473
+ # @param [SearchCatalogItemsRequest] body Required parameter: An object
474
+ # containing the fields to POST for the request. See the corresponding
475
+ # object definition for field details.
476
+ # @return [SearchCatalogItemsResponse Hash] response from the API call
477
+ def search_catalog_items(body:)
478
+ # Prepare query url.
479
+ _query_builder = config.get_base_uri
480
+ _query_builder << '/v2/catalog/search-catalog-items'
481
+ _query_url = APIHelper.clean_url _query_builder
482
+
483
+ # Prepare headers.
484
+ _headers = {
485
+ 'accept' => 'application/json',
486
+ 'content-type' => 'application/json; charset=utf-8'
487
+ }
488
+
489
+ # Prepare and execute HttpRequest.
490
+ _request = config.http_client.post(
491
+ _query_url,
492
+ headers: _headers,
493
+ parameters: body.to_json
494
+ )
495
+ OAuth2.apply(config, _request)
496
+ _response = execute_request(_request)
497
+
498
+ # Return appropriate response type.
499
+ decoded = APIHelper.json_deserialize(_response.raw_body)
500
+ _errors = APIHelper.map_response(decoded, ['errors'])
501
+ ApiResponse.new(_response, data: decoded, errors: _errors)
502
+ end
503
+
504
+ # Updates the [CatalogModifierList](#type-catalogmodifierlist) objects
505
+ # that apply to the targeted [CatalogItem](#type-catalogitem) without having
506
+ # to perform an upsert on the entire item.
507
+ # @param [UpdateItemModifierListsRequest] body Required parameter: An object
508
+ # containing the fields to POST for the request. See the corresponding
509
+ # object definition for field details.
510
+ # @return [UpdateItemModifierListsResponse Hash] response from the API call
511
+ def update_item_modifier_lists(body:)
512
+ # Prepare query url.
513
+ _query_builder = config.get_base_uri
514
+ _query_builder << '/v2/catalog/update-item-modifier-lists'
515
+ _query_url = APIHelper.clean_url _query_builder
516
+
517
+ # Prepare headers.
518
+ _headers = {
519
+ 'accept' => 'application/json',
520
+ 'content-type' => 'application/json; charset=utf-8'
521
+ }
522
+
523
+ # Prepare and execute HttpRequest.
524
+ _request = config.http_client.post(
525
+ _query_url,
526
+ headers: _headers,
527
+ parameters: body.to_json
528
+ )
529
+ OAuth2.apply(config, _request)
530
+ _response = execute_request(_request)
531
+
532
+ # Return appropriate response type.
533
+ decoded = APIHelper.json_deserialize(_response.raw_body)
534
+ _errors = APIHelper.map_response(decoded, ['errors'])
535
+ ApiResponse.new(_response, data: decoded, errors: _errors)
536
+ end
537
+
538
+ # Updates the [CatalogTax](#type-catalogtax) objects that apply to the
539
+ # targeted [CatalogItem](#type-catalogitem) without having to perform an
540
+ # upsert on the entire item.
541
+ # @param [UpdateItemTaxesRequest] body Required parameter: An object
542
+ # containing the fields to POST for the request. See the corresponding
543
+ # object definition for field details.
544
+ # @return [UpdateItemTaxesResponse Hash] response from the API call
545
+ def update_item_taxes(body:)
546
+ # Prepare query url.
547
+ _query_builder = config.get_base_uri
548
+ _query_builder << '/v2/catalog/update-item-taxes'
549
+ _query_url = APIHelper.clean_url _query_builder
550
+
551
+ # Prepare headers.
552
+ _headers = {
553
+ 'accept' => 'application/json',
554
+ 'content-type' => 'application/json; charset=utf-8'
555
+ }
556
+
557
+ # Prepare and execute HttpRequest.
558
+ _request = config.http_client.post(
559
+ _query_url,
560
+ headers: _headers,
561
+ parameters: body.to_json
562
+ )
563
+ OAuth2.apply(config, _request)
564
+ _response = execute_request(_request)
565
+
566
+ # Return appropriate response type.
567
+ decoded = APIHelper.json_deserialize(_response.raw_body)
568
+ _errors = APIHelper.map_response(decoded, ['errors'])
569
+ ApiResponse.new(_response, data: decoded, errors: _errors)
570
+ end
571
+ end
572
+ end