updateCatalogItemsModifiers method

Future<String> updateCatalogItemsModifiers({
  1. required String objectId,
  2. required UpdateCatalogItemsModifier request,
  3. String? authToken,
})

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

Implementation

Future<String> updateCatalogItemsModifiers({
  required String objectId,
  required UpdateCatalogItemsModifier 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/update-item-modifier-lists");

  //print (endpoint.toString());

  var response = await
  http.post(endpoint, body: jsonEncode(request.toJson()), headers: headers);

  if (response.statusCode == 200) {
    print (jsonDecode(response.body));
    return CatalogResponse.fromJson(jsonDecode(response.body)).updatedAt!;
  }
  else {
    print (response.body);
    throw CatalogException(statusCode: response.statusCode, message: CatalogResponse.fromJson(jsonDecode(response.body)).errors?[0].detail?.toString());
  }
}