callDeleteDiscountCartApi method
Future<void>
callDeleteDiscountCartApi(
)
Implementation
Future<void> callDeleteDiscountCartApi() async {
BuildContext context = Get.context!;
Helper.progressDialog(context, "Please wait..");
var body = {"cartDiscountId": null};
String requestTime = "";
String responseTime = "";
await ApiClient(
baseUrl: ApiConstant.posBL,
onFetchRequestTime: (time) {
requestTime = time;
},
onFetchResponseTime: (time) {
responseTime = time;
},
screenName: "scan",
)
.discountDeleteCart(
cartDiscountId: body,
cartId: cartId,
xRoles: SecureStorageService.readSecureData(
SecureStorageService.xUserId,
),
xUserId: SecureStorageService.readSecureData(
SecureStorageService.xUserId,
),
)
.then((response) {
Helper.close();
cart.CartModel model = response;
if (model.status == "POS200") {
Helper.logEvent(
"RESPONSE_EVENT",
success: true,
endPoint: "${Api.addToCart}/$cartId",
responseDate: responseTime,
screenName: "scan",
requestDate: requestTime,
transactionId: cartId,
);
discountId.value = "";
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");
}
}
}).catchError((error) {
ConditionalLogs().customLog("$error");
Helper.close();
MainController mainController = Get.put(MainController());
mainController.showErrorPopup();
});
}