closeSession method

Future<void> closeSession(
  1. String authCode,
  2. String sessionId,
  3. String amountCharged,
  4. String volume,
  5. String volumeMeasure,
  6. String pumpId,
  7. String status,
)

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();
    }
  });
}