Class: Square::CatalogApi

Inherits:
BaseApi
  • Object
show all
Defined in:
lib/square/api/catalog_api.rb

Overview

CatalogApi

Instance Attribute Summary

Attributes inherited from BaseApi

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseApi

#execute_request, #validate_parameters

Constructor Details

#initialize(config, http_call_back: nil) ⇒ CatalogApi

Returns a new instance of CatalogApi.



4
5
6
# File 'lib/square/api/catalog_api.rb', line 4

def initialize(config, http_call_back: nil)
  super(config, http_call_back: http_call_back)
end

Instance Method Details

#batch_delete_catalog_objects(body:) ⇒ BatchDeleteCatalogObjectsResponse Hash

Deletes a set of [CatalogItem]($m/CatalogItem)s based on the provided list of target IDs and returns a set of successfully deleted IDs in the response. Deletion is a cascading event such that all children of the targeted object are also deleted. For example, deleting a CatalogItem will also delete all of its [CatalogItemVariation]($m/CatalogItemVariation) children. `BatchDeleteCatalogObjects` succeeds even if only a portion of the targeted IDs can be deleted. The response will only include IDs that were actually deleted. object containing the fields to POST for the request. See the corresponding object definition for field details.

Parameters:

  • body (BatchDeleteCatalogObjectsRequest)

    Required parameter: An

Returns:

  • (BatchDeleteCatalogObjectsResponse Hash)

    response from the API call



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/square/api/catalog_api.rb', line 23

def batch_delete_catalog_objects(body:)
  # Prepare query url.
  _query_builder = config.get_base_uri
  _query_builder << '/v2/catalog/batch-delete'
  _query_url = APIHelper.clean_url _query_builder

  # Prepare headers.
  _headers = {
    'accept' => 'application/json',
    'content-type' => 'application/json; charset=utf-8'
  }

  # Prepare and execute HttpRequest.
  _request = config.http_client.post(
    _query_url,
    headers: _headers,
    parameters: body.to_json
  )
  OAuth2.apply(config, _request)
  _response = execute_request(_request)

  # Return appropriate response type.
  decoded = APIHelper.json_deserialize(_response.raw_body)
  _errors = APIHelper.map_response(decoded, ['errors'])
  ApiResponse.new(
    _response, data: decoded, errors: _errors
  )
end

#batch_retrieve_catalog_objects(body:) ⇒ BatchRetrieveCatalogObjectsResponse Hash

Returns a set of objects based on the provided ID. Each [CatalogItem]($m/CatalogItem) returned in the set includes all of its child information including: all of its [CatalogItemVariation]($m/CatalogItemVariation) objects, references to its [CatalogModifierList]($m/CatalogModifierList) objects, and the ids of any [CatalogTax]($m/CatalogTax) objects that apply to it. object containing the fields to POST for the request. See the corresponding object definition for field details.

Parameters:

  • body (BatchRetrieveCatalogObjectsRequest)

    Required parameter: An

Returns:

  • (BatchRetrieveCatalogObjectsResponse Hash)

    response from the API call



62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/square/api/catalog_api.rb', line 62

def batch_retrieve_catalog_objects(body:)
  # Prepare query url.
  _query_builder = config.get_base_uri
  _query_builder << '/v2/catalog/batch-retrieve'
  _query_url = APIHelper.clean_url _query_builder

  # Prepare headers.
  _headers = {
    'accept' => 'application/json',
    'content-type' => 'application/json; charset=utf-8'
  }

  # Prepare and execute HttpRequest.
  _request = config.http_client.post(
    _query_url,
    headers: _headers,
    parameters: body.to_json
  )
  OAuth2.apply(config, _request)
  _response = execute_request(_request)

  # Return appropriate response type.
  decoded = APIHelper.json_deserialize(_response.raw_body)
  _errors = APIHelper.map_response(decoded, ['errors'])
  ApiResponse.new(
    _response, data: decoded, errors: _errors
  )
end

#batch_upsert_catalog_objects(body:) ⇒ BatchUpsertCatalogObjectsResponse Hash

