closeSession method
Implementation
Future<void> closeSession(
String authCode,
String sessionId,
String amountCharged,
String volume,
String volumeMeasure,
String pumpId,
String status) async {
debugPrint("====VM Loading..");
CommonUtil().checkConnection().then((value) {
if (value) {
_status = Status.loading;
notifyListeners();
APICall()
.closeSession(
authCode, amountCharged, sessionId, volume, volumeMeasure)
.then((response) {
log('closeSession ==${response.statusCode}::${response.body}');
debugPrint('FAILED ::${response.body}');
if (response.statusCode == 200) {
log(response.body);
_closeSessionResponse =
CloseSessionResponse.fromJson(json.decode(response.body));
updatePumpStatus(StaticUtil.authCode, pumpId, status);
_status = Status.successful;
notifyListeners();
} else {
debugPrint('FAILED ::${response.body}');
/*_closeSessionResponse =
CloseSessionResponse.fromJson(json.decode(response.body));*/
_status = Status.failed;
notifyListeners();
}
}).catchError((error, stackTrace) {
_status = Status.exception;
log('ERROR ::: $error==$stackTrace');
notifyListeners();
});
} else {
_status = Status.noInternet;
notifyListeners();
}
});
}