const catalogApi = client.catalogApi;
CatalogApi
- Batch Delete Catalog Objects
- Batch Retrieve Catalog Objects
- Batch Upsert Catalog Objects
- Create Catalog Image
- Update Catalog Image
- Catalog Info
- List Catalog
- Upsert Catalog Object
- Delete Catalog Object
- Retrieve Catalog Object
- Search Catalog Objects
- Search Catalog Items
- Update Item Modifier Lists
- Update Item Taxes
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.
async batchDeleteCatalogObjects(
body: BatchDeleteCatalogObjectsRequest,
requestOptions?: RequestOptions
): Promise<ApiResponse<BatchDeleteCatalogObjectsResponse>>
Parameter | Type | Tags | Description |
---|---|---|---|
body |
BatchDeleteCatalogObjectsRequest |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
requestOptions |
RequestOptions | undefined |
Optional | Pass additional request options. |
BatchDeleteCatalogObjectsResponse
const contentType = null;
const bodyObjectIds: string[] = ['W62UWFY35CWMYGVWK6TWJDNI', 'AA27W3M2GGTF3H6AVPNB77CK'];
const body: BatchDeleteCatalogObjectsRequest = {};
body.objectIds = bodyObjectIds;
try {
const { result, ...httpResponse } = await catalogApi.batchDeleteCatalogObjects(body);
// Get more response info...
// const { statusCode, headers } = httpResponse;
} catch(error) {
if (error instanceof ApiError) {
const errors = error.result;
// const { statusCode, headers } = error;
}
}
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.
async batchRetrieveCatalogObjects(
body: BatchRetrieveCatalogObjectsRequest,
requestOptions?: RequestOptions
): Promise<ApiResponse<BatchRetrieveCatalogObjectsResponse>>
Parameter | Type | Tags | Description |
---|---|---|---|
body |
BatchRetrieveCatalogObjectsRequest |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
requestOptions |
RequestOptions | undefined |
Optional | Pass additional request options. |
BatchRetrieveCatalogObjectsResponse
const contentType = null;
const bodyObjectIds: string[] = ['W62UWFY35CWMYGVWK6TWJDNI', 'AA27W3M2GGTF3H6AVPNB77CK'];
const body: BatchRetrieveCatalogObjectsRequest = {
objectIds: bodyObjectIds,
};
body.includeRelatedObjects = true;
try {
const { result, ...httpResponse } = await catalogApi.batchRetrieveCatalogObjects(body);
// Get more response info...
// const { statusCode, headers } = httpResponse;
} catch(error) {
if (error instanceof ApiError) {
const errors = error.result;
// const { statusCode, headers } = error;
}
}
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.
async batchUpsertCatalogObjects(
body: BatchUpsertCatalogObjectsRequest,
requestOptions?: RequestOptions
): Promise<ApiResponse<BatchUpsertCatalogObjectsResponse>>
Parameter | Type | Tags | Description |
---|---|---|---|
body |
BatchUpsertCatalogObjectsRequest |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
requestOptions |
RequestOptions | undefined |
Optional | Pass additional request options. |
BatchUpsertCatalogObjectsResponse
const contentType = null;
const bodyBatches: CatalogObjectBatch[] = [];
const bodybatches0Objects: CatalogObject[] = [];
const bodybatches0objects0Type: string = {'' : null, '' : null, '' : null, '' : null } const bodybatches0objects0ItemDataTaxIds: string[] = ['#SalesTax'];
const bodybatches0objects0ItemDataVariations: CatalogObject[] = [];
const bodybatches0objects0ItemDatavariations0Type: string = {'' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null } const bodybatches0objects0ItemDatavariations0ItemVariationDataPricingType: string = {'' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null } const bodybatches0objects0ItemDatavariations0ItemVariationData: CatalogItemVariation = {};
bodybatches0objects0ItemDatavariations0ItemVariationData.itemId = '#Tea';
bodybatches0objects0ItemDatavariations0ItemVariationData.name = 'Mug';
bodybatches0objects0ItemDatavariations0ItemVariationData.pricingType = bodybatches0objects0ItemDatavariations0ItemVariationDataPricingType;
const bodybatches0objects0ItemDatavariations0: CatalogObject = {
type: bodybatches0objects0ItemDatavariations0Type,
id: '#Tea_Mug',
};
bodybatches0objects0ItemDatavariations0.presentAtAllLocations = true;
bodybatches0objects0ItemDatavariations0.itemVariationData = bodybatches0objects0ItemDatavariations0ItemVariationData;
bodybatches0objects0ItemDataVariations[0] = bodybatches0objects0ItemDatavariations0;
const bodybatches0objects0ItemData: CatalogItem = {};
bodybatches0objects0ItemData.name = 'Tea';
bodybatches0objects0ItemData.categoryId = '#Beverages';
bodybatches0objects0ItemData.taxIds = bodybatches0objects0ItemDataTaxIds;
bodybatches0objects0ItemData.variations = bodybatches0objects0ItemDataVariations;
bodybatches0objects0ItemData.descriptionHtml = '<p><strong>Hot</strong> Leaf Juice</p>';
const bodybatches0objects0: CatalogObject = {
type: bodybatches0objects0Type,
id: '#Tea',
};
bodybatches0objects0.presentAtAllLocations = true;
bodybatches0objects0.itemData = bodybatches0objects0ItemData;
bodybatches0Objects[0] = bodybatches0objects0;
const bodybatches0objects1Type: string = {'' : null, '' : null, '' : null, '' : null } const bodybatches0objects1ItemDataTaxIds: string[] = ['#SalesTax'];
const bodybatches0objects1ItemDataVariations: CatalogObject[] = [];
const bodybatches0objects1ItemDatavariations0Type: string = {'' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null } const bodybatches0objects1ItemDatavariations0ItemVariationDataPricingType: string = {'' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null } const bodybatches0objects1ItemDatavariations0ItemVariationData: CatalogItemVariation = {};
bodybatches0objects1ItemDatavariations0ItemVariationData.itemId = '#Coffee';
bodybatches0objects1ItemDatavariations0ItemVariationData.name = 'Regular';
bodybatches0objects1ItemDatavariations0ItemVariationData.pricingType = bodybatches0objects1ItemDatavariations0ItemVariationDataPricingType;
const bodybatches0objects1ItemDatavariations0: CatalogObject = {
type: bodybatches0objects1ItemDatavariations0Type,
id: '#Coffee_Regular',
};
bodybatches0objects1ItemDatavariations0.presentAtAllLocations = true;
bodybatches0objects1ItemDatavariations0.itemVariationData = bodybatches0objects1ItemDatavariations0ItemVariationData;
bodybatches0objects1ItemDataVariations[0] = bodybatches0objects1ItemDatavariations0;
const bodybatches0objects1ItemDatavariations1Type: string = {'' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null } const bodybatches0objects1ItemDatavariations1ItemVariationDataPricingType: string = {'' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null } const bodybatches0objects1ItemDatavariations1ItemVariationData: CatalogItemVariation = {};
bodybatches0objects1ItemDatavariations1ItemVariationData.itemId = '#Coffee';
bodybatches0objects1ItemDatavariations1ItemVariationData.name = 'Large';
bodybatches0objects1ItemDatavariations1ItemVariationData.pricingType = bodybatches0objects1ItemDatavariations1ItemVariationDataPricingType;
const bodybatches0objects1ItemDatavariations1: CatalogObject = {
type: bodybatches0objects1ItemDatavariations1Type,
id: '#Coffee_Large',
};
bodybatches0objects1ItemDatavariations1.presentAtAllLocations = true;
bodybatches0objects1ItemDatavariations1.itemVariationData = bodybatches0objects1ItemDatavariations1ItemVariationData;
bodybatches0objects1ItemDataVariations[1] = bodybatches0objects1ItemDatavariations1;
const bodybatches0objects1ItemData: CatalogItem = {};
bodybatches0objects1ItemData.name = 'Coffee';
bodybatches0objects1ItemData.categoryId = '#Beverages';
bodybatches0objects1ItemData.taxIds = bodybatches0objects1ItemDataTaxIds;
bodybatches0objects1ItemData.variations = bodybatches0objects1ItemDataVariations;
bodybatches0objects1ItemData.descriptionHtml = '<p>Hot <em>Bean Juice</em></p>';
const bodybatches0objects1: CatalogObject = {
type: bodybatches0objects1Type,
id: '#Coffee',
};
bodybatches0objects1.presentAtAllLocations = true;
bodybatches0objects1.itemData = bodybatches0objects1ItemData;
bodybatches0Objects[1] = bodybatches0objects1;
const bodybatches0objects2Type: string = {'' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null } const bodybatches0objects2CategoryData: CatalogCategory = {};
bodybatches0objects2CategoryData.name = 'Beverages';
const bodybatches0objects2: CatalogObject = {
type: bodybatches0objects2Type,
id: '#Beverages',
};
bodybatches0objects2.presentAtAllLocations = true;
bodybatches0objects2.categoryData = bodybatches0objects2CategoryData;
bodybatches0Objects[2] = bodybatches0objects2;
const bodybatches0objects3Type: string = {'' : null, '' : null, '' : null } const bodybatches0objects3TaxDataCalculationPhase: string = {'' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null } const bodybatches0objects3TaxDataInclusionType: string = {'' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null } const bodybatches0objects3TaxData: CatalogTax = {};
bodybatches0objects3TaxData.name = 'Sales Tax';
bodybatches0objects3TaxData.calculationPhase = bodybatches0objects3TaxDataCalculationPhase;
bodybatches0objects3TaxData.inclusionType = bodybatches0objects3TaxDataInclusionType;
bodybatches0objects3TaxData.percentage = '5.0';
bodybatches0objects3TaxData.appliesToCustomAmounts = true;
bodybatches0objects3TaxData.enabled = true;
const bodybatches0objects3: CatalogObject = {
type: bodybatches0objects3Type,
id: '#SalesTax',
};
bodybatches0objects3.presentAtAllLocations = true;
bodybatches0objects3.taxData = bodybatches0objects3TaxData;
bodybatches0Objects[3] = bodybatches0objects3;
const bodybatches0: CatalogObjectBatch = {
objects: bodybatches0Objects,
};
bodyBatches[0] = bodybatches0;
const body: BatchUpsertCatalogObjectsRequest = {
idempotencyKey: '789ff020-f723-43a9-b4b5-43b5dc1fa3dc',
batches: bodyBatches,
};
try {
const { result, ...httpResponse } = await catalogApi.batchUpsertCatalogObjects(body);
// Get more response info...
// const { statusCode, headers } = httpResponse;
} catch(error) {
if (error instanceof ApiError) {
const errors = error.result;
// const { statusCode, headers } = error;
}
}
Uploads an image file to be represented by a CatalogImage object that can be linked to an existing
CatalogObject instance. The resulting CatalogImage
is unattached to any CatalogObject
if the object_id
is not specified.
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.
async createCatalogImage(
request?: CreateCatalogImageRequest,
imageFile?: FileWrapper,
requestOptions?: RequestOptions
): Promise<ApiResponse<CreateCatalogImageResponse>>
Parameter | Type | Tags | Description |
---|---|---|---|
request |
CreateCatalogImageRequest | undefined |
Form (JSON-Encoded), Optional | - |
imageFile |
FileWrapper | undefined |
Form, Optional | - |
requestOptions |
RequestOptions | undefined |
Optional | Pass additional request options. |
const requestImageType: string = {'' : null, '' : null, '' : null, '' : null, '' : null } const requestImageImageData: CatalogImage = {};
requestImageImageData.caption = 'A picture of a cup of coffee';
const requestImage: CatalogObject = {
type: requestImageType,
id: '#TEMP_ID',
};
requestImage.imageData = requestImageImageData;
const request: CreateCatalogImageRequest = {
idempotencyKey: '528dea59-7bfb-43c1-bd48-4a6bba7dd61f86',
image: requestImage,
};
request.objectId = 'ND6EA5AAJEO5WL3JNNIAQA32';
try {
const { result, ...httpResponse } = await catalogApi.createCatalogImage(request);
// Get more response info...
// const { statusCode, headers } = httpResponse;
} catch(error) {
if (error instanceof ApiError) {
const errors = error.result;
// const { statusCode, headers } = error;
}
}
Uploads a new image file to replace the existing one in the specified CatalogImage object.
This UpdateCatalogImage
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.
async updateCatalogImage(
imageId: string,
request?: UpdateCatalogImageRequest,
imageFile?: FileWrapper,
requestOptions?: RequestOptions
): Promise<ApiResponse<UpdateCatalogImageResponse>>
Parameter | Type | Tags | Description |
---|---|---|---|
imageId |
string |
Template, Required | The ID of the CatalogImage object to update the encapsulated image file. |
request |
UpdateCatalogImageRequest | undefined |
Form (JSON-Encoded), Optional | - |
imageFile |
FileWrapper | undefined |
Form, Optional | - |
requestOptions |
RequestOptions | undefined |
Optional | Pass additional request options. |
const imageId = 'image_id4';
const request: UpdateCatalogImageRequest = {
idempotencyKey: '528dea59-7bfb-43c1-bd48-4a6bba7dd61f86',
};
try {
const { result, ...httpResponse } = await catalogApi.updateCatalogImage(imageId, request);
// Get more response info...
// const { statusCode, headers } = httpResponse;
} catch(error) {
if (error instanceof ApiError) {
const errors = error.result;
// const { statusCode, headers } = error;
}
}
Retrieves information about the Square Catalog API, such as batch size
limits that can be used by the BatchUpsertCatalogObjects
endpoint.
async catalogInfo(
requestOptions?: RequestOptions
): Promise<ApiResponse<CatalogInfoResponse>>
Parameter | Type | Tags | Description |
---|---|---|---|
requestOptions |
RequestOptions | undefined |
Optional | Pass additional request options. |
try {
const { result, ...httpResponse } = await catalogApi.catalogInfo();
// Get more response info...
// const { statusCode, headers } = httpResponse;
} catch(error) {
if (error instanceof ApiError) {
const errors = error.result;
// const { statusCode, headers } = error;
}
}
Returns a list of all CatalogObjects of the specified types in the catalog.
The types
parameter is specified as a comma-separated list of the CatalogObjectType values,
for example, "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 the include_deleted_objects
attribute value to true
.
async listCatalog(
cursor?: string,
types?: string,
catalogVersion?: bigint,
requestOptions?: RequestOptions
): Promise<ApiResponse<ListCatalogResponse>>
Parameter | Type | Tags | Description |
---|---|---|---|
cursor |
string | undefined |
Query, Optional | The pagination cursor returned in the previous response. Leave unset for an initial request. The page size is currently set to be 100. See Pagination for more information. |
types |
string | undefined |
Query, Optional | An optional case-insensitive, comma-separated list of object types to retrieve. The valid values are defined in the CatalogObjectType enum, for example, ITEM , ITEM_VARIATION , CATEGORY , DISCOUNT , TAX ,MODIFIER , MODIFIER_LIST , IMAGE , etc.If this is unspecified, the operation returns objects of all the top level types at the version of the Square API used to make the request. Object types that are nested onto other object types are not included in the defaults. At the current API version the default object types are: ITEM, CATEGORY, TAX, DISCOUNT, MODIFIER_LIST, PRICING_RULE, PRODUCT_SET, TIME_PERIOD, MEASUREMENT_UNIT, SUBSCRIPTION_PLAN, ITEM_OPTION, CUSTOM_ATTRIBUTE_DEFINITION, QUICK_AMOUNT_SETTINGS. |
catalogVersion |
bigint | undefined |
Query, Optional | The specific version of 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 CatalogObjects' version attribute. If not included, results willbe from the current version of the catalog. |
requestOptions |
RequestOptions | undefined |
Optional | Pass additional request options. |
try {
const { result, ...httpResponse } = await catalogApi.listCatalog();
// Get more response info...
// const { statusCode, headers } = httpResponse;
} catch(error) {
if (error instanceof ApiError) {
const errors = error.result;
// const { statusCode, headers } = error;
}
}
Creates or updates the target CatalogObject.
async upsertCatalogObject(
body: UpsertCatalogObjectRequest,
requestOptions?: RequestOptions
): Promise<ApiResponse<UpsertCatalogObjectResponse>>
Parameter | Type | Tags | Description |
---|---|---|---|
body |
UpsertCatalogObjectRequest |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
requestOptions |
RequestOptions | undefined |
Optional | Pass additional request options. |
const contentType = null;
const bodyObjectType: string = {'' : null, '' : null, '' : null, '' : null } const bodyObjectItemDataVariations: CatalogObject[] = [];
const bodyObjectItemDatavariations0Type: string = {'' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null } const bodyObjectItemDatavariations0ItemVariationDataPricingType: string = {'' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null } const bodyObjectItemDatavariations0ItemVariationData: CatalogItemVariation = {};
bodyObjectItemDatavariations0ItemVariationData.itemId = '#Cocoa';
bodyObjectItemDatavariations0ItemVariationData.name = 'Small';
bodyObjectItemDatavariations0ItemVariationData.pricingType = bodyObjectItemDatavariations0ItemVariationDataPricingType;
const bodyObjectItemDatavariations0: CatalogObject = {
type: bodyObjectItemDatavariations0Type,
id: '#Small',
};
bodyObjectItemDatavariations0.itemVariationData = bodyObjectItemDatavariations0ItemVariationData;
bodyObjectItemDataVariations[0] = bodyObjectItemDatavariations0;
const bodyObjectItemDatavariations1Type: string = {'' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null } const bodyObjectItemDatavariations1ItemVariationDataPricingType: string = {'' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null, '' : null } const bodyObjectItemDatavariations1ItemVariationDataPriceMoneyCurrency: string = {'' : null, '' : null, '' : null } const bodyObjectItemDatavariations1ItemVariationDataPriceMoney: Money = {};
bodyObjectItemDatavariations1ItemVariationDataPriceMoney.amount = BigInt(400);
bodyObjectItemDatavariations1ItemVariationDataPriceMoney.currency = bodyObjectItemDatavariations1ItemVariationDataPriceMoneyCurrency;
const bodyObjectItemDatavariations1ItemVariationData: CatalogItemVariation = {};
bodyObjectItemDatavariations1ItemVariationData.itemId = '#Cocoa';
bodyObjectItemDatavariations1ItemVariationData.name = 'Large';
bodyObjectItemDatavariations1ItemVariationData.pricingType = bodyObjectItemDatavariations1ItemVariationDataPricingType;
bodyObjectItemDatavariations1ItemVariationData.priceMoney = bodyObjectItemDatavariations1ItemVariationDataPriceMoney;
const bodyObjectItemDatavariations1: CatalogObject = {
type: bodyObjectItemDatavariations1Type,
id: '#Large',
};
bodyObjectItemDatavariations1.itemVariationData = bodyObjectItemDatavariations1ItemVariationData;
bodyObjectItemDataVariations[1] = bodyObjectItemDatavariations1;
const bodyObjectItemData: CatalogItem = {};
bodyObjectItemData.name = 'Cocoa';
bodyObjectItemData.abbreviation = 'Ch';
bodyObjectItemData.variations = bodyObjectItemDataVariations;
bodyObjectItemData.descriptionHtml = '<p><strong>Hot</strong> Chocolate</p>';
const bodyObject: CatalogObject = {
type: bodyObjectType,
id: '#Cocoa',
};
bodyObject.itemData = bodyObjectItemData;
const body: UpsertCatalogObjectRequest = {
idempotencyKey: 'af3d1afc-7212-4300-b463-0bfc5314a5ae',
object: bodyObject,
};
try {
const { result, ...httpResponse } = await catalogApi.upsertCatalogObject(body);
// Get more response info...
// const { statusCode, headers } = httpResponse;
} catch(error) {
if (error instanceof ApiError) {
const errors = error.result;
// const { statusCode, headers } = error;
}
}
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.
async deleteCatalogObject(
objectId: string,
requestOptions?: RequestOptions
): Promise<ApiResponse<DeleteCatalogObjectResponse>>
Parameter | Type | Tags | Description |
---|---|---|---|
objectId |
string |
Template, Required | 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). |
requestOptions |
RequestOptions | undefined |
Optional | Pass additional request options. |
const objectId = 'object_id8';
try {
const { result, ...httpResponse } = await catalogApi.deleteCatalogObject(objectId);
// Get more response info...
// const { statusCode, headers } = httpResponse;
} catch(error) {
if (error instanceof ApiError) {
const errors = error.result;
// const { statusCode, headers } = error;
}
}
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.
async retrieveCatalogObject(
objectId: string,
includeRelatedObjects?: boolean,
catalogVersion?: bigint,
requestOptions?: RequestOptions
): Promise<ApiResponse<RetrieveCatalogObjectResponse>>
Parameter | Type | Tags | Description |
---|---|---|---|
objectId |
string |
Template, Required | The object ID of any type of catalog objects to be retrieved. |
includeRelatedObjects |
boolean | undefined |
Query, Optional | If true , the response will include additional objects that are related to therequested objects. Related objects are defined as any objects referenced by ID by the results in the objects fieldof the response. These objects are put in the related_objects field. Setting this to true ishelpful when the objects are needed for immediate display to a user. This process only goes one level deep. Objects referenced by the related objects will not be included. For example, if the objects field of the response contains a CatalogItem, its associatedCatalogCategory objects, CatalogTax objects, CatalogImage objects and CatalogModifierLists will be returned in the related_objects field of theresponse. If the objects field of the response contains a CatalogItemVariation,its parent CatalogItem will be returned in the related_objects field ofthe response. Default value: false Default: false |
catalogVersion |
bigint | undefined |
Query, Optional | Requests objects as of a 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 CatalogObjects. If not included, results will be from the current version of the catalog. |
requestOptions |
RequestOptions | undefined |
Optional | Pass additional request options. |
const objectId = 'object_id8';
const includeRelatedObjects = false;
try {
const { result, ...httpResponse } = await catalogApi.retrieveCatalogObject(objectId, includeRelatedObjects);
// Get more response info...
// const { statusCode, headers } = httpResponse;
} catch(error) {
if (error instanceof ApiError) {
const errors = error.result;
// const { statusCode, headers } = error;
}
}
Searches for 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
endpoint in the following aspects:
SearchCatalogItems
can only search for items or item variations, whereasSearchCatalogObjects
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, whereSearchCatalogObjects
does not.SearchCatalogItems
does not support theinclude_deleted_objects
filter to search for deleted items or item variations, whereasSearchCatalogObjects
does.- The both endpoints have different call conventions, including the query filter formats.
async searchCatalogObjects(
body: SearchCatalogObjectsRequest,
requestOptions?: RequestOptions
): Promise<ApiResponse<SearchCatalogObjectsResponse>>
Parameter | Type | Tags | Description |
---|---|---|---|
body |
SearchCatalogObjectsRequest |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
requestOptions |
RequestOptions | undefined |
Optional | Pass additional request options. |
const contentType = null;
const bodyObjectTypes: string[] = ['ITEM'];
const bodyQueryPrefixQuery: CatalogQueryPrefix = {
attributeName: 'name',
attributePrefix: 'tea',
};
const bodyQuery: CatalogQuery = {};
bodyQuery.prefixQuery = bodyQueryPrefixQuery;
const body: SearchCatalogObjectsRequest = {};
body.objectTypes = bodyObjectTypes;
body.query = bodyQuery;
body.limit = 100;
try {
const { result, ...httpResponse } = await catalogApi.searchCatalogObjects(body);
// Get more response info...
// const { statusCode, headers } = httpResponse;
} catch(error) {
if (error instanceof ApiError) {
const errors = error.result;
// const { statusCode, headers } = error;
}
}
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
endpoint in the following aspects:
SearchCatalogItems
can only search for items or item variations, whereasSearchCatalogObjects
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, whereSearchCatalogObjects
does not.SearchCatalogItems
does not support theinclude_deleted_objects
filter to search for deleted items or item variations, whereasSearchCatalogObjects
does.- The both endpoints use different call conventions, including the query filter formats.
async searchCatalogItems(
body: SearchCatalogItemsRequest,
requestOptions?: RequestOptions
): Promise<ApiResponse<SearchCatalogItemsResponse>>
Parameter | Type | Tags | Description |
---|---|---|---|
body |
SearchCatalogItemsRequest |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
requestOptions |
RequestOptions | undefined |
Optional | Pass additional request options. |
const contentType = null;
const bodyCategoryIds: string[] = ['WINE_CATEGORY_ID'];
const bodyStockLevels: string[] = ['OUT', 'LOW'];
const bodyEnabledLocationIds: string[] = ['ATL_LOCATION_ID'];
const bodySortOrder: string = {'' : null, '' : null, '' : null } const bodyProductTypes: string[] = ['REGULAR'];
const bodyCustomAttributeFilters: CustomAttributeFilter[] = [];
const bodycustomAttributeFilters0: CustomAttributeFilter = {};
bodycustomAttributeFilters0.customAttributeDefinitionId = 'VEGAN_DEFINITION_ID';
bodycustomAttributeFilters0.boolFilter = true;
bodyCustomAttributeFilters[0] = bodycustomAttributeFilters0;
const bodycustomAttributeFilters1: CustomAttributeFilter = {};
bodycustomAttributeFilters1.customAttributeDefinitionId = 'BRAND_DEFINITION_ID';
bodycustomAttributeFilters1.stringFilter = 'Dark Horse';
bodyCustomAttributeFilters[1] = bodycustomAttributeFilters1;
const bodycustomAttributeFilters2NumberFilter: Range = {};
bodycustomAttributeFilters2NumberFilter.min = '2017';
bodycustomAttributeFilters2NumberFilter.max = '2018';
const bodycustomAttributeFilters2: CustomAttributeFilter = {};
bodycustomAttributeFilters2.key = 'VINTAGE';
bodycustomAttributeFilters2.numberFilter = bodycustomAttributeFilters2NumberFilter;
bodyCustomAttributeFilters[2] = bodycustomAttributeFilters2;
const bodycustomAttributeFilters3: CustomAttributeFilter = {};
bodycustomAttributeFilters3.customAttributeDefinitionId = 'VARIETAL_DEFINITION_ID';
bodyCustomAttributeFilters[3] = bodycustomAttributeFilters3;
const body: SearchCatalogItemsRequest = {};
body.textFilter = 'red';
body.categoryIds = bodyCategoryIds;
body.stockLevels = bodyStockLevels;
body.enabledLocationIds = bodyEnabledLocationIds;
body.limit = 100;
body.sortOrder = bodySortOrder;
body.productTypes = bodyProductTypes;
body.customAttributeFilters = bodyCustomAttributeFilters;
try {
const { result, ...httpResponse } = await catalogApi.searchCatalogItems(body);
// Get more response info...
// const { statusCode, headers } = httpResponse;
} catch(error) {
if (error instanceof ApiError) {
const errors = error.result;
// const { statusCode, headers } = error;
}
}
Updates the CatalogModifierList objects that apply to the targeted CatalogItem without having to perform an upsert on the entire item.
async updateItemModifierLists(
body: UpdateItemModifierListsRequest,
requestOptions?: RequestOptions
): Promise<ApiResponse<UpdateItemModifierListsResponse>>
Parameter | Type | Tags | Description |
---|---|---|---|
body |
UpdateItemModifierListsRequest |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
requestOptions |
RequestOptions | undefined |
Optional | Pass additional request options. |
UpdateItemModifierListsResponse
const contentType = null;
const bodyItemIds: string[] = ['H42BRLUJ5KTZTTMPVSLFAACQ', '2JXOBJIHCWBQ4NZ3RIXQGJA6'];
const bodyModifierListsToEnable: string[] = ['H42BRLUJ5KTZTTMPVSLFAACQ', '2JXOBJIHCWBQ4NZ3RIXQGJA6'];
const bodyModifierListsToDisable: string[] = ['7WRC16CJZDVLSNDQ35PP6YAD'];
const body: UpdateItemModifierListsRequest = {
itemIds: bodyItemIds,
};
body.modifierListsToEnable = bodyModifierListsToEnable;
body.modifierListsToDisable = bodyModifierListsToDisable;
try {
const { result, ...httpResponse } = await catalogApi.updateItemModifierLists(body);
// Get more response info...
// const { statusCode, headers } = httpResponse;
} catch(error) {
if (error instanceof ApiError) {
const errors = error.result;
// const { statusCode, headers } = error;
}
}
Updates the CatalogTax objects that apply to the targeted CatalogItem without having to perform an upsert on the entire item.
async updateItemTaxes(
body: UpdateItemTaxesRequest,
requestOptions?: RequestOptions
): Promise<ApiResponse<UpdateItemTaxesResponse>>
Parameter | Type | Tags | Description |
---|---|---|---|
body |
UpdateItemTaxesRequest |
Body, Required | An object containing the fields to POST for the request. See the corresponding object definition for field details. |
requestOptions |
RequestOptions | undefined |
Optional | Pass additional request options. |
const contentType = null;
const bodyItemIds: string[] = ['H42BRLUJ5KTZTTMPVSLFAACQ', '2JXOBJIHCWBQ4NZ3RIXQGJA6'];
const bodyTaxesToEnable: string[] = ['4WRCNHCJZDVLSNDQ35PP6YAD'];
const bodyTaxesToDisable: string[] = ['AQCEGCEBBQONINDOHRGZISEX'];
const body: UpdateItemTaxesRequest = {
itemIds: bodyItemIds,
};
body.taxesToEnable = bodyTaxesToEnable;
body.taxesToDisable = bodyTaxesToDisable;
try {
const { result, ...httpResponse } = await catalogApi.updateItemTaxes(body);
// Get more response info...
// const { statusCode, headers } = httpResponse;
} catch(error) {
if (error instanceof ApiError) {
const errors = error.result;
// const { statusCode, headers } = error;
}
}