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