Creates or updates up to 10,000 target objects based on the provided list of objects. The target objects are grouped into batches and each batch is inserted/updated in an all-or-nothing manner. If an object within a batch is malformed in some way, or violates a database constraint, the entire batch containing that item will be disregarded. However, other batches in the same request may still succeed. Each batch may contain up to 1,000 objects, and batches will be processed in order as long as the total object count for the request (items, variations, modifier lists, discounts, and taxes) is no more than 10,000. object containing the fields to POST for the request. See the corresponding object definition for field details.

Parameters:

  • body (BatchUpsertCatalogObjectsRequest)

    Required parameter: An

Returns:

  • (BatchUpsertCatalogObjectsResponse Hash)

    response from the API call



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
# File 'lib/square/api/catalog_api.rb', line 109

def batch_upsert_catalog_objects(body:)
  # Prepare query url.
  _query_builder = config.get_base_uri
  _query_builder << '/v2/catalog/batch-upsert'
  _query_url = APIHelper.clean_url _query_builder

  # Prepare headers.
  _headers = {
    'accept' => 'application/json',
    'content-type' => 'application/json; charset=utf-8'
  }

  # Prepare and execute HttpRequest.
  _request = config.http_client.post(
    _query_url,
    headers: _headers,
    parameters: body.to_json
  )
  OAuth2.apply(config, _request)
  _response = execute_request(_request)

  # Return appropriate response type.
  decoded = APIHelper.json_deserialize(_response.raw_body)
  _errors = APIHelper.map_response(decoded, ['errors'])
  ApiResponse.new(
    _response, data: decoded, errors: _errors
  )
end

#catalog_infoCatalogInfoResponse Hash

Retrieves information about the Square Catalog API, such as batch size limits that can be used by the `BatchUpsertCatalogObjects` endpoint.

Returns:

  • (CatalogInfoResponse Hash)

    response from the API call



202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
# File 'lib/square/api/catalog_api.rb', line 202

def catalog_info
  # Prepare query url.
  _query_builder = config.get_base_uri
  _query_builder << '/v2/catalog/info'
  _query_url = APIHelper.clean_url _query_builder

  # Prepare headers.
  _headers = {
    'accept' => 'application/json'
  }

  # Prepare and execute HttpRequest.
  _request = config.http_client.get(
    _query_url,
    headers: _headers
  )
  OAuth2.apply(config, _request)
  _response = execute_request(_request)

  # Return appropriate response type.
  decoded = APIHelper.json_deserialize(_response.raw_body)
  _errors = APIHelper.map_response(decoded, ['errors'])
  ApiResponse.new(
    _response, data: decoded, errors: _errors
  )
end

#create_catalog_image(request: nil, image_file: nil) ⇒ CreateCatalogImageResponse Hash

Uploads an image file to be represented by a [CatalogImage]($m/CatalogImage) object linked to an existing [CatalogObject]($m/CatalogObject) instance. A call to this endpoint can upload an image, link an image to a catalog object, or do both. This `CreateCatalogImage` endpoint accepts HTTP multipart/form-data requests with a JSON part and an image file part in JPEG, PJPEG, PNG, or GIF format. The maximum file size is 15MB.

Parameters:

  • request (CreateCatalogImageRequest) (defaults to: nil)

    Optional parameter: Example:

  • image_file (File | UploadIO) (defaults to: nil)

    Optional parameter: Example:

Returns:

  • (CreateCatalogImageResponse Hash)

    response from the API call



149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# File 'lib/square/api/catalog_api.rb', line 149

