uploadDoc method

Future uploadDoc({
  1. required File file,
  2. required dynamic onUpload(
    1. BankReceiptUploadModel
    ),
})

Implementation

Future uploadDoc({
  required File file,
  required Function(BankReceiptUploadModel) onUpload,
}) async {
  BuildContext context = Get.context!;
  String requestTime = "";
  String responseTime = "";
  Helper.progressDialog(context, "Please wait..");
  await ApiClient(
    baseUrl: ApiConstant.posBaseUrl,
    onFetchRequestTime: (time) {
      requestTime = time;
    },
    onFetchResponseTime: (time) {
      responseTime = time;
    },
    screenName: "checkStock",
  )
      .bankReceiptUpload(
          xUserId: SecureStorageService.readSecureData(
            SecureStorageService.xUserId,
          ),
          xUserName: SecureStorageService.readSecureData(
            SecureStorageService.xUserId,
          ),
          sourceSystem: "sourceSystem",
          file: file,
          storeType: "FileSystem",
          resourceType: "PAYMENT_ATTACHMENT")
      .then((response) {
    Get.back();
    Helper.logEvent(
      "RESPONSE_EVENT",
      success: true,
      endPoint: "${Api.getMoreInfo}/$dealerId",
      responseDate: responseTime,
      screenName: "checkStock",
      requestDate: requestTime,
    );
    if (response.status == "POS200") {
      onUpload(response);
    } else {
      if (response.errors != null) {
        Helper.messageDialog(
            Get.context!,
            response.errors![0].code ?? "Try again!!",
            response.errors![0].description ?? "Something went wrong");
      }
    }
  }).catchError((error) {
    ConditionalLogs().customLog("$error");
    Get.back();
    MainController mainController = Get.put(MainController());
    mainController.showErrorPopup();
  });
}