square.rb 3.20190624.0 → 3.20190814.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +10 -28
  3. data/README.md +281 -17235
  4. data/lib/square/api/apple_pay_api.rb +55 -54
  5. data/lib/square/api/base_api.rb +45 -45
  6. data/lib/square/api/catalog_api.rb +461 -460
  7. data/lib/square/api/checkout_api.rb +54 -54
  8. data/lib/square/api/customers_api.rb +335 -334
  9. data/lib/square/api/employees_api.rb +91 -91
  10. data/lib/square/api/inventory_api.rb +300 -298
  11. data/lib/square/api/labor_api.rb +558 -558
  12. data/lib/square/api/locations_api.rb +45 -45
  13. data/lib/square/api/mobile_authorization_api.rb +56 -56
  14. data/lib/square/api/o_auth_api.rb +168 -164
  15. data/lib/square/api/orders_api.rb +269 -151
  16. data/lib/square/api/payments_api.rb +282 -0
  17. data/lib/square/api/refunds_api.rb +149 -0
  18. data/lib/square/api/reporting_api.rb +143 -139
  19. data/lib/square/api/transactions_api.rb +379 -360
  20. data/lib/square/api/v1_employees_api.rb +720 -720
  21. data/lib/square/api/v1_items_api.rb +1651 -1651
  22. data/lib/square/api/v1_locations_api.rb +67 -67
  23. data/lib/square/api/v1_locations_api.rbe +67 -0
  24. data/lib/square/api/v1_transactions_api.rb +574 -574
  25. data/lib/square/api_helper.rb +281 -277
  26. data/lib/square/client.rb +139 -127
  27. data/lib/square/configuration.rb +88 -85
  28. data/lib/square/exceptions/api_exception.rb +20 -20
  29. data/lib/square/http/api_response.rb +50 -50
  30. data/lib/square/http/auth/o_auth2.rb +17 -17
  31. data/lib/square/http/faraday_client.rb +64 -64
  32. data/lib/square/http/http_call_back.rb +24 -24
  33. data/lib/square/http/http_client.rb +104 -104
  34. data/lib/square/http/http_method_enum.rb +13 -13
  35. data/lib/square/http/http_request.rb +50 -50
  36. data/lib/square/http/http_response.rb +29 -29
  37. data/lib/square.rb +52 -50
  38. data/spec/user_journey_spec.rb +4 -1
  39. data/test/api/api_test_base.rb +2 -1
  40. data/test/api/test_catalog_api.rb +59 -0
  41. data/test/api/test_employees_api.rb +36 -0
  42. data/test/api/test_locations_api.rb +35 -0
  43. data/test/api/test_payments_api.rb +42 -0
  44. data/test/api/test_refunds_api.rb +41 -0
  45. metadata +19 -11
