FinalUploadClaimDocuments method

dynamic FinalUploadClaimDocuments({
  1. dynamic context,
})

Implementation

FinalUploadClaimDocuments({context}) async {
  var checkStatusCode;
  var body;
  try {
    Map data = {
      "data": {
        "intimation_id": ClaimSubmissionNumber.toString(),
      },
      "document": UploadDocumentSubmission
    };

    body = jsonEncode(data);

    http.Response response = await http.post(
        Uri.parse('${choice_Base_Url}claim_add_documents'),
        body: body,
        headers: {
          "Authorization": choiceToken,
        });
    TokenRefresh(refreshtoken: response.headers['authorization'].toString());
    checkStatusCode = response.statusCode;

    var decodedResponse = await json.decode(response.body);
    decodedResponse = json.decode(response.body);

    if (decodedResponse['status'] == true) {
      Get.back();
      Get.off(ChoiceSecondPageClaimSubmission());
      showDialog(
        context: context,
        barrierDismissible: false,
        builder: (BuildContext context) {
          return ChoiceAlertPopup(
            messag: "${decodedResponse['app_message'] ?? errorMessage}",
            image:
                '${BASE_URL}assets/images/medibhai_images/lottie/Upload_Successful.json',
          );
        },
      );
    } else {
      Get.back();
      Fluttertoast.showToast(
          msg: decodedResponse['message'], gravity: ToastGravity.CENTER);
    }
  } catch (err) {
    AutoLogoutThreeTry();
    if (checkStatusCode == 401) {
      await FinalUploadClaimDocuments(context: context);
      (commonContext as Element).reassemble();
    } else {}
  }
}