square.rb 3.3.0.20191217

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +10 -0
  3. data/README.md +285 -0
  4. data/lib/square/api/apple_pay_api.rb +50 -0
  5. data/lib/square/api/base_api.rb +43 -0
  6. data/lib/square/api/cash_drawers_api.rb +150 -0
  7. data/lib/square/api/catalog_api.rb +545 -0
  8. data/lib/square/api/checkout_api.rb +49 -0
  9. data/lib/square/api/customers_api.rb +327 -0
  10. data/lib/square/api/employees_api.rb +86 -0
  11. data/lib/square/api/inventory_api.rb +295 -0
  12. data/lib/square/api/labor_api.rb +553 -0
  13. data/lib/square/api/locations_api.rb +146 -0
  14. data/lib/square/api/merchants_api.rb +82 -0
  15. data/lib/square/api/mobile_authorization_api.rb +52 -0
  16. data/lib/square/api/o_auth_api.rb +163 -0
  17. data/lib/square/api/orders_api.rb +266 -0
  18. data/lib/square/api/payments_api.rb +277 -0
  19. data/lib/square/api/refunds_api.rb +144 -0
  20. data/lib/square/api/reporting_api.rb +138 -0
  21. data/lib/square/api/transactions_api.rb +377 -0
  22. data/lib/square/api/v1_employees_api.rb +715 -0
  23. data/lib/square/api/v1_items_api.rb +2046 -0
  24. data/lib/square/api/v1_locations_api.rb +83 -0
  25. data/lib/square/api/v1_transactions_api.rb +568 -0
  26. data/lib/square/api_helper.rb +276 -0
  27. data/lib/square/client.rb +156 -0
  28. data/lib/square/configuration.rb +93 -0
  29. data/lib/square/exceptions/api_exception.rb +15 -0
  30. data/lib/square/http/api_response.rb +45 -0
  31. data/lib/square/http/auth/o_auth2.rb +12 -0
  32. data/lib/square/http/faraday_client.rb +59 -0
  33. data/lib/square/http/http_call_back.rb +19 -0
  34. data/lib/square/http/http_client.rb +99 -0
  35. data/lib/square/http/http_method_enum.rb +8 -0
  36. data/lib/square/http/http_request.rb +45 -0
  37. data/lib/square/http/http_response.rb +24 -0
  38. data/lib/square.rb +49 -0
  39. data/spec/user_journey_spec.rb +145 -0
  40. data/test/api/api_test_base.rb +24 -0
  41. data/test/api/test_catalog_api.rb +59 -0
  42. data/test/api/test_customers_api.rb +45 -0
  43. data/test/api/test_employees_api.rb +36 -0
  44. data/test/api/test_labor_api.rb +74 -0
  45. data/test/api/test_locations_api.rb +35 -0
  46. data/test/api/test_merchants_api.rb +40 -0
  47. data/test/api/test_payments_api.rb +42 -0
  48. data/test/api/test_refunds_api.rb +41 -0
  49. data/test/http_response_catcher.rb +19 -0
  50. data/test/test_helper.rb +94 -0
  51. metadata +190 -0
