Skip to content
This repository was archived by the owner on Apr 23, 2021. It is now read-only.

Latest commit

 

History

History
602 lines (434 loc) · 25.5 KB

CatalogApi.md

File metadata and controls

602 lines (434 loc) · 25.5 KB

CatalogApi

All URIs are relative to https://connect.squareup.com

Method HTTP request Description
batchDeleteCatalogObjects POST /v2/catalog/batch-delete BatchDeleteCatalogObjects
batchRetrieveCatalogObjects POST /v2/catalog/batch-retrieve BatchRetrieveCatalogObjects
batchUpsertCatalogObjects POST /v2/catalog/batch-upsert BatchUpsertCatalogObjects
catalogInfo GET /v2/catalog/info CatalogInfo
deleteCatalogObject DELETE /v2/catalog/object/{object_id} DeleteCatalogObject
listCatalog GET /v2/catalog/list ListCatalog
retrieveCatalogObject GET /v2/catalog/object/{object_id} RetrieveCatalogObject
searchCatalogObjects POST /v2/catalog/search SearchCatalogObjects
updateItemModifierLists POST /v2/catalog/update-item-modifier-lists UpdateItemModifierLists
updateItemTaxes POST /v2/catalog/update-item-taxes UpdateItemTaxes
upsertCatalogObject POST /v2/catalog/object UpsertCatalogObject

batchDeleteCatalogObjects

BatchDeleteCatalogObjectsResponse batchDeleteCatalogObjects(body)

BatchDeleteCatalogObjects

Deletes a set of CatalogItems 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 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.

Example

// Import classes:
//import com.squareup.connect.ApiClient;
//import com.squareup.connect.ApiException;
//import com.squareup.connect.Configuration;
//import com.squareup.connect.auth.*;
//import com.squareup.connect.api.CatalogApi;

ApiClient defaultClient = Configuration.getDefaultApiClient();

// Configure OAuth2 access token for authorization: oauth2
OAuth oauth2 = (OAuth) defaultClient.getAuthentication("oauth2");
oauth2.setAccessToken("YOUR ACCESS TOKEN");

CatalogApi apiInstance = new CatalogApi();
BatchDeleteCatalogObjectsRequest body = new BatchDeleteCatalogObjectsRequest(); // BatchDeleteCatalogObjectsRequest | An object containing the fields to POST for the request.  See the corresponding object definition for field details.
try {
    BatchDeleteCatalogObjectsResponse result = apiInstance.batchDeleteCatalogObjects(body);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling CatalogApi#batchDeleteCatalogObjects");
    e.printStackTrace();
}

Parameters

Name Type Description Notes
body BatchDeleteCatalogObjectsRequest An object containing the fields to POST for the request. See the corresponding object definition for field details.

Return type

BatchDeleteCatalogObjectsResponse

Authorization

oauth2

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

batchRetrieveCatalogObjects

BatchRetrieveCatalogObjectsResponse batchRetrieveCatalogObjects(body)

BatchRetrieveCatalogObjects

Returns a set of objects based on the provided ID. Each CatalogItem returned in the set includes all of its child information including: all of its CatalogItemVariation objects, references to its CatalogModifierList objects, and the ids of any CatalogTax objects that apply to it.

Example

// Import classes:
//import com.squareup.connect.ApiClient;
//import com.squareup.connect.ApiException;
//import com.squareup.connect.Configuration;
//import com.squareup.connect.auth.*;
//import com.squareup.connect.api.CatalogApi;

ApiClient defaultClient = Configuration.getDefaultApiClient();

// Configure OAuth2 access token for authorization: oauth2
OAuth oauth2 = (OAuth) defaultClient.getAuthentication("oauth2");
oauth2.setAccessToken("YOUR ACCESS TOKEN");

CatalogApi apiInstance = new CatalogApi();
BatchRetrieveCatalogObjectsRequest body = new BatchRetrieveCatalogObjectsRequest(); // BatchRetrieveCatalogObjectsRequest | An object containing the fields to POST for the request.  See the corresponding object definition for field details.
try {
    BatchRetrieveCatalogObjectsResponse result = apiInstance.batchRetrieveCatalogObjects(body);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling CatalogApi#batchRetrieveCatalogObjects");
    e.printStackTrace();
}

Parameters

Name Type Description Notes
body BatchRetrieveCatalogObjectsRequest An object containing the fields to POST for the request. See the corresponding object definition for field details.

Return type

BatchRetrieveCatalogObjectsResponse

Authorization

oauth2

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

batchUpsertCatalogObjects

