callDiscountCartApi method

Future<void> callDiscountCartApi(
  1. String cartDiscountId
)

Implementation

Future<void> callDiscountCartApi(String cartDiscountId) async {
  BuildContext context = Get.context!;
  WidgetsBinding.instance.addPostFrameCallback((_) {
    Helper.progressDialog(context, "Please wait..");
  });
  var body = {"cartDiscountId": cartDiscountId};
  await ApiClient(baseUrl: ApiConstant.posBL)
      .discountCart(
          cartDiscountId: body,
          cartId: cartId,
          xRoles: storage.read("XUSER_ID"),
          xUserId: storage.read("XUSER_ID"))
      .then((response) {
    Get.back();
    cart.CartModel model = response;
    if (model.status == "POS200") {
      discountId.value = cartDiscountId;
      cartId = model.data!.cartId!;
      if (currentScan == ScanType.spotSellThru) {
        updateSpotSellThruOrder(model);
      }
    } else {
      if (model.errors != null) {
        Helper.messageDialog(
            Get.context!,
            model.errors![0].code ?? "Try again!!",
            model.errors![0].localeMessage ?? "Something went wrong");
      }
    }
  }, onError: (error) {
    print(error.toString());
    Get.back();
    Helper.messageDialog(Get.context!, "Try Again!!", error.toString());
  });
}