@@ -0,0 +1,545 @@
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
+ # Upload an image file to create a new [CatalogImage](#type-catalogimage)
135
+ # for an existing
136
+ # [CatalogObject](#type-catalogobject). Images can be uploaded and linked in
137
+ # this request or created independently
138
+ # (without an object assignment) and linked to a
139
+ # [CatalogObject](#type-catalogobject) at a later time.
140
+ # CreateCatalogImage accepts HTTP multipart/form-data requests with a JSON
141
+ # part and an image file part in
142
+ # JPEG, PJPEG, PNG, or GIF format. The maximum file size is 15MB. The
143
+ # following is an example of such an HTTP request:
144
+ # ```
145
+ # POST /v2/catalog/images
146
+ # Accept: application/json
147
+ # Content-Type: multipart/form-data;boundary="boundary"
148
+ # Square-Version: XXXX-XX-XX
149
+ # Authorization: Bearer {ACCESS_TOKEN}
150
+ # --boundary
151
+ # Content-Disposition: form-data; name="request"
152
+ # Content-Type: application/json
153
+ # {
154
+ # "idempotency_key":"528dea59-7bfb-43c1-bd48-4a6bba7dd61f86",
155
+ # "object_id": "ND6EA5AAJEO5WL3JNNIAQA32",
156
+ # "image":{
157
+ # "id":"#TEMP_ID",
158
+ # "type":"IMAGE",
159
+ # "image_data":{
160
+ # "caption":"A picture of a cup of coffee"
161
+ # }
162
+ # }
163
+ # }
164
+ # --boundary
165
+ # Content-Disposition: form-data; name="image"; filename="Coffee.jpg"
166
+ # Content-Type: image/jpeg
167
+ # {ACTUAL_IMAGE_BYTES}
168
+ # --boundary
169
+ # ```
170
+ # Additional information and an example cURL request can be found in the
171
+ # [Create a Catalog Image
172
+ # recipe](https://developer.squareup.com/docs/more-apis/catalog/cookbook/cre
173
+ # ate-catalog-images).
174
+ # @param [CreateCatalogImageRequest] request Optional parameter: Example:
175
+ # @param [File | UploadIO] image_file Optional parameter: Example:
176
+ # @return [CreateCatalogImageResponse Hash] response from the API call
177
+ def create_catalog_image(request: nil,
178
+ image_file: nil)
179
+ # Prepare query url.
180
+ _query_builder = config.get_base_uri
181
+ _query_builder << '/v2/catalog/images'
182
+ _query_url = APIHelper.clean_url _query_builder
183
+
184
+ # Prepare headers.
185
+ _headers = {
186
+ 'accept' => 'application/json'
187
+ }
188
+
189
+ # Prepare form parameters.
190
+ _parameters = {
191
+ 'request' => Faraday::UploadIO.new(
192
+ StringIO.new(request.to_json),
193
+ 'application/json'
194
+ ),
195
+ 'image_file' => Faraday::UploadIO.new(
196
+ image_file,
197
+ 'image/jpeg'
198
+ )
199
+ }
200
+ _parameters = APIHelper.form_encode_parameters(_parameters)
201
+
202
+ # Prepare and execute HttpRequest.
203
+ _request = config.http_client.post(
204
+ _query_url,
205
+ headers: _headers,
206
+ parameters: _parameters
207
+ )
208
+ OAuth2.apply(config, _request)
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(_response, data: decoded, errors: _errors)
215
+ end
216
+
217
+ # Returns information about the Square Catalog API, such as batch size
218
+ # limits for `BatchUpsertCatalogObjects`.
219
+ # @return [CatalogInfoResponse Hash] response from the API call
220
+ def catalog_info
221
+ # Prepare query url.
222
+ _query_builder = config.get_base_uri
223
+ _query_builder << '/v2/catalog/info'
224
+ _query_url = APIHelper.clean_url _query_builder
225
+
226
+ # Prepare headers.
227
+ _headers = {
228
+ 'accept' => 'application/json'
229
+ }
230
+
231
+ # Prepare and execute HttpRequest.
232
+ _request = config.http_client.get(
233
+ _query_url,
234
+ headers: _headers
235
+ )
236
+ OAuth2.apply(config, _request)
237
+ _response = execute_request(_request)
238
+
239
+ # Return appropriate response type.
240
+ decoded = APIHelper.json_deserialize(_response.raw_body)
241
+ _errors = APIHelper.map_response(decoded, ['errors'])
242
+ ApiResponse.new(_response, data: decoded, errors: _errors)
243
+ end
244
+
245
+ # Returns a list of [CatalogObject](#type-catalogobject)s that includes
246
+ # all objects of a set of desired types (for example, all
247
+ # [CatalogItem](#type-catalogitem)
248
+ # and [CatalogTax](#type-catalogtax) objects) in the catalog. The `types`
249
+ # parameter
250
+ # is specified as a comma-separated list of valid
251
+ # [CatalogObject](#type-catalogobject) types:
252
+ # `ITEM`, `ITEM_VARIATION`, `MODIFIER`, `MODIFIER_LIST`, `CATEGORY`,
253
+ # `DISCOUNT`, `TAX`, `IMAGE`.
254
+ # __Important:__ ListCatalog does not return deleted catalog items. To
255
+ # retrieve
256
+ # deleted catalog items, use SearchCatalogObjects and set
257
+ # `include_deleted_objects`
258
+ # to `true`.
259
+ # @param [String] cursor Optional parameter: The pagination cursor returned
260
+ # in the previous response. Leave unset for an initial request. See
261
+ # [Pagination](https://developer.squareup.com/docs/basics/api101/pagination)
262
+ # for more information.
263
+ # @param [String] types Optional parameter: An optional case-insensitive,
264
+ # comma-separated list of object types to retrieve, for example
265
+ # `ITEM,ITEM_VARIATION,CATEGORY,IMAGE`. The legal values are taken from the
266
+ # CatalogObjectType enum: `ITEM`, `ITEM_VARIATION`, `CATEGORY`, `DISCOUNT`,
267
+ # `TAX`, `MODIFIER`, `MODIFIER_LIST`, or `IMAGE`.
268
+ # @return [ListCatalogResponse Hash] response from the API call
269
+ def list_catalog(cursor: nil,
270
+ types: nil)
271
+ # Prepare query url.
272
+ _query_builder = config.get_base_uri
273
+ _query_builder << '/v2/catalog/list'
274
+ _query_builder = APIHelper.append_url_with_query_parameters(
275
+ _query_builder,
276
+ 'cursor' => cursor,
277
+ 'types' => types
278
+ )
279
+ _query_url = APIHelper.clean_url _query_builder
280
+
281
+ # Prepare headers.
282
+ _headers = {
283
+ 'accept' => 'application/json'
284
+ }
285
+
286
+ # Prepare and execute HttpRequest.
287
+ _request = config.http_client.get(
288
+ _query_url,
289
+ headers: _headers
290
+ )
291
+ OAuth2.apply(config, _request)
292
+ _response = execute_request(_request)
293
+
294
+ # Return appropriate response type.
295
+ decoded = APIHelper.json_deserialize(_response.raw_body)
296
+ _errors = APIHelper.map_response(decoded, ['errors'])
297
+ ApiResponse.new(_response, data: decoded, errors: _errors)
298
+ end
299
+
300
+ # Creates or updates the target [CatalogObject](#type-catalogobject).
301
+ # @param [UpsertCatalogObjectRequest] body Required parameter: An object
302
+ # containing the fields to POST for the request. See the corresponding
303
+ # object definition for field details.
304
+ # @return [UpsertCatalogObjectResponse Hash] response from the API call
305
+ def upsert_catalog_object(body:)
306
+ # Prepare query url.
307
+ _query_builder = config.get_base_uri
308
+ _query_builder << '/v2/catalog/object'
309
+ _query_url = APIHelper.clean_url _query_builder
310
+
311
+ # Prepare headers.
312
+ _headers = {
313
+ 'accept' => 'application/json',
314
+ 'content-type' => 'application/json; charset=utf-8'
315
+ }
316
+
317
+ # Prepare and execute HttpRequest.
318
+ _request = config.http_client.post(
319
+ _query_url,
320
+ headers: _headers,
321
+ parameters: body.to_json
322
+ )
323
+ OAuth2.apply(config, _request)
324
+ _response = execute_request(_request)
325
+
326
+ # Return appropriate response type.
327
+ decoded = APIHelper.json_deserialize(_response.raw_body)
328
+ _errors = APIHelper.map_response(decoded, ['errors'])
329
+ ApiResponse.new(_response, data: decoded, errors: _errors)
330
+ end
331
+
332
+ # Deletes a single [CatalogObject](#type-catalogobject) based on the
333
+ # provided ID and returns the set of successfully deleted IDs in the
334
+ # response.
335
+ # Deletion is a cascading event such that all children of the targeted
336
+ # object
337
+ # are also deleted. For example, deleting a [CatalogItem](#type-catalogitem)
338
+ # will also delete all of its
339
+ # [CatalogItemVariation](#type-catalogitemvariation) children.
340
+ # @param [String] object_id Required parameter: The ID of the catalog object
341
+ # to be deleted. When an object is deleted, other objects in the graph that
342
+ # depend on that object will be deleted as well (for example, deleting a
343
+ # catalog item will delete its catalog item variations).
344
+ # @return [DeleteCatalogObjectResponse Hash] response from the API call
345
+ def delete_catalog_object(object_id:)
346
+ # Prepare query url.
347
+ _query_builder = config.get_base_uri
348
+ _query_builder << '/v2/catalog/object/{object_id}'
349
+ _query_builder = APIHelper.append_url_with_template_parameters(
350
+ _query_builder,
351
+ 'object_id' => object_id
352
+ )
353
+ _query_url = APIHelper.clean_url _query_builder
354
+
355
+ # Prepare headers.
356
+ _headers = {
357
+ 'accept' => 'application/json'
358
+ }
359
+
360
+ # Prepare and execute HttpRequest.
361
+ _request = config.http_client.delete(
362
+ _query_url,
363
+ headers: _headers
364
+ )
365
+ OAuth2.apply(config, _request)
366
+ _response = execute_request(_request)
367
+
368
+ # Return appropriate response type.
369
+ decoded = APIHelper.json_deserialize(_response.raw_body)
370
+ _errors = APIHelper.map_response(decoded, ['errors'])
371
+ ApiResponse.new(_response, data: decoded, errors: _errors)
372
+ end
373
+
374
+ # Returns a single [CatalogItem](#type-catalogitem) as a
375
+ # [CatalogObject](#type-catalogobject) based on the provided ID. The
376
+ # returned
377
+ # object includes all of the relevant [CatalogItem](#type-catalogitem)
378
+ # information including: [CatalogItemVariation](#type-catalogitemvariation)
379
+ # children, references to its
380
+ # [CatalogModifierList](#type-catalogmodifierlist) objects, and the ids of
381
+ # any [CatalogTax](#type-catalogtax) objects that apply to it.
382
+ # @param [String] object_id Required parameter: The object ID of any type of
383
+ # catalog objects to be retrieved.
384
+ # @param [Boolean] include_related_objects Optional parameter: If `true`,
385
+ # the response will include additional objects that are related to the
386
+ # requested object, as follows: If the `object` field of the response
387
+ # contains a CatalogItem, its associated CatalogCategory, CatalogTax
388
+ # objects, CatalogImages and CatalogModifierLists will be returned in the
389
+ # `related_objects` field of the response. If the `object` field of the
390
+ # response contains a CatalogItemVariation, its parent CatalogItem will be
391
+ # returned in the `related_objects` field of the response. Default value:
392
+ # `false`
393
+ # @return [RetrieveCatalogObjectResponse Hash] response from the API call
394
+ def retrieve_catalog_object(object_id:,
395
+ include_related_objects: nil)
396
+ # Prepare query url.
397
+ _query_builder = config.get_base_uri
398
+ _query_builder << '/v2/catalog/object/{object_id}'
399
+ _query_builder = APIHelper.append_url_with_template_parameters(
400
+ _query_builder,
401
+ 'object_id' => object_id
402
+ )
403
+ _query_builder = APIHelper.append_url_with_query_parameters(
404
+ _query_builder,
405
+ 'include_related_objects' => include_related_objects
406
+ )
407
+ _query_url = APIHelper.clean_url _query_builder
408
+
409
+ # Prepare headers.
410
+ _headers = {
411
+ 'accept' => 'application/json'
412
+ }
413
+
414
+ # Prepare and execute HttpRequest.
415
+ _request = config.http_client.get(
416
+ _query_url,
417
+ headers: _headers
418
+ )
419
+ OAuth2.apply(config, _request)
420
+ _response = execute_request(_request)
421
+
422
+ # Return appropriate response type.
423
+ decoded = APIHelper.json_deserialize(_response.raw_body)
424
+ _errors = APIHelper.map_response(decoded, ['errors'])
425
+ ApiResponse.new(_response, data: decoded, errors: _errors)
426
+ end
427
+
428
+ # Queries the targeted catalog using a variety of query types:
429
+ # [CatalogQuerySortedAttribute](#type-catalogquerysortedattribute),
430
+ # [CatalogQueryExact](#type-catalogqueryexact),
431
+ # [CatalogQueryRange](#type-catalogqueryrange),
432
+ # [CatalogQueryText](#type-catalogquerytext),
433
+ # [CatalogQueryItemsForTax](#type-catalogqueryitemsfortax), and
434
+ # [CatalogQueryItemsForModifierList](#type-catalogqueryitemsformodifierlist)
435
+ # .
436
+ # --
437
+ # --
438
+ # Future end of the above comment:
439
+ # [CatalogQueryItemsForTax](#type-catalogqueryitemsfortax),
440
+ # [CatalogQueryItemsForModifierList](#type-catalogqueryitemsformodifierlist)
441
+ # ,
442
+ # [CatalogQueryItemsForItemOptions](#type-catalogqueryitemsforitemoptions),
443
+ # and
444
+ # [CatalogQueryItemVariationsForItemOptionValues](#type-catalogqueryitemvari
445
+ # ationsforitemoptionvalues).
446
+ # @param [SearchCatalogObjectsRequest] body Required parameter: An object
447
+ # containing the fields to POST for the request. See the corresponding
448
+ # object definition for field details.
449
+ # @return [SearchCatalogObjectsResponse Hash] response from the API call
450
+ def search_catalog_objects(body:)
451
+ # Prepare query url.
452
+ _query_builder = config.get_base_uri
453
+ _query_builder << '/v2/catalog/search'
454
+ _query_url = APIHelper.clean_url _query_builder
455
+
456
+ # Prepare headers.
457
+ _headers = {
458
+ 'accept' => 'application/json',
459
+ 'content-type' => 'application/json; charset=utf-8'
460
+ }
461
+
462
+ # Prepare and execute HttpRequest.
463
+ _request = config.http_client.post(
464
+ _query_url,
465
+ headers: _headers,
466
+ parameters: body.to_json
467
+ )
468
+ OAuth2.apply(config, _request)
469
+ _response = execute_request(_request)
470
+
471
+ # Return appropriate response type.
472
+ decoded = APIHelper.json_deserialize(_response.raw_body)
473
+ _errors = APIHelper.map_response(decoded, ['errors'])
474
+ ApiResponse.new(_response, data: decoded, errors: _errors)
475
+ end
476
+
477
+ # Updates the [CatalogModifierList](#type-catalogmodifierlist) objects
478
+ # that apply to the targeted [CatalogItem](#type-catalogitem) without having
479
+ # to perform an upsert on the entire item.
480
+ # @param [UpdateItemModifierListsRequest] body Required parameter: An object
481
+ # containing the fields to POST for the request. See the corresponding
482
+ # object definition for field details.
483
+ # @return [UpdateItemModifierListsResponse Hash] response from the API call
484
+ def update_item_modifier_lists(body:)
485
+ # Prepare query url.
486
+ _query_builder = config.get_base_uri
487
+ _query_builder << '/v2/catalog/update-item-modifier-lists'
488
+ _query_url = APIHelper.clean_url _query_builder
489
+
490
+ # Prepare headers.
491
+ _headers = {
492
+ 'accept' => 'application/json',
493
+ 'content-type' => 'application/json; charset=utf-8'
494
+ }
495
+
496
+ # Prepare and execute HttpRequest.
497
+ _request = config.http_client.post(
498
+ _query_url,
499
+ headers: _headers,
500
+ parameters: body.to_json
501
+ )
502
+ OAuth2.apply(config, _request)
503
+ _response = execute_request(_request)
504
+
505
+ # Return appropriate response type.
506
+ decoded = APIHelper.json_deserialize(_response.raw_body)
507
+ _errors = APIHelper.map_response(decoded, ['errors'])
508
+ ApiResponse.new(_response, data: decoded, errors: _errors)
509
+ end
510
+
511
+ # Updates the [CatalogTax](#type-catalogtax) objects that apply to the
512
+ # targeted [CatalogItem](#type-catalogitem) without having to perform an
513
+ # upsert on the entire item.
514
+ # @param [UpdateItemTaxesRequest] body Required parameter: An object
515
+ # containing the fields to POST for the request. See the corresponding
516
+ # object definition for field details.
517
+ # @return [UpdateItemTaxesResponse Hash] response from the API call
518
+ def update_item_taxes(body:)
519
+ # Prepare query url.
520
+ _query_builder = config.get_base_uri
521
+ _query_builder << '/v2/catalog/update-item-taxes'
522
+ _query_url = APIHelper.clean_url _query_builder
523
+
524
+ # Prepare headers.
525
+ _headers = {
526
+ 'accept' => 'application/json',
527
+ 'content-type' => 'application/json; charset=utf-8'
528
+ }
529
+
530
+ # Prepare and execute HttpRequest.
531
+ _request = config.http_client.post(
532
+ _query_url,
533
+ headers: _headers,
534
+ parameters: body.to_json
535
+ )
536
+ OAuth2.apply(config, _request)
537
+ _response = execute_request(_request)
538
+
539
+ # Return appropriate response type.
540
+ decoded = APIHelper.json_deserialize(_response.raw_body)
541
+ _errors = APIHelper.map_response(decoded, ['errors'])
542
+ ApiResponse.new(_response, data: decoded, errors: _errors)
543
+ end
544
+ end
545
+ end
@@ -0,0 +1,49 @@
1
+ module Square
2
+ # CheckoutApi
3
+ class CheckoutApi < BaseApi
4
+ def initialize(config, http_call_back: nil)
5
+ super(config, http_call_back: http_call_back)
6
+ end
7
+
8
+ # Links a `checkoutId` to a `checkout_page_url` that customers will
9
+ # be directed to in order to provide their payment information using a
10
+ # payment processing workflow hosted on connect.squareup.com.
11
+ # @param [String] location_id Required parameter: The ID of the business
12
+ # location to associate the checkout with.
13
+ # @param [CreateCheckoutRequest] body Required parameter: An object
14
+ # containing the fields to POST for the request. See the corresponding
15
+ # object definition for field details.
16
+ # @return [CreateCheckoutResponse Hash] response from the API call
17
+ def create_checkout(location_id:,
18
+ body:)
19
+ # Prepare query url.
20
+ _query_builder = config.get_base_uri
21
+ _query_builder << '/v2/locations/{location_id}/checkouts'
22
+ _query_builder = APIHelper.append_url_with_template_parameters(
23
+ _query_builder,
24
+ 'location_id' => location_id
25
+ )
26
+ _query_url = APIHelper.clean_url _query_builder
27
+
28
+ # Prepare headers.
29
+ _headers = {
30
+ 'accept' => 'application/json',
31
+ 'content-type' => 'application/json; charset=utf-8'
32
+ }
33
+
34
+ # Prepare and execute HttpRequest.
35
+ _request = config.http_client.post(
36
+ _query_url,
37
+ headers: _headers,
38
+ parameters: body.to_json
39
+ )
40
+ OAuth2.apply(config, _request)
41
+ _response = execute_request(_request)
42
+
43
+ # Return appropriate response type.
44
+ decoded = APIHelper.json_deserialize(_response.raw_body)
45
+ _errors = APIHelper.map_response(decoded, ['errors'])
46
+ ApiResponse.new(_response, data: decoded, errors: _errors)
47
+ end
48
+ end
49
+ end