def create_catalog_image(request: nil,
                         image_file: nil)
  # Prepare query url.
  _query_builder = config.get_base_uri
  _query_builder << '/v2/catalog/images'
  _query_url = APIHelper.clean_url _query_builder

  if image_file.is_a? FileWrapper
    image_file_wrapper = image_file.file
    image_file_content_type = image_file.content_type
  else
    image_file_wrapper = image_file
    image_file_content_type = 'image/jpeg'
  end

  # Prepare headers.
  _headers = {
    'accept' => 'application/json'
  }

  # Prepare form parameters.
  _parameters = {
    'request' => Faraday::UploadIO.new(
      StringIO.new(request.to_json),
      'application/json'
    ),
    'image_file' => Faraday::UploadIO.new(
      image_file_wrapper,
      image_file_content_type
    )
  }
  _parameters = APIHelper.form_encode_parameters(_parameters)

  # Prepare and execute HttpRequest.
  _request = config.http_client.post(
    _query_url,
    headers: _headers,
    parameters: _parameters
  )
  OAuth2.apply(config, _request)
  _response = execute_request(_request)

  # Return appropriate response type.
  decoded = APIHelper.json_deserialize(_response.raw_body)
  _errors = APIHelper.map_response(decoded, ['errors'])
  ApiResponse.new(
    _response, data: decoded, errors: _errors
  )
end

#delete_catalog_object(object_id:) ⇒ DeleteCatalogObjectResponse Hash

Deletes a single [CatalogObject]($m/CatalogObject) based on the provided ID and returns the set of successfully deleted IDs in the response. Deletion is a cascading event such that all children of the targeted object are also deleted. For example, deleting a [CatalogItem]($m/CatalogItem) will also delete all of its [CatalogItemVariation]($m/CatalogItemVariation) children. to be deleted. When an object is deleted, other objects in the graph that depend on that object will be deleted as well (for example, deleting a catalog item will delete its catalog item variations).

Parameters:

  • object_id (String)

    Required parameter: The ID of the catalog object

Returns:

  • (DeleteCatalogObjectResponse Hash)

    response from the API call



343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
# File 'lib/square/api/catalog_api.rb', line 343

def delete_catalog_object(object_id:)
  # Prepare query url.
  _query_builder = config.get_base_uri
  _query_builder << '/v2/catalog/object/{object_id}'
  _query_builder = APIHelper.append_url_with_template_parameters(
    _query_builder,
    'object_id' => { 'value' => object_id, 'encode' => true }
  )
  _query_url = APIHelper.clean_url _query_builder

  # Prepare headers.
  _headers = {
    'accept' => 'application/json'
  }

  # Prepare and execute HttpRequest.
  _request = config.http_client.delete(
    _query_url,
    headers: _headers
  )
  OAuth2.apply(config, _request)
  _response = execute_request(_request)

  # Return appropriate response type.
  decoded = APIHelper.json_deserialize(_response.raw_body)
  _errors = APIHelper.map_response(decoded, ['errors'])
  ApiResponse.new(
    _response, data: decoded, errors: _errors
  )
end

#list_catalog(cursor: nil, types: nil, catalog_version: nil) ⇒ ListCatalogResponse Hash

Returns a list of [CatalogObject]($m/CatalogObject)s that includes all objects of a set of desired types (for example, all [CatalogItem]($m/CatalogItem) and [CatalogTax]($m/CatalogTax) objects) in the catalog. The `types` parameter is specified as a comma-separated list of valid [CatalogObject]($m/CatalogObject) types: `ITEM`, `ITEM_VARIATION`, `MODIFIER`, `MODIFIER_LIST`, `CATEGORY`, `DISCOUNT`, `TAX`, `IMAGE`. Important: ListCatalog does not return deleted catalog items. To retrieve deleted catalog items, use [SearchCatalogObjects]($e/Catalog/SearchCatalogObjects) and set the `include_deleted_objects` attribute value to `true`. in the previous response. Leave unset for an initial request. The page size is currently set to be 100. See [Pagination](developer.squareup.com/docs/basics/api101/pagination) for more information. comma-separated list of object types to retrieve. The valid values are defined in the [CatalogObjectType]($m/CatalogObjectType) enum, including `ITEM`, `ITEM_VARIATION`, `CATEGORY`, `DISCOUNT`, `TAX`, `MODIFIER`, `MODIFIER_LIST`, or `IMAGE`. If this is unspecified, the operation returns objects of all the types at the version of the Square API used to make the request. the catalog objects to be included in the response. This allows you to retrieve historical versions of objects. The specified version value is matched against the [CatalogObject]($m/CatalogObject)s' `version` attribute.

