batchDeleteCatalog method
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.
Implementation
Future<CatalogDeleteResponse> batchDeleteCatalog({
required List<String> objectIds,
String? authToken,
}) async {
authToken ??= authenticationService.getCachedToken()?.accessToken;
Map<String, String> headers = {
"Authorization": "Bearer ${authToken ?? ""}",
'Content-Type': 'application/json; charset=UTF-8',
'Accept': 'application/json',
};
var request = {
"object_ids": objectIds,
};
Uri endpoint = Uri.https(
baseUrl, "/v2/catalog/batch-delete");
//print (endpoint.toString());
var response = await
http.post(endpoint, body: jsonEncode(request), headers: headers);
if (response.statusCode == 200) {
print (jsonDecode(response.body));
return CatalogDeleteResponse.fromJson(jsonDecode(response.body));
}
else {
print (response.body);
throw CatalogException(statusCode: response.statusCode, message: CatalogDeleteResponse.fromJson(jsonDecode(response.body)).errors?[0].detail?.toString());
}
}