API request into equivalent SDK code
Monday, August 13, 2018 at 08:09am
HI All,
Can you help me to convert the below API request into equivalent SDK code to create the package(with one document file as attachment to sign off):
{
"name": "packagename",
"status": "SENT",
"roles": [
{
"id": "signer1",
"index": "1",
"type": "SIGNER",
"signers": [
{
"email": "[email protected]",
"firstName": "TestUser1",
"lastName": "TestUser1",
"delivery": {
"email": false,
"provider": false,
"download": false
}
}
]
},
{
"id": "signer2",
"index": "1",
"type": "SIGNER",
"signers": [
{
"email": "[email protected]",
"firstName": "TestUser2",
"lastName": " TestUser2",
"delivery": {
"email": false,
"provider": false,
"download": false
}
}
]
},
{
"id": "employee",
"index": "0",
"type": "SIGNER",
"signers": [
{
"email": "[email protected]",
"firstName": "Employee1",
"lastName": " Employee1",
"delivery": {
"email": false,
"provider": false,
"download": false
}
}
]
}
],
"documents": [
{
"extract": true,
"name": "SaskatchewanLoanProtectionPlan",
"index": 0,
"fields": [
{
"FieldName": "CUSTNUM",
"FieldValue": "2321495"
},
{
"FieldName": "CUSTBR",
"FieldValue": "2546"
},
{
"FieldName": "CUSTSURNAME",
"FieldValue": "Houlihan"
}
]
}
]
}
Thanks in advance.
Reply to: API request into equivalent SDK code
Monday, August 13, 2018 at 08:41ampublic void createPackage2() { // Build the DocumentPackage object DocumentPackage documentPackage = newPackageNamed("packagename") .withSigner(newSignerWithEmail("[email protected]") .withCustomId("signer1") .withFirstName("TestUser1").withLastName("TestUser1") .signingOrder(1) ) .withSigner(newSignerWithEmail("[email protected]") .withCustomId("signer2") .withFirstName("TestUser2").withLastName("TestUser2") .signingOrder(1) ) .withSigner(newSignerWithEmail("[email protected]") .withCustomId("employee") .withFirstName("Employee1").withLastName("Employee1") .signingOrder(0) ) .withDocument(newDocumentWithName("SaskatchewanLoanProtectionPlan") .fromFile(URL_PATH) .enableExtraction() .atIndex(0) .withInjectedField(FieldBuilder.textField() .withName("CUSTNUM") .withValue("2321495")) .withInjectedField(FieldBuilder.textField() .withName("CUSTBR") .withValue("2546")) .withInjectedField(FieldBuilder.textField() .withName("CUSTSURNAME") .withValue("Houlihan")) ) .build(); // Issue the request to the e-SignLive server to create the DocumentPackage PackageId packageId = eslClient.createAndSendPackage(documentPackage); }This is the sample code created for you. And“deliveryâ€: {“emailâ€: false,“providerâ€: false,“downloadâ€: false}this part is set to false by default I think. If you are using Text Injection, please make sure the pdf form property name is in consistent with your field name. And if you are applying Document Extraction,.enableExtraction()function is enough to tell OneSpan Sign the info of your approvals and fields. But if you are using other kinds of extraction, please do the corresponding changes in the code. Hope this could help you! DuoReply to: API request into equivalent SDK code
Tuesday, August 14, 2018 at 02:32amReply to: API request into equivalent SDK code
Tuesday, August 14, 2018 at 05:12amInputStream is = new ByteArrayInputStream(byteArray); DocumentBuilder db= newDocumentWithName(name) .fromStream(is, DocumentType.PDF);This two lines work well from my testing. DuoReply to: API request into equivalent SDK code
Tuesday, August 14, 2018 at 06:30amFile file = new File(sourcePath); int size = (int) file.length(); if (size > Integer.MAX_VALUE) { System.out.println("File is to larger"); } byte[] bytes = new byte[size]; DataInputStream dis = new DataInputStream(new FileInputStream(file)); int read = 0; int numRead = 0; while (read bytes.length && (numRead = dis.read(bytes, read, bytes.length - read)) >= 0) { read = read + numRead; } dis.close(); InputStream testStream3 = new ByteArrayInputStream(bytes);I don't know whether it makes sense to you as in the code, the FileInputStream is actually used to generate the byte[] and then you'd use byte[] to generate an InputStream. And since I don't know what kind of data you are handling. Duo