Parameters:

  • cursor (String) (defaults to: nil)

    Optional parameter: The pagination cursor returned

  • types (String) (defaults to: nil)

    Optional parameter: An optional case-insensitive,

  • catalog_version (Long) (defaults to: nil)

    Optional parameter: The specific version of

Returns:

  • (ListCatalogResponse Hash)

    response from the API call



261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
# File 'lib/square/api/catalog_api.rb', line 261

def list_catalog(cursor: nil,
                 types: nil,
                 catalog_version: nil)
  # Prepare query url.
  _query_builder = config.get_base_uri
  _query_builder << '/v2/catalog/list'
  _query_builder = APIHelper.append_url_with_query_parameters(
    _query_builder,
    'cursor' => cursor,
    'types' => types,
    'catalog_version' => catalog_version
  )
  _query_url = APIHelper.clean_url _query_builder

  # Prepare headers.
  _headers = {
    'accept' => 'application/json'
  }

  # Prepare and execute HttpRequest.
  _request = config.http_client.get(
    _query_url,
    headers: _headers
  )
  OAuth2.apply(config, _request)
  _response = execute_request(_request)

  # Return appropriate response type.
  decoded = APIHelper.json_deserialize(_response.raw_body)
  _errors = APIHelper.map_response(decoded, ['errors'])
  ApiResponse.new(
    _response, data: decoded, errors: _errors
  )
end

#retrieve_catalog_object(object_id:, include_related_objects: false, catalog_version: nil) ⇒ RetrieveCatalogObjectResponse Hash

Returns a single [CatalogItem]($m/CatalogItem) as a [CatalogObject]($m/CatalogObject) based on the provided ID. The returned object includes all of the relevant [CatalogItem]($m/CatalogItem) information including: [CatalogItemVariation]($m/CatalogItemVariation) children, references to its [CatalogModifierList]($m/CatalogModifierList) objects, and the ids of any [CatalogTax]($m/CatalogTax) objects that apply to it. catalog objects to be retrieved. the response will include additional objects that are related to the requested object, as follows: If the `object` field of the response contains a `CatalogItem`, its associated `CatalogCategory`, `CatalogTax`, `CatalogImage` and `CatalogModifierList` objects will be returned in the `related_objects` field of the response. If the `object` field of the response contains a `CatalogItemVariation`, its parent `CatalogItem` will be returned in the `related_objects` field of the response. Default value: `false` specific version of the catalog. This allows you to retrieve historical versions of objects. The value to retrieve a specific version of an object can be found in the version field of [CatalogObject]($m/CatalogObject)s.

Parameters:

  • object_id (String)

    Required parameter: The object ID of any type of

  • include_related_objects (Boolean) (defaults to: false)

    Optional parameter: If `true`,

  • catalog_version (Long) (defaults to: nil)

    Optional parameter: Requests objects as of a

Returns:

  • (RetrieveCatalogObjectResponse Hash)

    response from the API call



397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
# File 'lib/square/api/catalog_api.rb', line 397

def retrieve_catalog_object(object_id:,
                            include_related_objects: false,
                            catalog_version: nil)
  # Prepare query url.
  _query_builder = config.get_base_uri
  _query_builder << '/v2/catalog/object/{object_id}'
  _query_builder = APIHelper.append_url_with_template_parameters(
    _query_builder,
    'object_id' => { 'value' => object_id, 'encode' => true }
  )
  _query_builder = APIHelper.append_url_with_query_parameters(
    _query_builder,
    'include_related_objects' => include_related_objects,
    'catalog_version' => catalog_version
  )
  _query_url = APIHelper.clean_url _query_builder

  # Prepare headers.
  _headers = {
    'accept' => 'application/json'
  }

  # Prepare and execute HttpRequest.
  _request = config.http_client.get(
    _query_url,
    headers: _headers
  )
  OAuth2.apply(config, _request)
  _response = execute_request(_request)

  # Return appropriate response type.
  decoded = APIHelper.json_deserialize(_response.raw_body)
  _errors = APIHelper.map_response(decoded, ['errors'])
  ApiResponse.new(
    _response, data: decoded, errors: _errors
  )