@@ -1,460 +1,461 @@
1
- # square
2
- #
3
- # This file was automatically generated by APIMATIC v2.0
4
- # ( https://apimatic.io ).
5
-
6
- module Square
7
- # CatalogApi
8
- class CatalogApi < BaseApi
9
- def initialize(config, http_call_back: nil)
10
- super(config, http_call_back: http_call_back)
11
- end
12
-
13
- # Deletes a set of [CatalogItem](#type-catalogitem)s based on the
14
- # provided list of target IDs and returns a set of successfully deleted IDs
15
- # in
16
- # the response. Deletion is a cascading event such that all children of the
17
- # targeted object are also deleted. For example, deleting a CatalogItem will
18
- # also delete all of its [CatalogItemVariation](#type-catalogitemvariation)
19
- # children.
20
- # `BatchDeleteCatalogObjects` succeeds even if only a portion of the
21
- # targeted
22
- # IDs can be deleted. The response will only include IDs that were
23
- # actually deleted.
24
- # @param [BatchDeleteCatalogObjectsRequest] body Required parameter: An
25
- # object containing the fields to POST for the request. See the
26
- # corresponding object definition for field details.
27
- # @return [BatchDeleteCatalogObjectsResponse Hash] response from the API call
28
- def batch_delete_catalog_objects(body:)
29
- # Prepare query url.
30
- _query_builder = config.get_base_uri
31
- _query_builder << '/v2/catalog/batch-delete'
32
- _query_url = APIHelper.clean_url _query_builder
33
-
34
- # Prepare headers.
35
- _headers = {
36
- 'accept' => 'application/json',
37
- 'content-type' => 'application/json; charset=utf-8'
38
- }
39
-
40
- # Prepare and execute HttpRequest.
41
- _request = config.http_client.post(
42
- _query_url,
43
- headers: _headers,
44
- parameters: body.to_json
45
- )
46
- OAuth2.apply(config, _request)
47
- _response = execute_request(_request)
48
-
49
- # Return appropriate response type.
50
- decoded = APIHelper.json_deserialize(_response.raw_body)
51
- _errors = APIHelper.map_response(decoded, ['errors'])
52
- ApiResponse.new(_response, data: decoded, errors: _errors)
53
- end
54
-
55
- # Returns a set of objects based on the provided ID.
56
- # Each [CatalogItem](#type-catalogitem) returned in the set includes all of
57
- # its
58
- # child information including: all of its
59
- # [CatalogItemVariation](#type-catalogitemvariation) objects, references to
60
- # its [CatalogModifierList](#type-catalogmodifierlist) objects, and the ids
61
- # of
62
- # any [CatalogTax](#type-catalogtax) objects that apply to it.
63
- # @param [BatchRetrieveCatalogObjectsRequest] body Required parameter: An
64
- # object containing the fields to POST for the request. See the
65
- # corresponding object definition for field details.
66
- # @return [BatchRetrieveCatalogObjectsResponse Hash] response from the API call
67
- def batch_retrieve_catalog_objects(body:)
68
- # Prepare query url.
69
- _query_builder = config.get_base_uri
70
- _query_builder << '/v2/catalog/batch-retrieve'
71
- _query_url = APIHelper.clean_url _query_builder
72
-
73
- # Prepare headers.
74
- _headers = {
75
- 'accept' => 'application/json',
76
- 'content-type' => 'application/json; charset=utf-8'
77
- }
78
-
79
- # Prepare and execute HttpRequest.
80
- _request = config.http_client.post(
81
- _query_url,
82
- headers: _headers,
83
- parameters: body.to_json
84
- )
85
- OAuth2.apply(config, _request)
86
- _response = execute_request(_request)
87
-
88
- # Return appropriate response type.
89
- decoded = APIHelper.json_deserialize(_response.raw_body)
90
- _errors = APIHelper.map_response(decoded, ['errors'])
91
- ApiResponse.new(_response, data: decoded, errors: _errors)
92
- end
93
-
94
- # Creates or updates up to 10,000 target objects based on the provided
95
- # list of objects. The target objects are grouped into batches and each
96
- # batch is
97
- # inserted/updated in an all-or-nothing manner. If an object within a batch
98
- # is
99
- # malformed in some way, or violates a database constraint, the entire batch
100
- # containing that item will be disregarded. However, other batches in the
101
- # same
102
- # request may still succeed. Each batch may contain up to 1,000 objects, and
103
- # batches will be processed in order as long as the total object count for
104
- # the
105
- # request (items, variations, modifier lists, discounts, and taxes) is no
106
- # more
107
- # than 10,000.
108
- # @param [BatchUpsertCatalogObjectsRequest] body Required parameter: An
109
- # object containing the fields to POST for the request. See the
110
- # corresponding object definition for field details.
111
- # @return [BatchUpsertCatalogObjectsResponse Hash] response from the API call
112
- def batch_upsert_catalog_objects(body:)
113
- # Prepare query url.
114
- _query_builder = config.get_base_uri
115
- _query_builder << '/v2/catalog/batch-upsert'
116
- _query_url = APIHelper.clean_url _query_builder
117
-
118
- # Prepare headers.
119
- _headers = {
120
- 'accept' => 'application/json',
121
- 'content-type' => 'application/json; charset=utf-8'
122
- }
123
-
124
- # Prepare and execute HttpRequest.
125
- _request = config.http_client.post(
126
- _query_url,
127
- headers: _headers,
128
- parameters: body.to_json
129
- )
130
- OAuth2.apply(config, _request)
131
- _response = execute_request(_request)
132
-
133
- # Return appropriate response type.
134
- decoded = APIHelper.json_deserialize(_response.raw_body)
135
- _errors = APIHelper.map_response(decoded, ['errors'])
136
- ApiResponse.new(_response, data: decoded, errors: _errors)
137
- end
138
-
139
- # Returns information about the Square Catalog API, such as batch size
140
- # limits for `BatchUpsertCatalogObjects`.
141
- # @return [CatalogInfoResponse Hash] response from the API call
142
- def catalog_info
143
- # Prepare query url.
144
- _query_builder = config.get_base_uri
145
- _query_builder << '/v2/catalog/info'
146
- _query_url = APIHelper.clean_url _query_builder
147
-
148
- # Prepare headers.
149
- _headers = {
150
- 'accept' => 'application/json'
151
- }
152
-
153
- # Prepare and execute HttpRequest.
154
- _request = config.http_client.get(
155
- _query_url,
156
- headers: _headers
157
- )
158
- OAuth2.apply(config, _request)
159
- _response = execute_request(_request)
160
-
161
- # Return appropriate response type.
162
- decoded = APIHelper.json_deserialize(_response.raw_body)
163
- _errors = APIHelper.map_response(decoded, ['errors'])
164
- ApiResponse.new(_response, data: decoded, errors: _errors)
165
- end
166
-
167
- # Returns a list of [CatalogObject](#type-catalogobject)s that includes
168
- # all objects of a set of desired types (for example, all
169
- # [CatalogItem](#type-catalogitem)
170
- # and [CatalogTax](#type-catalogtax) objects) in the catalog. The `types`
171
- # parameter
172
- # is specified as a comma-separated list of valid
173
- # [CatalogObject](#type-catalogobject) types:
174
- # `ITEM`, `ITEM_VARIATION`, `MODIFIER`, `MODIFIER_LIST`, `CATEGORY`,
175
- # `DISCOUNT`, `TAX`.
176
- # __Important:__ ListCatalog does not return deleted catalog items. To
177
- # retrieve
178
- # deleted catalog items, use SearchCatalogObjects and set
179
- # `include_deleted_objects`
180
- # to `true`.
181
- # @param [String] cursor Optional parameter: The pagination cursor returned
182
- # in the previous response. Leave unset for an initial request. See
183
- # [Pagination](/basics/api101/pagination) for more information.
184
- # @param [String] types Optional parameter: An optional case-insensitive,
185
- # comma-separated list of object types to retrieve, for example
186
- # `ITEM,ITEM_VARIATION,CATEGORY,IMAGE`. The legal values are taken from the
187
- # [CatalogObjectType](#type-catalogobjecttype) enumeration, namely `ITEM`,
188
- # `ITEM_VARIATION`, `CATEGORY`, `DISCOUNT`, `TAX`, `MODIFIER`,
189
- # `MODIFIER_LIST`, or `IMAGE`.
190
- # @return [ListCatalogResponse Hash] response from the API call
191
- def list_catalog(cursor: nil,
192
- types: nil)
193
- # Prepare query url.
194
- _query_builder = config.get_base_uri
195
- _query_builder << '/v2/catalog/list'
196
- _query_builder = APIHelper.append_url_with_query_parameters(
197
- _query_builder,
198
- 'cursor' => cursor,
199
- 'types' => types
200
- )
201
- _query_url = APIHelper.clean_url _query_builder
202
-
203
- # Prepare headers.
204
- _headers = {
205
- 'accept' => 'application/json'
206
- }
207
-
208
- # Prepare and execute HttpRequest.
209
- _request = config.http_client.get(
210
- _query_url,
211
- headers: _headers
212
- )
213
- OAuth2.apply(config, _request)
214
- _response = execute_request(_request)
215
-
216
- # Return appropriate response type.
217
- decoded = APIHelper.json_deserialize(_response.raw_body)
218
- _errors = APIHelper.map_response(decoded, ['errors'])
219
- ApiResponse.new(_response, data: decoded, errors: _errors)
220
- end
221
-
222
- # Creates or updates the target [CatalogObject](#type-catalogobject).
223
- # @param [UpsertCatalogObjectRequest] body Required parameter: An object
224
- # containing the fields to POST for the request. See the corresponding
225
- # object definition for field details.
226
- # @return [UpsertCatalogObjectResponse Hash] response from the API call
227
- def upsert_catalog_object(body:)
228
- # Prepare query url.
229
- _query_builder = config.get_base_uri
230
- _query_builder << '/v2/catalog/object'
231
- _query_url = APIHelper.clean_url _query_builder
232
-
233
- # Prepare headers.
234
- _headers = {
235
- 'accept' => 'application/json',
236
- 'content-type' => 'application/json; charset=utf-8'
237
- }
238
-
239
- # Prepare and execute HttpRequest.
240
- _request = config.http_client.post(
241
- _query_url,
242
- headers: _headers,
243
- parameters: body.to_json
244
- )
245
- OAuth2.apply(config, _request)
246
- _response = execute_request(_request)
247
-
248
- # Return appropriate response type.
249
- decoded = APIHelper.json_deserialize(_response.raw_body)
250
- _errors = APIHelper.map_response(decoded, ['errors'])
251
- ApiResponse.new(_response, data: decoded, errors: _errors)
252
- end
253
-
254
- # Deletes a single [CatalogObject](#type-catalogobject) based on the
255
- # provided ID and returns the set of successfully deleted IDs in the
256
- # response.
257
- # Deletion is a cascading event such that all children of the targeted
258
- # object
259
- # are also deleted. For example, deleting a [CatalogItem](#type-catalogitem)
260
- # will also delete all of its
261
- # [CatalogItemVariation](#type-catalogitemvariation) children.
262
- # @param [String] object_id Required parameter: The ID of the
263
- # [CatalogObject](#type-catalogobject) to be deleted. When an object is
264
- # deleted, other objects in the graph that depend on that object will be
265
- # deleted as well (for example, deleting a [CatalogItem](#type-catalogitem)
266
- # will delete its [CatalogItemVariation](#type-catalogitemvariation)s).
267
- # @return [DeleteCatalogObjectResponse Hash] response from the API call
268
- def delete_catalog_object(object_id:)
269
- # Prepare query url.
270
- _query_builder = config.get_base_uri
271
- _query_builder << '/v2/catalog/object/{object_id}'
272
- _query_builder = APIHelper.append_url_with_template_parameters(
273
- _query_builder,
274
- 'object_id' => object_id
275
- )
276
- _query_url = APIHelper.clean_url _query_builder
277
-
278
- # Prepare headers.
279
- _headers = {
280
- 'accept' => 'application/json'
281
- }
282
-
283
- # Prepare and execute HttpRequest.
284
- _request = config.http_client.delete(
285
- _query_url,
286
- headers: _headers
287
- )
288
- OAuth2.apply(config, _request)
289
- _response = execute_request(_request)
290
-
291
- # Return appropriate response type.
292
- decoded = APIHelper.json_deserialize(_response.raw_body)
293
- _errors = APIHelper.map_response(decoded, ['errors'])
294
- ApiResponse.new(_response, data: decoded, errors: _errors)
295
- end
296
-
297
- # Returns a single [CatalogItem](#type-catalogitem) as a
298
- # [CatalogObject](#type-catalogobject) based on the provided ID. The
299
- # returned
300
- # object includes all of the relevant [CatalogItem](#type-catalogitem)
301
- # information including: [CatalogItemVariation](#type-catalogitemvariation)
302
- # children, references to its
303
- # [CatalogModifierList](#type-catalogmodifierlist) objects, and the ids of
304
- # any [CatalogTax](#type-catalogtax) objects that apply to it.
305
- # @param [String] object_id Required parameter: The object ID of any type of
306
- # [CatalogObject](#type-catalogobject)s to be retrieved.
307
- # @param [Boolean] include_related_objects Optional parameter: If `true`,
308
- # the response will include additional objects that are related to the
309
- # requested object, as follows: If the `object` field of the response
310
- # contains a [CatalogItem](#type-catalogitem), its associated
311
- # [CatalogCategory](#type-catalogcategory),
312
- # [CatalogTax](#type-catalogtax)es, [CatalogImage](#type-catalogimage)s and
313
- # [CatalogModifierList](#type-catalogmodifierlist)s will be returned in the
314
- # `related_objects` field of the response. If the `object` field of the
315
- # response contains a [CatalogItemVariation](#type-catalogitemvariation),
316
- # its parent [CatalogItem](#type-catalogitem) will be returned in the
317
- # `related_objects` field of the response. Default value: `false`
318
- # @return [RetrieveCatalogObjectResponse Hash] response from the API call
319
- def retrieve_catalog_object(object_id:,
320
- include_related_objects: nil)
321
- # Prepare query url.
322
- _query_builder = config.get_base_uri
323
- _query_builder << '/v2/catalog/object/{object_id}'
324
- _query_builder = APIHelper.append_url_with_template_parameters(
325
- _query_builder,
326
- 'object_id' => object_id
327
- )
328
- _query_builder = APIHelper.append_url_with_query_parameters(
329
- _query_builder,
330
- 'include_related_objects' => include_related_objects
331
- )
332
- _query_url = APIHelper.clean_url _query_builder
333
-
334
- # Prepare headers.
335
- _headers = {
336
- 'accept' => 'application/json'
337
- }
338
-
339
- # Prepare and execute HttpRequest.
340
- _request = config.http_client.get(
341
- _query_url,
342
- headers: _headers
343
- )
344
- OAuth2.apply(config, _request)
345
- _response = execute_request(_request)
346
-
347
- # Return appropriate response type.
348
- decoded = APIHelper.json_deserialize(_response.raw_body)
349
- _errors = APIHelper.map_response(decoded, ['errors'])
350
- ApiResponse.new(_response, data: decoded, errors: _errors)
351
- end
352
-
353
- # Queries the targeted catalog using a variety of query types:
354
- # [CatalogQuerySortedAttribute](#type-catalogquerysortedattribute),
355
- # [CatalogQueryExact](#type-catalogqueryexact),
356
- # [CatalogQueryRange](#type-catalogqueryrange),
357
- # [CatalogQueryText](#type-catalogquerytext),
358
- # [CatalogQueryItemsForTax](#type-catalogqueryitemsfortax), and
359
- # [CatalogQueryItemsForModifierList](#type-catalogqueryitemsformodifierlist)
360
- # .
361
- # @param [SearchCatalogObjectsRequest] body Required parameter: An object
362
- # containing the fields to POST for the request. See the corresponding
363
- # object definition for field details.
364
- # @return [SearchCatalogObjectsResponse Hash] response from the API call
365
- def search_catalog_objects(body:)
366
- # Prepare query url.
367
- _query_builder = config.get_base_uri
368
- _query_builder << '/v2/catalog/search'
369
- _query_url = APIHelper.clean_url _query_builder
370
-
371
- # Prepare headers.
372
- _headers = {
373
- 'accept' => 'application/json',
374
- 'content-type' => 'application/json; charset=utf-8'
375
- }
376
-
377
- # Prepare and execute HttpRequest.
378
- _request = config.http_client.post(
379
- _query_url,
380
- headers: _headers,
381
- parameters: body.to_json
382
- )
383
- OAuth2.apply(config, _request)
384
- _response = execute_request(_request)
385
-
386
- # Return appropriate response type.
387
- decoded = APIHelper.json_deserialize(_response.raw_body)
388
- _errors = APIHelper.map_response(decoded, ['errors'])
389
- ApiResponse.new(_response, data: decoded, errors: _errors)
390
- end
391
-
392
- # Updates the [CatalogModifierList](#type-catalogmodifierlist) objects
393
- # that apply to the targeted [CatalogItem](#type-catalogitem) without having
394
- # to perform an upsert on the entire item.
395
- # @param [UpdateItemModifierListsRequest] body Required parameter: An object
396
- # containing the fields to POST for the request. See the corresponding
397
- # object definition for field details.
398
- # @return [UpdateItemModifierListsResponse Hash] response from the API call
399
- def update_item_modifier_lists(body:)
400
- # Prepare query url.
401
- _query_builder = config.get_base_uri
402
- _query_builder << '/v2/catalog/update-item-modifier-lists'
403
- _query_url = APIHelper.clean_url _query_builder
404
-
405
- # Prepare headers.
406
- _headers = {
407
- 'accept' => 'application/json',
408
- 'content-type' => 'application/json; charset=utf-8'
409
- }
410
-
411
- # Prepare and execute HttpRequest.
412
- _request = config.http_client.post(
413
- _query_url,
414
- headers: _headers,
415
- parameters: body.to_json
416
- )
417
- OAuth2.apply(config, _request)
418
- _response = execute_request(_request)
419
-
420
- # Return appropriate response type.
421
- decoded = APIHelper.json_deserialize(_response.raw_body)
422
- _errors = APIHelper.map_response(decoded, ['errors'])
423
- ApiResponse.new(_response, data: decoded, errors: _errors)
424
- end
425
-
426
- # Updates the [CatalogTax](#type-catalogtax) objects that apply to the
427
- # targeted [CatalogItem](#type-catalogitem) without having to perform an
428
- # upsert on the entire item.
429
- # @param [UpdateItemTaxesRequest] body Required parameter: An object
430
- # containing the fields to POST for the request. See the corresponding
431
- # object definition for field details.
432
- # @return [UpdateItemTaxesResponse Hash] response from the API call
433
- def update_item_taxes(body:)
434
- # Prepare query url.
435
- _query_builder = config.get_base_uri
436
- _query_builder << '/v2/catalog/update-item-taxes'
437
- _query_url = APIHelper.clean_url _query_builder
438
-
439
- # Prepare headers.
440
- _headers = {
441
- 'accept' => 'application/json',
442
- 'content-type' => 'application/json; charset=utf-8'
443
- }
444
-
445
- # Prepare and execute HttpRequest.
446
- _request = config.http_client.post(
447
- _query_url,
448
- headers: _headers,
449
- parameters: body.to_json
450
- )
451
- OAuth2.apply(config, _request)
452
- _response = execute_request(_request)
453
-
454
- # Return appropriate response type.
455
- decoded = APIHelper.json_deserialize(_response.raw_body)
456
- _errors = APIHelper.map_response(decoded, ['errors'])
457
- ApiResponse.new(_response, data: decoded, errors: _errors)
458
- end
459
- end
460
- end
1
+ # square
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module Square
7
+ # CatalogApi
8
+ class CatalogApi < BaseApi
9
+ def initialize(config, http_call_back: nil)
10
+ super(config, http_call_back: http_call_back)
11
+ end
12
+
13
+ # Deletes a set of [CatalogItem](#type-catalogitem)s based on the
14
+ # provided list of target IDs and returns a set of successfully deleted IDs
15
+ # in
16
+ # the response. Deletion is a cascading event such that all children of the
17
+ # targeted object are also deleted. For example, deleting a CatalogItem will
18
+ # also delete all of its [CatalogItemVariation](#type-catalogitemvariation)
19
+ # children.
20
+ # `BatchDeleteCatalogObjects` succeeds even if only a portion of the
21
+ # targeted
22
+ # IDs can be deleted. The response will only include IDs that were
23
+ # actually deleted.
24
+ # @param [BatchDeleteCatalogObjectsRequest] body Required parameter: An
25
+ # object containing the fields to POST for the request. See the
26
+ # corresponding object definition for field details.
27
+ # @return [BatchDeleteCatalogObjectsResponse Hash] response from the API call
28
+ def batch_delete_catalog_objects(body:)
29
+ # Prepare query url.
30
+ _query_builder = config.get_base_uri
31
+ _query_builder << '/v2/catalog/batch-delete'
32
+ _query_url = APIHelper.clean_url _query_builder
33
+
34
+ # Prepare headers.
35
+ _headers = {
36
+ 'accept' => 'application/json',
37
+ 'content-type' => 'application/json; charset=utf-8'
38
+ }
39
+
40
+ # Prepare and execute HttpRequest.
41
+ _request = config.http_client.post(
42
+ _query_url,
43
+ headers: _headers,
44
+ parameters: body.to_json
45
+ )
46
+ OAuth2.apply(config, _request)
47
+ _response = execute_request(_request)
48
+
49
+ # Return appropriate response type.
50
+ decoded = APIHelper.json_deserialize(_response.raw_body)
51
+ _errors = APIHelper.map_response(decoded, ['errors'])
52
+ ApiResponse.new(_response, data: decoded, errors: _errors)
53
+ end
54
+
55
+ # Returns a set of objects based on the provided ID.
56
+ # Each [CatalogItem](#type-catalogitem) returned in the set includes all of
57
+ # its
58
+ # child information including: all of its
59
+ # [CatalogItemVariation](#type-catalogitemvariation) objects, references to
60
+ # its [CatalogModifierList](#type-catalogmodifierlist) objects, and the ids
61
+ # of
62
+ # any [CatalogTax](#type-catalogtax) objects that apply to it.
63
+ # @param [BatchRetrieveCatalogObjectsRequest] body Required parameter: An
64
+ # object containing the fields to POST for the request. See the
65
+ # corresponding object definition for field details.
66
+ # @return [BatchRetrieveCatalogObjectsResponse Hash] response from the API call
67
+ def batch_retrieve_catalog_objects(body:)
68
+ # Prepare query url.
69
+ _query_builder = config.get_base_uri
70
+ _query_builder << '/v2/catalog/batch-retrieve'
71
+ _query_url = APIHelper.clean_url _query_builder
72
+
73
+ # Prepare headers.
74
+ _headers = {
75
+ 'accept' => 'application/json',
76
+ 'content-type' => 'application/json; charset=utf-8'
77
+ }
78
+
79
+ # Prepare and execute HttpRequest.
80
+ _request = config.http_client.post(
81
+ _query_url,
82
+ headers: _headers,
83
+ parameters: body.to_json
84
+ )
85
+ OAuth2.apply(config, _request)
86
+ _response = execute_request(_request)
87
+
88
+ # Return appropriate response type.
89
+ decoded = APIHelper.json_deserialize(_response.raw_body)
90
+ _errors = APIHelper.map_response(decoded, ['errors'])
91
+ ApiResponse.new(_response, data: decoded, errors: _errors)
92
+ end
93
+
94
+ # Creates or updates up to 10,000 target objects based on the provided
95
+ # list of objects. The target objects are grouped into batches and each
96
+ # batch is
97
+ # inserted/updated in an all-or-nothing manner. If an object within a batch
98
+ # is
99
+ # malformed in some way, or violates a database constraint, the entire batch
100
+ # containing that item will be disregarded. However, other batches in the
101
+ # same
102
+ # request may still succeed. Each batch may contain up to 1,000 objects, and
103
+ # batches will be processed in order as long as the total object count for
104
+ # the
105
+ # request (items, variations, modifier lists, discounts, and taxes) is no
106
+ # more
107
+ # than 10,000.
108
+ # @param [BatchUpsertCatalogObjectsRequest] body Required parameter: An
109
+ # object containing the fields to POST for the request. See the
110
+ # corresponding object definition for field details.
111
+ # @return [BatchUpsertCatalogObjectsResponse Hash] response from the API call
112
+ def batch_upsert_catalog_objects(body:)
113
+ # Prepare query url.
114
+ _query_builder = config.get_base_uri
115
+ _query_builder << '/v2/catalog/batch-upsert'
116
+ _query_url = APIHelper.clean_url _query_builder
117
+
118
+ # Prepare headers.
119
+ _headers = {
120
+ 'accept' => 'application/json',
121
+ 'content-type' => 'application/json; charset=utf-8'
122
+ }
123
+
124
+ # Prepare and execute HttpRequest.
125
+ _request = config.http_client.post(
126
+ _query_url,
127
+ headers: _headers,
128
+ parameters: body.to_json
129
+ )
130
+ OAuth2.apply(config, _request)
131
+ _response = execute_request(_request)
132
+
133
+ # Return appropriate response type.
134
+ decoded = APIHelper.json_deserialize(_response.raw_body)
135
+ _errors = APIHelper.map_response(decoded, ['errors'])
136
+ ApiResponse.new(_response, data: decoded, errors: _errors)
137
+ end
138
+
139
+ # Returns information about the Square Catalog API, such as batch size
140
+ # limits for `BatchUpsertCatalogObjects`.
141
+ # @return [CatalogInfoResponse Hash] response from the API call
142
+ def catalog_info
143
+ # Prepare query url.
144
+ _query_builder = config.get_base_uri
145
+ _query_builder << '/v2/catalog/info'
146
+ _query_url = APIHelper.clean_url _query_builder
147
+
148
+ # Prepare headers.
149
+ _headers = {
150
+ 'accept' => 'application/json'
151
+ }
152
+
153
+ # Prepare and execute HttpRequest.
154
+ _request = config.http_client.get(
155
+ _query_url,
156
+ headers: _headers
157
+ )
158
+ OAuth2.apply(config, _request)
159
+ _response = execute_request(_request)
160
+
161
+ # Return appropriate response type.
162
+ decoded = APIHelper.json_deserialize(_response.raw_body)
163
+ _errors = APIHelper.map_response(decoded, ['errors'])
164
+ ApiResponse.new(_response, data: decoded, errors: _errors)
165
+ end
166
+
167
+ # Returns a list of [CatalogObject](#type-catalogobject)s that includes
168
+ # all objects of a set of desired types (for example, all
169
+ # [CatalogItem](#type-catalogitem)
170
+ # and [CatalogTax](#type-catalogtax) objects) in the catalog. The `types`
171
+ # parameter
172
+ # is specified as a comma-separated list of valid
173
+ # [CatalogObject](#type-catalogobject) types:
174
+ # `ITEM`, `ITEM_VARIATION`, `MODIFIER`, `MODIFIER_LIST`, `CATEGORY`,
175
+ # `DISCOUNT`, `TAX`.
176
+ # __Important:__ ListCatalog does not return deleted catalog items. To
177
+ # retrieve
178
+ # deleted catalog items, use SearchCatalogObjects and set
179
+ # `include_deleted_objects`
180
+ # to `true`.
181
+ # @param [String] cursor Optional parameter: The pagination cursor returned
182
+ # in the previous response. Leave unset for an initial request. See
183
+ # [Pagination](https://developer.squareup.com/docs/basics/api101/pagination)
184
+ # for more information.
185
+ # @param [String] types Optional parameter: An optional case-insensitive,
186
+ # comma-separated list of object types to retrieve, for example
187
+ # `ITEM,ITEM_VARIATION,CATEGORY,IMAGE`. The legal values are taken from the
188
+ # [CatalogObjectType](#type-catalogobjecttype) enumeration, namely `ITEM`,
189
+ # `ITEM_VARIATION`, `CATEGORY`, `DISCOUNT`, `TAX`, `MODIFIER`,
190
+ # `MODIFIER_LIST`, or `IMAGE`.
191
+ # @return [ListCatalogResponse Hash] response from the API call
192
+ def list_catalog(cursor: nil,
193
+ types: nil)
194
+ # Prepare query url.
195
+ _query_builder = config.get_base_uri
196
+ _query_builder << '/v2/catalog/list'
197
+ _query_builder = APIHelper.append_url_with_query_parameters(
198
+ _query_builder,
199
+ 'cursor' => cursor,
200
+ 'types' => types
201
+ )
202
+ _query_url = APIHelper.clean_url _query_builder
203
+
204
+ # Prepare headers.
205
+ _headers = {
206
+ 'accept' => 'application/json'
207
+ }
208
+
209
+ # Prepare and execute HttpRequest.
210
+ _request = config.http_client.get(
211
+ _query_url,
212
+ headers: _headers
213
+ )
214
+ OAuth2.apply(config, _request)
215
+ _response = execute_request(_request)
216
+
217
+ # Return appropriate response type.
218
+ decoded = APIHelper.json_deserialize(_response.raw_body)
219
+ _errors = APIHelper.map_response(decoded, ['errors'])
220
+ ApiResponse.new(_response, data: decoded, errors: _errors)
221
+ end
222
+
223
+ # Creates or updates the target [CatalogObject](#type-catalogobject).
224
+ # @param [UpsertCatalogObjectRequest] body Required parameter: An object
225
+ # containing the fields to POST for the request. See the corresponding
226
+ # object definition for field details.
227
+ # @return [UpsertCatalogObjectResponse Hash] response from the API call
228
+ def upsert_catalog_object(body:)
229
+ # Prepare query url.
230
+ _query_builder = config.get_base_uri
231
+ _query_builder << '/v2/catalog/object'
232
+ _query_url = APIHelper.clean_url _query_builder
233
+
234
+ # Prepare headers.
235
+ _headers = {
236
+ 'accept' => 'application/json',
237
+ 'content-type' => 'application/json; charset=utf-8'
238
+ }
239
+
240
+ # Prepare and execute HttpRequest.
241
+ _request = config.http_client.post(
242
+ _query_url,
243
+ headers: _headers,
244
+ parameters: body.to_json
245
+ )
246
+ OAuth2.apply(config, _request)
247
+ _response = execute_request(_request)
248
+
249
+ # Return appropriate response type.
250
+ decoded = APIHelper.json_deserialize(_response.raw_body)
251
+ _errors = APIHelper.map_response(decoded, ['errors'])
252
+ ApiResponse.new(_response, data: decoded, errors: _errors)
253
+ end
254
+
255
+ # Deletes a single [CatalogObject](#type-catalogobject) based on the
256
+ # provided ID and returns the set of successfully deleted IDs in the
257
+ # response.
258
+ # Deletion is a cascading event such that all children of the targeted
259
+ # object
260
+ # are also deleted. For example, deleting a [CatalogItem](#type-catalogitem)
261
+ # will also delete all of its
262
+ # [CatalogItemVariation](#type-catalogitemvariation) children.
263
+ # @param [String] object_id Required parameter: The ID of the
264
+ # [CatalogObject](#type-catalogobject) to be deleted. When an object is
265
+ # deleted, other objects in the graph that depend on that object will be
266
+ # deleted as well (for example, deleting a [CatalogItem](#type-catalogitem)
267
+ # will delete its [CatalogItemVariation](#type-catalogitemvariation)s).
268
+ # @return [DeleteCatalogObjectResponse Hash] response from the API call
269
+ def delete_catalog_object(object_id:)
270
+ # Prepare query url.
271
+ _query_builder = config.get_base_uri
272
+ _query_builder << '/v2/catalog/object/{object_id}'
273
+ _query_builder = APIHelper.append_url_with_template_parameters(
274
+ _query_builder,
275
+ 'object_id' => object_id
276
+ )
277
+ _query_url = APIHelper.clean_url _query_builder
278
+
279
+ # Prepare headers.
280
+ _headers = {
281
+ 'accept' => 'application/json'
282
+ }
283
+
284
+ # Prepare and execute HttpRequest.
285
+ _request = config.http_client.delete(
286
+ _query_url,
287
+ headers: _headers
288
+ )
289
+ OAuth2.apply(config, _request)
290
+ _response = execute_request(_request)
291
+
292
+ # Return appropriate response type.
293
+ decoded = APIHelper.json_deserialize(_response.raw_body)
294
+ _errors = APIHelper.map_response(decoded, ['errors'])
295
+ ApiResponse.new(_response, data: decoded, errors: _errors)
296
+ end
297
+
298
+ # Returns a single [CatalogItem](#type-catalogitem) as a
299
+ # [CatalogObject](#type-catalogobject) based on the provided ID. The
300
+ # returned
301
+ # object includes all of the relevant [CatalogItem](#type-catalogitem)
302
+ # information including: [CatalogItemVariation](#type-catalogitemvariation)
303
+ # children, references to its
304
+ # [CatalogModifierList](#type-catalogmodifierlist) objects, and the ids of
305
+ # any [CatalogTax](#type-catalogtax) objects that apply to it.
306
+ # @param [String] object_id Required parameter: The object ID of any type of
307
+ # [CatalogObject](#type-catalogobject)s to be retrieved.
308
+ # @param [Boolean] include_related_objects Optional parameter: If `true`,
309
+ # the response will include additional objects that are related to the
310
+ # requested object, as follows: If the `object` field of the response
311
+ # contains a [CatalogItem](#type-catalogitem), its associated
312
+ # [CatalogCategory](#type-catalogcategory),
313
+ # [CatalogTax](#type-catalogtax)es, [CatalogImage](#type-catalogimage)s and
314
+ # [CatalogModifierList](#type-catalogmodifierlist)s will be returned in the
315
+ # `related_objects` field of the response. If the `object` field of the
316
+ # response contains a [CatalogItemVariation](#type-catalogitemvariation),
317
+ # its parent [CatalogItem](#type-catalogitem) will be returned in the
318
+ # `related_objects` field of the response. Default value: `false`
319
+ # @return [RetrieveCatalogObjectResponse Hash] response from the API call
320
+ def retrieve_catalog_object(object_id:,
321
+ include_related_objects: nil)
322
+ # Prepare query url.
323
+ _query_builder = config.get_base_uri
324
+ _query_builder << '/v2/catalog/object/{object_id}'
325
+ _query_builder = APIHelper.append_url_with_template_parameters(
326
+ _query_builder,
327
+ 'object_id' => object_id
328
+ )
329
+ _query_builder = APIHelper.append_url_with_query_parameters(
330
+ _query_builder,
331
+ 'include_related_objects' => include_related_objects
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.get(
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
+ # Queries the targeted catalog using a variety of query types:
355
+ # [CatalogQuerySortedAttribute](#type-catalogquerysortedattribute),
356
+ # [CatalogQueryExact](#type-catalogqueryexact),
357
+ # [CatalogQueryRange](#type-catalogqueryrange),
358
+ # [CatalogQueryText](#type-catalogquerytext),
359
+ # [CatalogQueryItemsForTax](#type-catalogqueryitemsfortax), and
360
+ # [CatalogQueryItemsForModifierList](#type-catalogqueryitemsformodifierlist)
361
+ # .
362
+ # @param [SearchCatalogObjectsRequest] body Required parameter: An object
363
+ # containing the fields to POST for the request. See the corresponding
364
+ # object definition for field details.
365
+ # @return [SearchCatalogObjectsResponse Hash] response from the API call
366
+ def search_catalog_objects(body:)
367
+ # Prepare query url.
368
+ _query_builder = config.get_base_uri
369
+ _query_builder << '/v2/catalog/search'
370
+ _query_url = APIHelper.clean_url _query_builder
371
+
372
+ # Prepare headers.
373
+ _headers = {
374
+ 'accept' => 'application/json',
375
+ 'content-type' => 'application/json; charset=utf-8'
376
+ }
377
+
378
+ # Prepare and execute HttpRequest.
379
+ _request = config.http_client.post(
380
+ _query_url,
381
+ headers: _headers,
382
+ parameters: body.to_json
383
+ )
384
+ OAuth2.apply(config, _request)
385
+ _response = execute_request(_request)
386
+
387
+ # Return appropriate response type.
388
+ decoded = APIHelper.json_deserialize(_response.raw_body)
389
+ _errors = APIHelper.map_response(decoded, ['errors'])
390
+ ApiResponse.new(_response, data: decoded, errors: _errors)
391
+ end
392
+
393
+ # Updates the [CatalogModifierList](#type-catalogmodifierlist) objects
394
+ # that apply to the targeted [CatalogItem](#type-catalogitem) without having
395
+ # to perform an upsert on the entire item.
396
+ # @param [UpdateItemModifierListsRequest] body Required parameter: An object
397
+ # containing the fields to POST for the request. See the corresponding
398
+ # object definition for field details.
399
+ # @return [UpdateItemModifierListsResponse Hash] response from the API call
400
+ def update_item_modifier_lists(body:)
401
+ # Prepare query url.
402
+ _query_builder = config.get_base_uri
403
+ _query_builder << '/v2/catalog/update-item-modifier-lists'
404
+ _query_url = APIHelper.clean_url _query_builder
405
+
406
+ # Prepare headers.
407
+ _headers = {
408
+ 'accept' => 'application/json',
409
+ 'content-type' => 'application/json; charset=utf-8'
410
+ }
411
+
412
+ # Prepare and execute HttpRequest.
413
+ _request = config.http_client.post(
414
+ _query_url,
415
+ headers: _headers,
416
+ parameters: body.to_json
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(_response, data: decoded, errors: _errors)
425
+ end
426
+
427
+ # Updates the [CatalogTax](#type-catalogtax) objects that apply to the
428
+ # targeted [CatalogItem](#type-catalogitem) without having to perform an
429
+ # upsert on the entire item.
430
+ # @param [UpdateItemTaxesRequest] body Required parameter: An object
431
+ # containing the fields to POST for the request. See the corresponding
432
+ # object definition for field details.
433
+ # @return [UpdateItemTaxesResponse Hash] response from the API call
434
+ def update_item_taxes(body:)
435
+ # Prepare query url.
436
+ _query_builder = config.get_base_uri
437
+ _query_builder << '/v2/catalog/update-item-taxes'
438
+ _query_url = APIHelper.clean_url _query_builder
439
+
440
+ # Prepare headers.
441
+ _headers = {
442
+ 'accept' => 'application/json',
443
+ 'content-type' => 'application/json; charset=utf-8'
444
+ }
445
+
446
+ # Prepare and execute HttpRequest.
447
+ _request = config.http_client.post(
448
+ _query_url,
449
+ headers: _headers,
450
+ parameters: body.to_json
451
+ )
452
+ OAuth2.apply(config, _request)
453
+ _response = execute_request(_request)
454
+
455
+ # Return appropriate response type.
456
+ decoded = APIHelper.json_deserialize(_response.raw_body)
457
+ _errors = APIHelper.map_response(decoded, ['errors'])
458
+ ApiResponse.new(_response, data: decoded, errors: _errors)
459
+ end
460
+ end
461
+ end