BatchUpsertCatalogObjectsResponse batchUpsertCatalogObjects(body)

BatchUpsertCatalogObjects

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.

Example

// Import classes:
//import com.squareup.connect.ApiClient;
//import com.squareup.connect.ApiException;
//import com.squareup.connect.Configuration;
//import com.squareup.connect.auth.*;
//import com.squareup.connect.api.CatalogApi;

ApiClient defaultClient = Configuration.getDefaultApiClient();

// Configure OAuth2 access token for authorization: oauth2
OAuth oauth2 = (OAuth) defaultClient.getAuthentication("oauth2");
oauth2.setAccessToken("YOUR ACCESS TOKEN");

CatalogApi apiInstance = new CatalogApi();
BatchUpsertCatalogObjectsRequest body = new BatchUpsertCatalogObjectsRequest(); // BatchUpsertCatalogObjectsRequest | An object containing the fields to POST for the request.  See the corresponding object definition for field details.
try {
    BatchUpsertCatalogObjectsResponse result = apiInstance.batchUpsertCatalogObjects(body);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling CatalogApi#batchUpsertCatalogObjects");
    e.printStackTrace();
}

Parameters

Name Type Description Notes
body BatchUpsertCatalogObjectsRequest An object containing the fields to POST for the request. See the corresponding object definition for field details.

Return type

BatchUpsertCatalogObjectsResponse

Authorization

oauth2

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

catalogInfo

CatalogInfoResponse catalogInfo()

CatalogInfo

Returns information about the Square Catalog API, such as batch size limits for `BatchUpsertCatalogObjects`.

Example

// Import classes:
//import com.squareup.connect.ApiClient;
//import com.squareup.connect.ApiException;
//import com.squareup.connect.Configuration;
//import com.squareup.connect.auth.*;
//import com.squareup.connect.api.CatalogApi;

ApiClient defaultClient = Configuration.getDefaultApiClient();

// Configure OAuth2 access token for authorization: oauth2
OAuth oauth2 = (OAuth) defaultClient.getAuthentication("oauth2");
oauth2.setAccessToken("YOUR ACCESS TOKEN");

CatalogApi apiInstance = new CatalogApi();
try {
    CatalogInfoResponse result = apiInstance.catalogInfo();
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling CatalogApi#catalogInfo");
    e.printStackTrace();
}

Parameters

This endpoint does not need any parameter.

Return type

CatalogInfoResponse

Authorization

oauth2

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

deleteCatalogObject

DeleteCatalogObjectResponse deleteCatalogObject(objectId)

DeleteCatalogObject

Deletes a single 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 will also delete all of its CatalogItemVariation children.

Example

// Import classes:
//import com.squareup.connect.ApiClient;
//import com.squareup.connect.ApiException;
//import com.squareup.connect.Configuration;
//import com.squareup.connect.auth.*;
//import com.squareup.connect.api.CatalogApi;

ApiClient defaultClient = Configuration.getDefaultApiClient();

// Configure OAuth2 access token for authorization: oauth2
OAuth oauth2 = (OAuth) defaultClient.getAuthentication("oauth2");
oauth2.setAccessToken("YOUR ACCESS TOKEN");

CatalogApi apiInstance = new CatalogApi();
String objectId = "objectId_example"; // String | The ID of the catalog object 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).
try {
    DeleteCatalogObjectResponse result = apiInstance.deleteCatalogObject(objectId);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling CatalogApi#deleteCatalogObject");
    e.printStackTrace();
}

Parameters

Name Type Description Notes
objectId String The ID of the catalog object 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).

Return type

DeleteCatalogObjectResponse

Authorization

oauth2

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

listCatalog

ListCatalogResponse listCatalog(cursor, types)

ListCatalog

Returns a list of CatalogObjects that includes all objects of a set of desired types (for example, all CatalogItem and CatalogTax objects) in the catalog. The `types` parameter is specified as a comma-separated list of valid 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 and set `include_deleted_objects` to `true`.

Example

// Import classes:
//import com.squareup.connect.ApiClient;
//import com.squareup.connect.ApiException;
//import com.squareup.connect.Configuration;
//import com.squareup.connect.auth.*;
//import com.squareup.connect.api.CatalogApi;

ApiClient defaultClient = Configuration.getDefaultApiClient();

// Configure OAuth2 access token for authorization: oauth2
OAuth oauth2 = (OAuth) defaultClient.getAuthentication("oauth2");
oauth2.setAccessToken("YOUR ACCESS TOKEN");