end

#search_catalog_items(body:) ⇒ SearchCatalogItemsResponse Hash

Searches for catalog items or item variations by matching supported search attribute values, including custom attribute values, against one or more of the specified query filters. This (`SearchCatalogItems`) endpoint differs from the [SearchCatalogObjects]($e/Catalog/SearchCatalogObjects) endpoint in the following aspects:

  • `SearchCatalogItems` can only search for items or item variations,

whereas `SearchCatalogObjects` can search for any type of catalog objects.

  • `SearchCatalogItems` supports the custom attribute query filters to

return items or item variations that contain custom attribute values, where `SearchCatalogObjects` does not.

  • `SearchCatalogItems` does not support the `include_deleted_objects`

filter to search for deleted items or item variations, whereas `SearchCatalogObjects` does.

  • The both endpoints use different call conventions, including the query

filter formats. containing the fields to POST for the request. See the corresponding object definition for field details.

Parameters:

  • body (SearchCatalogItemsRequest)

    Required parameter: An object

Returns:

  • (SearchCatalogItemsResponse Hash)

    response from the API call



506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
# File 'lib/square/api/catalog_api.rb', line 506

def search_catalog_items(body:)
  # Prepare query url.
  _query_builder = config.get_base_uri
  _query_builder << '/v2/catalog/search-catalog-items'
  _query_url = APIHelper.clean_url _query_builder

  # Prepare headers.
  _headers = {
    'accept' => 'application/json',
    'content-type' => 'application/json; charset=utf-8'
  }

  # Prepare and execute HttpRequest.
  _request = config.http_client.post(
    _query_url,
    headers: _headers,
    parameters: body.to_json
  )
  OAuth2.apply(config, _request)
  _response = execute_request(_request)

  # Return appropriate response type.
  decoded = APIHelper.json_deserialize(_response.raw_body)
  _errors = APIHelper.map_response(decoded, ['errors'])
  ApiResponse.new(
    _response, data: decoded, errors: _errors
  )
end

#search_catalog_objects(body:) ⇒ SearchCatalogObjectsResponse Hash

Searches for [CatalogObject]($m/CatalogObject) of any type by matching supported search attribute values, excluding custom attribute values on items or item variations, against one or more of the specified query filters. This (`SearchCatalogObjects`) endpoint differs from the [SearchCatalogItems]($e/Catalog/SearchCatalogItems) endpoint in the following aspects:

  • `SearchCatalogItems` can only search for items or item variations,

whereas `SearchCatalogObjects` can search for any type of catalog objects.

  • `SearchCatalogItems` supports the custom attribute query filters to

return items or item variations that contain custom attribute values, where `SearchCatalogObjects` does not.

  • `SearchCatalogItems` does not support the `include_deleted_objects`

filter to search for deleted items or item variations, whereas `SearchCatalogObjects` does.

  • The both endpoints have different call conventions, including the query

filter formats. containing the fields to POST for the request. See the corresponding object definition for field details.

Parameters:

  • body (SearchCatalogObjectsRequest)

    Required parameter: An object

Returns:

  • (SearchCatalogObjectsResponse Hash)

    response from the API call



456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
# File 'lib/square/api/catalog_api.rb', line 456

def search_catalog_objects(body:)
  # Prepare query url.
  _query_builder = config.get_base_uri
  _query_builder << '/v2/catalog/search'
  _query_url = APIHelper.clean_url _query_builder

  # Prepare headers.
  _headers = {
    'accept' => 'application/json',
    'content-type' => 'application/json; charset=utf-8'
  }

  # Prepare and execute HttpRequest.
  _request = config.http_client.post(
    _query_url,
    headers: _headers,
    parameters: body.to_json
  )
  OAuth2.apply(config, _request)
  _response = execute_request(_request)

  # Return appropriate response type.
  decoded = APIHelper.json_deserialize(_response.raw_body)
  _errors = APIHelper.map_response(decoded, ['errors'])
  ApiResponse.new(
    _response, data: decoded, errors: _errors
  )
end

