Digio_eSign_Document_Download method
Implementation
Future<File?> Digio_eSign_Document_Download() async{
String jwt_token= await GetCurrentJWTToken();
print("Calling Digio_eSign_Document_Download Using API"+jwt_token);
String lead_id = await GetLeadId();
print("Digio_eSign_Document_Download for Lead ID : "+lead_id);
String? doc_id = await Get_ESIGN_DOC_ID();
print("Digio_eSign_Document_Download for Doc Id : "+doc_id!);
var headers = {
'Authorization': 'Bearer $jwt_token',
'Content-Type': 'application/json'
};
var request = http.Request('POST', Uri.parse('$BASE_API_LINK_URL/api/eSign/Digio_eSign_Document_Download'));
request.body = json.encode({
"document_id": "$doc_id",
"lead_Id": "$lead_id"
});
request.headers.addAll(headers);
http.StreamedResponse response = await request.send();
if (response.statusCode == 200) {
var result = await response.stream.bytesToString();
print(result);
String fileName = "pdfsasas";
//final dir = await getExternalStorageDirectory();
//final file = File("${dir!.path}/$fileName.pdf");
//await file.writeAsBytes(result as Uint8List);
return null;
}
else {
print(response.reasonPhrase);
var result = "";
String fileName = "pdfsasas";
final dir = await getExternalStorageDirectory();
final file = File("${dir!.path}/$fileName.pdf");
await file.writeAsBytes(result as Uint8List);
return null;
}
}