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