uploadXml method
Implementation
Future<Either<Failure, AadhaarModel>> uploadXml(
String clientId, String clientSecret, String shareCode, File file,
{File? selfie}) async {
MultipartFile f = MultipartFile(file, filename: 'xml_file');
FormData form = FormData({
'client_id': clientId,
'shared_passcode': shareCode,
'xml_file': f,
});
if (selfie != null) {
MultipartFile selfieFile = MultipartFile(selfie, filename: 'selfie_file');
form = FormData({
'client_id': clientId,
'shared_passcode': shareCode,
'xml_file': f,
'selfie_file': selfieFile,
});
}
final response = await post(
'${Get.find<AadhaarSdkController>().baseUrl}/uploadokycxml',
form,
headers: {"x-api-key": clientSecret},
contentType: "multipart/form-data",
);
if (response.status.hasError) {
return Left(ServerFailure(
response.bodyString ?? "Error while getting data",
response.statusCode ?? 404));
} else {
if (response.bodyString != null) {
return Right(AadhaarModel.fromRawJson(response.bodyString!));
}
return const Left(ServerFailure("Error while getting data", 404));
}
}