submitData method

Future<SubmitIdResponse> submitData(
  1. dynamic idNo,
  2. dynamic frontFile,
  3. dynamic backFile,
  4. String docType,
)

return token

Implementation

Future<SubmitIdResponse> submitData(
    idNo, frontFile, backFile, String docType) async {
  Response response;
  final dio = apiClient();
  var payload = {
    "dataSource": "",
    "frontImage": frontFile,
    "backImage": backFile,
    "IDNo": idNo,
    "IDtype": docType == "AADHAAR" ? 1 : 2,
    "issueCountry": "644b373960d64aec0123a093"
  };
  try {
    var data = dio.then((value) async {
      response = await value.post("submit/idChecks", data: payload);
      if (response.statusCode == 200) {
        SubmitIdResponse results = SubmitIdResponse.fromMap(response.data);
        return results;
      } else {
        throw Exception("Documents uploading failed");
      }
    }).catchError((e) {
      throw Exception(e);
    });
    return data;
  } on DioError catch (_, e) {
    throw Exception(e);
  }
}