#update_item_modifier_lists(body:) ⇒ UpdateItemModifierListsResponse Hash

Updates the [CatalogModifierList]($m/CatalogModifierList) objects that apply to the targeted [CatalogItem]($m/CatalogItem) without having to perform an upsert on the entire item. containing the fields to POST for the request. See the corresponding object definition for field details.

Parameters:

  • body (UpdateItemModifierListsRequest)

    Required parameter: An object

Returns:

  • (UpdateItemModifierListsResponse Hash)

    response from the API call



542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
# File 'lib/square/api/catalog_api.rb', line 542

def update_item_modifier_lists(body:)
  # Prepare query url.
  _query_builder = config.get_base_uri
  _query_builder << '/v2/catalog/update-item-modifier-lists'
  _query_url = APIHelper.clean_url _query_builder

  # Prepare headers.
  _headers = {
    'accept' => 'application/json',
    'content-type' => 'application/json; charset=utf-8'
  }

  # Prepare and execute HttpRequest.
  _request = config.http_client.post(
    _query_url,
    headers: _headers,
    parameters: body.to_json
  )
  OAuth2.apply(config, _request)
  _response = execute_request(_request)

  # Return appropriate response type.
  decoded = APIHelper.json_deserialize(_response.raw_body)
  _errors = APIHelper.map_response(decoded, ['errors'])
  ApiResponse.new(
    _response, data: decoded, errors: _errors
  )
end

#update_item_taxes(body:) ⇒ UpdateItemTaxesResponse Hash

Updates the [CatalogTax]($m/CatalogTax) objects that apply to the targeted [CatalogItem]($m/CatalogItem) without having to perform an upsert on the entire item. containing the fields to POST for the request. See the corresponding object definition for field details.

Parameters:

  • body (UpdateItemTaxesRequest)

    Required parameter: An object

Returns:

  • (UpdateItemTaxesResponse Hash)

    response from the API call



578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
# File 'lib/square/api/catalog_api.rb', line 578

def update_item_taxes(body:)
  # Prepare query url.
  _query_builder = config.get_base_uri
  _query_builder << '/v2/catalog/update-item-taxes'
  _query_url = APIHelper.clean_url _query_builder

  # Prepare headers.
  _headers = {
    'accept' => 'application/json',
    'content-type' => 'application/json; charset=utf-8'
  }

  # Prepare and execute HttpRequest.
  _request = config.http_client.post(
    _query_url,
    headers: _headers,
    parameters: body.to_json
  )
  OAuth2.apply(config, _request)
  _response = execute_request(_request)

  # Return appropriate response type.
  decoded = APIHelper.json_deserialize(_response.raw_body)
  _errors = APIHelper.map_response(decoded, ['errors'])
  ApiResponse.new(
    _response, data: decoded, errors: _errors
  )
end

#upsert_catalog_object(body:) ⇒ UpsertCatalogObjectResponse Hash

Creates or updates the target [CatalogObject]($m/CatalogObject). containing the fields to POST for the request. See the corresponding object definition for field details.

Parameters:

  • body (UpsertCatalogObjectRequest)

    Required parameter: An object

Returns:

  • (UpsertCatalogObjectResponse Hash)

    response from the API call



301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
# File 'lib/square/api/catalog_api.rb', line 301

def upsert_catalog_object(body:)
  # Prepare query url.
  _query_builder = config.get_base_uri
  _query_builder << '/v2/catalog/object'
  _query_url = APIHelper.clean_url _query_builder

  # Prepare headers.
  _headers = {
    'accept' => 'application/json',
    'content-type' => 'application/json; charset=utf-8'
  }

  # Prepare and execute HttpRequest.
  _request = config.http_client.post(
    _query_url,
    headers: _headers,
    parameters: body.to_json
  )
  OAuth2.apply(config, _request)
  _response = execute_request(_request)

  # Return appropriate response type.
  decoded = APIHelper.json_deserialize(_response.raw_body)
  _errors = APIHelper.map_response(decoded, ['errors'])
  ApiResponse.new(
    _response, data: decoded, errors: _errors
  )
end