CatalogApi apiInstance = new CatalogApi();
String cursor = "cursor_example"; // String | The pagination cursor returned in the previous response. Leave unset for an initial request. See [Pagination](https://developer.squareup.com/docs/basics/api101/pagination) for more information.
String types = "types_example"; // String | An optional case-insensitive, comma-separated list of object types to retrieve, for example `ITEM,ITEM_VARIATION,CATEGORY,IMAGE`.  The legal values are taken from the CatalogObjectType enum: `ITEM`, `ITEM_VARIATION`, `CATEGORY`, `DISCOUNT`, `TAX`, `MODIFIER`, `MODIFIER_LIST`, or `IMAGE`.
try {
    ListCatalogResponse result = apiInstance.listCatalog(cursor, types);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling CatalogApi#listCatalog");
    e.printStackTrace();
}

Parameters

Name Type Description Notes
cursor String The pagination cursor returned in the previous response. Leave unset for an initial request. See Pagination for more information. [optional]
types String An optional case-insensitive, comma-separated list of object types to retrieve, for example `ITEM,ITEM_VARIATION,CATEGORY,IMAGE`. The legal values are taken from the CatalogObjectType enum: `ITEM`, `ITEM_VARIATION`, `CATEGORY`, `DISCOUNT`, `TAX`, `MODIFIER`, `MODIFIER_LIST`, or `IMAGE`. [optional]

Return type

ListCatalogResponse

Authorization

oauth2

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

retrieveCatalogObject

RetrieveCatalogObjectResponse retrieveCatalogObject(objectId, includeRelatedObjects)

RetrieveCatalogObject

Returns a single CatalogItem as a CatalogObject based on the provided ID. The returned object includes all of the relevant CatalogItem information including: CatalogItemVariation children, references to its CatalogModifierList objects, and the ids of any CatalogTax objects that apply to it.

Example

// Import classes:
//import com.squareup.connect.ApiClient;
//import com.squareup.connect.ApiException;
//import com.squareup.connect.Configuration;
//import com.squareup.connect.auth.*;
//import com.squareup.connect.api.CatalogApi;

ApiClient defaultClient = Configuration.getDefaultApiClient();

// Configure OAuth2 access token for authorization: oauth2
OAuth oauth2 = (OAuth) defaultClient.getAuthentication("oauth2");
oauth2.setAccessToken("YOUR ACCESS TOKEN");

CatalogApi apiInstance = new CatalogApi();
String objectId = "objectId_example"; // String | The object ID of any type of catalog objects to be retrieved.
Boolean includeRelatedObjects = true; // Boolean | If `true`, 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 objects, CatalogImages and CatalogModifierLists 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`
try {
    RetrieveCatalogObjectResponse result = apiInstance.retrieveCatalogObject(objectId, includeRelatedObjects);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling CatalogApi#retrieveCatalogObject");
    e.printStackTrace();
}

Parameters

