processRequest method

void processRequest({
  1. required Map<String, String> body,
})

Implementation

void processRequest({required Map<String, String> body}) async {
  ReqModel reqModel = ReqModel();
  Map<String, String> headerValue = new Map<String, String>();
  headerValue["Content-Type"] = "application/json; charset=UTF-8";
  try {
    Uri _baseUri = Uri.https(ReqModel.URL, ReqModel.PATH);
    final response = await http.post(_baseUri,
        headers: headerValue, body: jsonEncode(body));
    print(response.body);
    print(response.statusCode);
    if (response.statusCode == 401) {
      reqModel.status = ICactions.UNAUTHORISED;
    } else if (response.statusCode == 200) {
      final json = jsonDecode(response.body);
      reqModel.fromJson(json);
      reqModel.status = ICactions.SUCCESS;
    } else if (response.statusCode == 409) {
      reqModel.status = ICactions.DUPLICATE;
    } else if (response.statusCode == 400) {
      reqModel.status = ICactions.TRANSACTION_ERROR;
    } else {
      // print(reqModel.toString());
      reqModel.status = ICactions.UNKNOWN;
    }
  } catch (ex) {
    reqModel.status = ICactions.NETWORK_ERROR;
  }
  _apiContract.onApiResult(reqModel);
}