Name Type Description Notes
objectId String The object ID of any type of catalog objects to be retrieved.
includeRelatedObjects Boolean If `true`, 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 objects, CatalogImages and CatalogModifierLists 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` [optional]

Return type

RetrieveCatalogObjectResponse

Authorization

oauth2

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

searchCatalogObjects

SearchCatalogObjectsResponse searchCatalogObjects(body)

SearchCatalogObjects

Queries the targeted catalog using a variety of query types: CatalogQuerySortedAttribute, CatalogQueryExact, CatalogQueryRange, CatalogQueryText, CatalogQueryItemsForTax, and CatalogQueryItemsForModifierList. -- -- Future end of the above comment: CatalogQueryItemsForTax, CatalogQueryItemsForModifierList, CatalogQueryItemsForItemOptions, and CatalogQueryItemVariationsForItemOptionValues.

Example

// Import classes:
//import com.squareup.connect.ApiClient;
//import com.squareup.connect.ApiException;
//import com.squareup.connect.Configuration;
//import com.squareup.connect.auth.*;
//import com.squareup.connect.api.CatalogApi;

ApiClient defaultClient = Configuration.getDefaultApiClient();

// Configure OAuth2 access token for authorization: oauth2
OAuth oauth2 = (OAuth) defaultClient.getAuthentication("oauth2");
oauth2.setAccessToken("YOUR ACCESS TOKEN");

CatalogApi apiInstance = new CatalogApi();
SearchCatalogObjectsRequest body = new SearchCatalogObjectsRequest(); // SearchCatalogObjectsRequest | An object containing the fields to POST for the request.  See the corresponding object definition for field details.
try {
    SearchCatalogObjectsResponse result = apiInstance.searchCatalogObjects(body);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling CatalogApi#searchCatalogObjects");
    e.printStackTrace();
}

Parameters

Name Type Description Notes
body SearchCatalogObjectsRequest An object containing the fields to POST for the request. See the corresponding object definition for field details.

Return type

SearchCatalogObjectsResponse

Authorization

oauth2

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

updateItemModifierLists

UpdateItemModifierListsResponse updateItemModifierLists(body)

UpdateItemModifierLists

Updates the CatalogModifierList objects that apply to the targeted CatalogItem without having to perform an upsert on the entire item.

Example

// Import classes:
//import com.squareup.connect.ApiClient;
//import com.squareup.connect.ApiException;
//import com.squareup.connect.Configuration;
//import com.squareup.connect.auth.*;
//import com.squareup.connect.api.CatalogApi;

ApiClient defaultClient = Configuration.getDefaultApiClient();

// Configure OAuth2 access token for authorization: oauth2
OAuth oauth2 = (OAuth) defaultClient.getAuthentication("oauth2");
oauth2.setAccessToken("YOUR ACCESS TOKEN");

CatalogApi apiInstance = new CatalogApi();
UpdateItemModifierListsRequest body = new UpdateItemModifierListsRequest(); // UpdateItemModifierListsRequest | An object containing the fields to POST for the request.  See the corresponding object definition for field details.
try {
    UpdateItemModifierListsResponse result = apiInstance.updateItemModifierLists(body);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling CatalogApi#updateItemModifierLists");
    e.printStackTrace();
}

Parameters

Name Type Description Notes
body UpdateItemModifierListsRequest An object containing the fields to POST for the request. See the corresponding object definition for field details.

Return type

UpdateItemModifierListsResponse

Authorization

oauth2

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

updateItemTaxes

UpdateItemTaxesResponse updateItemTaxes(body)

UpdateItemTaxes

Updates the CatalogTax objects that apply to the targeted CatalogItem without having to perform an upsert on the entire item.

Example

// Import classes:
//import com.squareup.connect.ApiClient;
//import com.squareup.connect.ApiException;
//import com.squareup.connect.Configuration;
//import com.squareup.connect.auth.*;
//import com.squareup.connect.api.CatalogApi;

ApiClient defaultClient = Configuration.getDefaultApiClient();

// Configure OAuth2 access token for authorization: oauth2
OAuth oauth2 = (OAuth) defaultClient.getAuthentication("oauth2");
oauth2.setAccessToken("YOUR ACCESS TOKEN");

CatalogApi apiInstance = new CatalogApi();
UpdateItemTaxesRequest body = new UpdateItemTaxesRequest(); // UpdateItemTaxesRequest | An object containing the fields to POST for the request.  See the corresponding object definition for field details.
try {
    UpdateItemTaxesResponse result = apiInstance.updateItemTaxes(body);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling CatalogApi#updateItemTaxes");
    e.printStackTrace();
}

Parameters

Name Type Description Notes
body UpdateItemTaxesRequest An object containing the fields to POST for the request. See the corresponding object definition for field details.

Return type

UpdateItemTaxesResponse

Authorization

oauth2

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

upsertCatalogObject

UpsertCatalogObjectResponse upsertCatalogObject(body)

UpsertCatalogObject

Creates or updates the target CatalogObject.

Example

// Import classes:
//import com.squareup.connect.ApiClient;
//import com.squareup.connect.ApiException;
//import com.squareup.connect.Configuration;
//import com.squareup.connect.auth.*;
//import com.squareup.connect.api.CatalogApi;

ApiClient defaultClient = Configuration.getDefaultApiClient();

// Configure OAuth2 access token for authorization: oauth2
OAuth oauth2 = (OAuth) defaultClient.getAuthentication("oauth2");
oauth2.setAccessToken("YOUR ACCESS TOKEN");

CatalogApi apiInstance = new CatalogApi();
UpsertCatalogObjectRequest body = new UpsertCatalogObjectRequest(); // UpsertCatalogObjectRequest | An object containing the fields to POST for the request.  See the corresponding object definition for field details.
try {
    UpsertCatalogObjectResponse result = apiInstance.upsertCatalogObject(body);
    System.out.println(result);
} catch (ApiException e) {
    System.err.println("Exception when calling CatalogApi#upsertCatalogObject");
    e.printStackTrace();
}

Parameters

Name Type Description Notes
body UpsertCatalogObjectRequest An object containing the fields to POST for the request. See the corresponding object definition for field details.

Return type

UpsertCatalogObjectResponse

Authorization

oauth2

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json