Last modified: 2024-03-26

Java SDK

It is strongly recommended that you use a Callback Listener instead of polling for transaction statuses. The use of polling may consume unnecessary resources on both your end, and on the OneSpan Sign service.

This section discusses the following topics related to retrieving information about e-signature processes:

Retrieving Version Information

The following code samples illustrate how to retrieve your version of OneSpan Sign.

Java Code

package com.eSignLive.com.esl.sdk.examples; import java.util.Properties; public class ApplicationVersionExample extends SDKSample { public String applicationVersion; public static void main( String... args ) { new ApplicationVersionExample(Props.get()).run(); } public ApplicationVersionExample( Properties props ) { this( props.getProperty( "api.key" ), props.getProperty( "api.url" )); } public ApplicationVersionExample( String apiKey, String apiUrl ) { super( apiKey, apiUrl ); } public void execute() { applicationVersion = eslClient.getSystemService().getApplicationVersion(); } }

C# Code

using System; namespace SDK.Examples { public class ApplicationVersionExample : SDKSample { public static void Main(string[] args) { new ApplicationVersionExample(Props.GetInstance()).Run(); } public string applicationVersion; public ApplicationVersionExample(Props props) : this(props.Get("api.key"), props.Get("api.url")) { } public ApplicationVersionExample(string apiKey, string apiUrl) : base(apiKey, apiUrl) { } override public void Execute() { applicationVersion = eslClient.SystemService.GetApplicationVersion(); } } }

Retrieving Information for Technical Support

The following code samples illustrate how to retrieve transaction information for our Support Team.

Java Code

package com.eSignLive.com.esl.sdk.examples; import com.eSignLive.com.esl.sdk.DocumentPackage; import com.eSignLive.com.esl.sdk.DocumentType; import com.eSignLive.com.esl.sdk.SupportConfiguration; import java.io.InputStream; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Properties; import static com.eSignLive.com.esl.sdk.builder.DocumentBuilder.newDocumentWithName; import static com.eSignLive.com.esl.sdk.builder.PackageBuilder.newPackageNamed; import static com.eSignLive.com.esl.sdk.builder.SignatureBuilder.signatureFor; import static com.eSignLive.com.esl.sdk.builder.SignerBuilder.newSignerWithEmail; public class PackageInformationExample extends SDKSample { private String email1; private InputStream documentInputStream1; public SupportConfiguration supportConfiguration; public static void main( String... args ) { new PackageInformationExample(Props.get()).run(); } public PackageInformationExample( Properties props ) { this( props.getProperty( "api.key" ), props.getProperty( "api.url" ), props.getProperty( "1.email" )); } public PackageInformationExample( String apiKey, String apiUrl, String email1 ) { super( apiKey, apiUrl ); this.email1 = email1; documentInputStream1 = this.getClass().getClassLoader().getResourceAsStream( "document.pdf" ); } public void execute() { DocumentPackage superDuperPackage = newPackageNamed("PackageInformationExample " + new SimpleDateFormat("HH:mm:ss").format(new Date())) .describedAs("This is a package created using the eSignLive SDK") .withSigner(newSignerWithEmail(email1) .withFirstName("John1") .withLastName("Smith1")) .withDocument(newDocumentWithName("First Document") .fromStream(documentInputStream1, DocumentType.PDF) .withSignature(signatureFor(email1) .onPage(0) .atPosition(100, 100))) .build(); packageId = eslClient.createPackage( superDuperPackage ); eslClient.sendPackage( packageId ); supportConfiguration = eslClient.getPackageService().getConfig(packageId); } }

C# Code

using System; using System.IO; using eSignLive.com.ESL.SDK; using eSignLive.com.ESL.SDK.Builder; namespace SDK.Examples { public class PackageInformationExample : SDKSample { public static void Main(string[] args) { new PackageInformationExample(Props.GetInstance()).Run(); } private string email1; private Stream fileStream1; public SupportConfiguration supportConfiguration; public readonly string DOCUMENT_NAME = "First Document"; public PackageInformationExample(Props props) : this(props.Get("api.key"), props.Get("api.url"), props.Get("1.email")) { } public PackageInformationExample(string apiKey, string apiUrl, string email1) : base(apiKey, apiUrl) { this.email1 = email1; this.fileStream1 = File.OpenRead(new FileInfo(Directory.GetCurrentDirectory() + "/src/document.pdf").FullName); } override public void Execute() { DocumentPackage superDuperPackage = PackageBuilder.NewPackageNamed("PackageInformationExample: " + DateTime.Now) .WithSettings(DocumentPackageSettingsBuilder.NewDocumentPackageSettings().WithInPerson()) .WithSigner(SignerBuilder.NewSignerWithEmail(email1) .WithFirstName("John1") .WithLastName("Smith1")) .WithDocument(DocumentBuilder.NewDocumentNamed(DOCUMENT_NAME) .FromStream(fileStream1, DocumentType.PDF) .WithSignature(SignatureBuilder.SignatureFor(email1) .OnPage(0) .AtPosition(100, 100))) .Build(); packageId = eslClient.CreatePackage(superDuperPackage); eslClient.SendPackage(packageId); supportConfiguration = eslClient.PackageService.GetConfig(packageId); } } }

Retrieving All Approvals for a Transaction

The following code samples illustrate how to retrieve all approvals for a specified transaction.

Java Code

package com.eSignLive.com.esl.sdk.examples; import com.eSignLive.com.esl.sdk.DocumentPackage; import com.eSignLive.com.esl.sdk.DocumentType; import com.eSignLive.com.esl.sdk.Signature; import java.io.InputStream; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; import java.util.Properties; import static com.eSignLive.com.esl.sdk.builder.DocumentBuilder.newDocumentWithName; import static com.eSignLive.com.esl.sdk.builder.PackageBuilder.newPackageNamed; import static com.eSignLive.com.esl.sdk.builder.SignatureBuilder.signatureFor; import static com.eSignLive.com.esl.sdk.builder.SignerBuilder.newSignerWithEmail; public class SignableSignaturesExample extends SDKSample { private InputStream documentInputStream1; private DocumentPackage sentPackage; private String signer1Id = "signer1Id"; private String signer2Id = "signer2Id"; private String documentId = "documentId"; public String email1; public String email2; public List<Signature> signer1SignableSignatures, signer2SignableSignatures; public static void main( String... args ) { new SignableSignaturesExample(Props.get()).run(); } public SignableSignaturesExample(Properties props) { this( props.getProperty( "api.key" ), props.getProperty( "api.url" ), props.getProperty( "1.email" ), props.getProperty( "2.email" )); } public SignableSignaturesExample(String apiKey, String apiUrl, String email1, String email2) { super( apiKey, apiUrl ); this.email1 = email1; this.email2 = email2; documentInputStream1 = this.getClass().getClassLoader().getResourceAsStream( "document.pdf" ); } public void execute() { DocumentPackage superDuperPackage = newPackageNamed("SignableSignaturesExample " + new SimpleDateFormat("HH:mm:ss").format(new Date())) .describedAs("This is a package created using the eSignLive SDK") .withSigner(newSignerWithEmail(email1) .withFirstName("John1") .withLastName("Smith1") .withCustomId(signer1Id)) .withSigner(newSignerWithEmail(email2) .withFirstName("John2") .withLastName("Smith2") .withCustomId(signer2Id)) .withDocument(newDocumentWithName("First Document") .fromStream(documentInputStream1, DocumentType.PDF) .withId(documentId) .withSignature(signatureFor(email1) .onPage(0) .atPosition(100, 100)) .withSignature(signatureFor(email1) .onPage(0) .atPosition(300, 100)) .withSignature(signatureFor(email2) .onPage(0) .atPosition(500, 100))) .build(); packageId = eslClient.createPackage( superDuperPackage ); eslClient.sendPackage( packageId ); sentPackage = eslClient.getPackage( packageId ); signer1SignableSignatures = eslClient.getApprovalService().getAllSignableSignatures(sentPackage, documentId, signer1Id); signer2SignableSignatures = eslClient.getApprovalService().getAllSignableSignatures(sentPackage, documentId, signer2Id); } }

C# Code

using System; using System.IO; using eSignLive.com.ESL.SDK; using System.Collections.Generic; using eSignLive.com.ESL.SDK.Builder; namespace SDK.Examples { public class SignableSignaturesExample : SDKSample { public static void Main(string[] args) { new SignableSignaturesExample(Props.GetInstance()).Run(); } private Stream fileStream1; public DocumentPackage sentPackage; private string signer1Id = "signer1Id"; private string signer2Id = "signer2Id"; private string documentId = "documentId"; private string DOCUMENT_NAME = "First Document"; public string email1; public string email2; public IList<Signature> signer1SignableSignatures, signer2SignableSignatures; public SignableSignaturesExample(Props props) : this(props.Get("api.key"), props.Get("api.url"), props.Get("1.email"), props.Get("2.email")) { } public SignableSignaturesExample(string apiKey, string apiUrl, string email1, string email2) : base(apiKey, apiUrl) { this.email1 = email1; this.email2 = email2; this.fileStream1 = File.OpenRead(new FileInfo(Directory.GetCurrentDirectory() + "/src/document.pdf").FullName); } override public void Execute() { DocumentPackage superDuperPackage = PackageBuilder.NewPackageNamed("SignableSignaturesExample: " + DateTime.Now) .WithSettings(DocumentPackageSettingsBuilder.NewDocumentPackageSettings().WithInPerson()) .WithSigner(SignerBuilder.NewSignerWithEmail(email1) .WithFirstName("John1") .WithLastName("Smith1") .WithCustomId(signer1Id)) .WithSigner(SignerBuilder.NewSignerWithEmail(email2) .WithFirstName("John2") .WithLastName("Smith2") .WithCustomId(signer2Id)) .WithDocument(DocumentBuilder.NewDocumentNamed(DOCUMENT_NAME) .FromStream(fileStream1, DocumentType.PDF) .WithId(documentId) .WithSignature(SignatureBuilder.SignatureFor(email1) .OnPage(0) .AtPosition(100, 100)) .WithSignature(SignatureBuilder.SignatureFor(email1) .OnPage(0) .AtPosition(300, 100)) .WithSignature(SignatureBuilder.SignatureFor(email2) .OnPage(0) .AtPosition(500, 100))) .Build(); packageId = eslClient.CreatePackage(superDuperPackage); eslClient.SendPackage(packageId); sentPackage = eslClient.GetPackage(packageId); signer1SignableSignatures = eslClient.ApprovalService.GetAllSignableSignatures(sentPackage, documentId, signer1Id); signer2SignableSignatures = eslClient.ApprovalService.GetAllSignableSignatures(sentPackage, documentId, signer2Id); } } }

Retrieving a Transaction

Once you have begun to create and send transactions, you may want to retrieve the latest version of a particular transaction. To do this, you need the ID of the transaction you want to retrieve.

The following code samples illustrate how to retrieve a transaction ID.

Java Code

EslClient esl = new EslClient( API_KEY, API_URL ); PackageId packageId = new PackageId("your package id"); DocumentPackage pkg = esl.getPackage(packageId);

C# Code

EslClient client = new EslClient (API_KEY, API_URL); PackageId packageId = new PackageId ("GLK2xasqLvFe2wc4qwO5iTKyjx42"); DocumentPackage pkg = client.getPackage (packageId);

Downloading Documents

Once you have begun to create and send transactions, you may want to retrieve the latest versions of the documents that are in a particular transaction. To do this, you need the ID of the transaction and the IDs of the relevant documents.

The following code samples illustrate how to download: (1) a specific document; (2) the transaction's Evidence Summary; (3) a zip file that contains all the transaction's documents.

Java Code

EslClient esl = new EslClient( API_KEY, API_URL ); PackageId packageId = new PackageId("your package id"); byte[] documentContent = esl.downloadDocument(packageId, "your document id"); Files.saveTo(documentContent, "downloaded.pdf"); byte[] evidenceContent = esl.downloadEvidenceSummary(packageId); Files.saveTo(evidenceContent, "evidence.pdf"); byte[] zip = esl.downloadZippedDocuments(packageId); Files.saveTo(zip, "package.zip");

C# Code

EslClient client = new EslClient (API_KEY, API_URL); PackageId packageId = new PackageId ("GLK2xasqLvFe2wc4qwO5iTKyjx42"); byte[] documentContent = client.DownloadDocument (packageId, "testing"); File.WriteAllBytes (Directory.GetCurrentDirectory() + "/downloaded.pdf", documentContent); byte[] evidenceContent = client.DownloadEvidenceSummary (packageId); File.WriteAllBytes (Directory.GetCurrentDirectory() + "/evidence-summary.pdf", evidenceContent); byte[] zipContent = client.DownloadZippedDocuments (packageId); File.WriteAllBytes (Directory.GetCurrentDirectory() + "/package-documents.zip", zipContent);

Downloading Documents Completed within a Date Range

The following code samples illustrate how to download documents that were completed within a specified range of dates.

Java Code

package com.eSignLive.com.esl.sdk.examples; import com.eSignLive.com.esl.sdk.DocumentPackage; import com.eSignLive.com.esl.sdk.PackageStatus; import com.eSignLive.com.esl.sdk.Page; import com.eSignLive.com.esl.sdk.PageRequest; import org.joda.time.DateTime; import java.util.Date; import java.util.Properties; public class GetCompletedPackagesWithinDateRangeExample extends SDKSample { public static final Date START_DATE = new DateTime().toDate(); public static final Date END_DATE = new DateTime().toDate(); public Page<DocumentPackage> draftPackages; public Page<DocumentPackage> sentPackages; public Page<DocumentPackage> declinedPackages; public Page<DocumentPackage> archivedPackages; public Page<DocumentPackage> completedPackages; public static void main( String... args ) { new GetCompletedPackagesWithinDateRangeExample( Props.get() ).run(); } public GetCompletedPackagesWithinDateRangeExample( Properties properties ) { this( properties.getProperty( "api.key" ), properties.getProperty( "api.url" ) ); } public GetCompletedPackagesWithinDateRangeExample( String apiKey, String apiUrl ) { super( apiKey, apiUrl ); } public void execute() { draftPackages = getPackagesByPackageStatus(PackageStatus.DRAFT, START_DATE, END_DATE); sentPackages = getPackagesByPackageStatus(PackageStatus.SENT, START_DATE, END_DATE); declinedPackages = getPackagesByPackageStatus(PackageStatus.DECLINED, START_DATE, END_DATE); archivedPackages = getPackagesByPackageStatus(PackageStatus.ARCHIVED, START_DATE, END_DATE); completedPackages = getPackagesByPackageStatus(PackageStatus.COMPLETED, START_DATE, END_DATE); private Page<DocumentPackage> getPackagesByPackageStatus(PackageStatus packageStatus, Date startDate, Date endDate) { Page<DocumentPackage> resultPage = eslClient.getPackageService().getUpdatedPackagesWithinDateRange(packageStatus, new PageRequest(1), startDate, endDate); return resultPage; } } }

C# Code

using System; using eSignLive.com.ESL.SDK; namespace SDK.Examples { public class GetCompletedPackagesWithinDateRangeExample : SDKSample { public static void Main (string[] args) { new GetCompletedPackagesWithinDateRangeExample(Props.GetInstance()).Run(); } public readonly DateTime START_DATE = DateTime.Now; public readonly DateTime END_DATE = DateTime.Now; public Page<DocumentPackage> draftPackages; public Page<DocumentPackage> sentPackages; public Page<DocumentPackage> declinedPackages; public Page<DocumentPackage> archivedPackages; public Page<DocumentPackage> completedPackages; public GetCompletedPackagesWithinDateRangeExample( Props props ) : this(props.Get("api.key"), props.Get("api.url")) { } public GetCompletedPackagesWithinDateRangeExample( String apiKey, String apiUrl ) : base( apiKey, apiUrl ) { } override public void Execute() { draftPackages = getPackagesByPackageStatus(DocumentPackageStatus.DRAFT, START_DATE, END_DATE); sentPackages = getPackagesByPackageStatus(DocumentPackageStatus.SENT, START_DATE, END_DATE); declinedPackages = getPackagesByPackageStatus(DocumentPackageStatus.DECLINED, START_DATE, END_DATE); archivedPackages = getPackagesByPackageStatus(DocumentPackageStatus.ARCHIVED, START_DATE, END_DATE); completedPackages = getPackagesByPackageStatus(DocumentPackageStatus.COMPLETED, START_DATE, END_DATE); private Page<DocumentPackage> getPackagesByPackageStatus(DocumentPackageStatus packageStatus, DateTime startDate, DateTime endDate) { Page<DocumentPackage> resultPage = eslClient.PackageService.GetUpdatedPackagesWithinDateRange(packageStatus, new PageRequest(1), startDate, endDate); return resultPage; } } } }

Retrieving a transaction's Status

Once a transaction has been created, you might want to retrieve just its signing status (instead of the entire transaction). The following code samples illustrate how to retrieve a transaction's signing status.

Java Code

EslClient eslClient = new EslClient( API_KEY, API_URL ); DocumentPackage superDuperPackage = newPackageNamed( "GetSigningStatus example" ) .withSigner( newSignerWithEmail( "[email protected]" ) .withFirstName( "John" ) .withLastName( "Smith" )) .withDocument( newDocumentWithName( "First Document" ) .fromFile( "src/main/Resources/document.pdf" ) .withSignature( signatureFor( "[email protected]" ) .onPage( 0 ) .atPosition( 100, 100 ) ) ) .build(); PackageId packageId = eslClient.createPackage( superDuperPackage ); SigningStatus draftSigningStatus = eslClient.getSigningStatus( packageId, null, null ); System.out.println(draftSigningStatus.getToken()); eslClient.sendPackage( packageId ); SigningStatus sentSigningStatus = eslClient.getSigningStatus( packageId, null, null ); System.out.println(sentSigningStatus.getToken());

C# Code

DocumentPackage package = PackageBuilder.NewPackageNamed ("GetSigningStatus example") .DescribedAs ("This is a new package") .WithSigner(SignerBuilder.NewSignerWithEmail("[email protected]") .WithFirstName("John") .WithLastName("Smith")) .WithDocument(DocumentBuilder.NewDocumentNamed("First Document") .FromFile("src/main/Resources/document.pdf") .WithSignature(SignatureBuilder.SignatureFor("[email protected]") .OnPage(0) .AtPosition(100, 100))) .Build (); PackageId id = eslClient.CreatePackage (package); SigningStatus draftSigningStatus = eslClient.GetSigningStatus( id, null, null ); Console.WriteLine(draftSigningStatus); eslClient.SendPackage(id); draftSigningStatus = eslClient.GetSigningStatus( id, null, null ); Console.WriteLine(draftSigningStatus);

Retrieving Field Values

Once a transaction has been completed, it may be useful to retrieve the values entered in certain fields. A single call can access all fields in the transaction.

The following code samples retrieve a list of all fields, and then outputs their values. The samples assume that: (1) signing is complete for a transaction that contains fields; (2) you know the transaction's PackageId.

Java Code

EslClient eslClient = new EslClient( API_KEY, API_URL ); List<FieldSummary> fieldSummaries = eslClient.getFieldValues( new PackageId( PACKAGE_ID ) ); System.out.println( "SignerId, DocumentId, FieldId: Value" ); for ( FieldSummary fieldSummary : fieldSummaries ) { System.out.println( fieldSummary.getSignerId() + ", " + fieldSummary.getDocumentId() + ", " + fieldSummary.getFieldId() + ": " + fieldSummary.getFieldValue() ); }

C# Code

EslClient eslClient = new EslClient( API_KEY, API_URL ); List<FieldSummary> fieldSummaries = eslClient.FieldSummaryService.GetFieldSummary(new PackageId( CURR_PACKAGE_ID ) ); Console.WriteLine( "SignerId, DocumentId, FieldId: Value" ); foreach ( FieldSummary fieldSummary in fieldSummaries ) { Console.WriteLine( fieldSummary.SignerId + ", " + fieldSummary.DocumentId + ", " + fieldSummary.FieldId + ": " + fieldSummary.FieldValue ); }

Retrieving Decline Reasons

A signer can decline to sign a transaction electronically. When that happens, the signer is prompted to provide a reason. That reason is saved in the transaction's list of messages.

The following code samples illustrate how to retrieve a decline reason from a transaction.

Java Code

// Get the list of messages from signer (the decline reason) DocumentPackage documentPackage = eslClient.getPackage(packageId); List<Message> messages = eslClient.getPackage(packageId).getMessages(); System.out.println(documentPackage.getStatus().toString() + " reason : " + messages.get(0).getContent());

C# Code

// Get the list of messages from signer (the decline reason) DocumentPackage documentPackage = eslClient.GetPackage(packageId); IList<Message> messages = eslClient.GetPackage(packageId).Messages; Console.WriteLine(documentPackage.Status.ToString() + " reason : " + messages[0].Content);

Retrieving a Completion Report

A Completion Report contains information about: (1) a sender; (2) their transactions with a specified status (e.g., DRAFT, SENT, COMPLETED).

Such a report can be retrieved via two alternative methods: (1) as a CompletionReport object; (2) in CSV format.

The following code samples illustrate how to retrieve a Completion Report using both methods.

Java Code

// Date and time range to get completion report Calendar fromCalendar = new GregorianCalendar(); fromCalendar.add(Calendar.DATE, -1); Date from = fromCalendar.getTime(); Calendar toCalendar = new GregorianCalendar(); toCalendar.setTime(new Date(System.currentTimeMillis())); Date to = toCalendar.getTime(); // Get the completion report object CompletionReport sdkCompletionReport = eslClient.getPackageService().downloadCompletionReport(com.eSignLive.com.esl.sdk.PackageStatus.DRAFT, senderUID, from, to); // Get the completion report in csv format String csvCompletionReport = eslClient.getPackageService().downloadCompletionReportAsCSV(com.eSignLive.com.esl.sdk.PackageStatus.DRAFT, senderUID, from, to); // Display package id and name of packages in DRAFT from sender System.out.print("Sender: " + sdkCompletionReport.getSenders().get(0).getSender().getEmail()); System.out.println(" has " + sdkCompletionReport.getSenders().get(0).getPackages().size() + " packages in DRAFT"); for (PackageCompletionReport packageCompletionReport : sdkCompletionReport.getSenders().get(0).getPackages()) { System.out.println(packageCompletionReport.getId() + " , " + packageCompletionReport.getName()); }

C# Code

// Date and time range to get completion report DateTime from = DateTime.Today.AddDays(-1); DateTime to = DateTime.Now; // Get the completion report object CompletionReport sdkCompletionReport = eslClient.PackageService.DownloadCompletionReport(DocumentPackageStatus.DRAFT, senderUID, from, to); // Get the completion report in csv format string csvCompletionReport = eslClient.PackageService.DownloadCompletionReportAsCSV(DocumentPackageStatus.DRAFT, senderUID, from, to); // Display package id and name of packages in DRAFT from sender Console.Write("Sender: " + sdkCompletionReport.Senders[0].Sender.Email); Console.WriteLine(" has " + sdkCompletionReport.Senders[0].Packages.Count + " packages in DRAFT"); foreach (PackageCompletionReport packageCompletionReport in sdkCompletionReport.Senders[0].Packages) { Console.WriteLine(packageCompletionReport.Id + " , " + packageCompletionReport.Name); }

Retrieving a Usage Report

A Usage Report contains: (1) a list of all senders on an account; (2) for each sender, the number of transactions and their signing statuses (e.g., DRAFT, SENT, COMPLETED).

Such a report can be retrieved via two alternative methods: (1) as a UsageReport object; (2) in CSV format.

The following code samples illustrate how to retrieve a Usage Report using both methods.

Java Code

package com.eSignLive.com.esl.sdk.examples; import com.eSignLive.com.esl.sdk.*; import com.eSignLive.com.esl.sdk.builder.FieldBuilder; import com.eSignLive.com.esl.sdk.internal.Converter; import java.io.InputStream; import java.text.SimpleDateFormat; import java.util.*; import static com.eSignLive.com.esl.sdk.builder.DocumentBuilder.newDocumentWithName; import static com.eSignLive.com.esl.sdk.builder.PackageBuilder.newPackageNamed; import static com.eSignLive.com.esl.sdk.builder.SignatureBuilder.signatureFor; import static com.eSignLive.com.esl.sdk.builder.SignerBuilder.newSignerWithEmail; import static org.joda.time.DateMidnight.now; public class DownloadCompletionAndUsageReportExample extends SDKSample { public final String email1; private String senderUID; private InputStream documentInputStream1; public com.eSignLive.com.esl.sdk.CompletionReport sdkCompletionReportForSender; public com.eSignLive.com.esl.sdk.CompletionReport sdkCompletionReport; public com.eSignLive.com.esl.sdk.UsageReport sdkUsageReport; public String csvCompletionReportForSender; public String csvCompletionReport; public String csvUsageReport; public static void main(String... args) { new DownloadCompletionAndUsageReportExample(Props.get()).run(); } public DownloadCompletionAndUsageReportExample(Properties properties) { this(properties.getProperty("api.key"), properties.getProperty("api.url"), properties.getProperty("1.email")); } public DownloadCompletionAndUsageReportExample(String apiKey, String apiUrl, String email1) { super(apiKey, apiUrl); this.email1 = email1; this.senderUID = Converter.apiKeyToUID(apiKey); documentInputStream1 = this.getClass().getClassLoader().getResourceAsStream("document.pdf"); } @Override public void execute() { DocumentPackage superDuperPackage = newPackageNamed( "DownloadCompletionAndUsageReport " + new SimpleDateFormat( "HH:mm:ss" ).format( new Date() ) ) .describedAs("This is a package created using the eSignLive SDK") .expiresAt(now().plusMonths(1).toDate()) .withEmailMessage("This message should be delivered to all signers") .withSigner(newSignerWithEmail(email1) .withFirstName("John") .withLastName("Smith") .withTitle("Managing Director") .withCustomId("signer1") .withCompany("Acme Inc.")) .withDocument(newDocumentWithName("First Document") .fromStream(documentInputStream1, DocumentType.PDF) .withSignature(signatureFor(email1) .onPage(0) .atPosition(100, 100) .withField(FieldBuilder.textField() .onPage(0) .atPosition(400, 100) .withSize(200, 50)))) .build(); packageId = eslClient.createPackage(superDuperPackage); // Date and time range to get completion/usage report. Calendar fromCalendar = new GregorianCalendar(); fromCalendar.add(Calendar.DATE, -1); Date from = fromCalendar.getTime(); Calendar toCalendar = new GregorianCalendar(); toCalendar.setTime(new Date(System.currentTimeMillis())); Date to = toCalendar.getTime(); // Download the completion report for a sender sdkCompletionReportForSender = eslClient.getPackageService().downloadCompletionReport(PackageStatus.DRAFT, senderUID, from, to); csvCompletionReportForSender = eslClient.getPackageService().downloadCompletionReportAsCSV(com.eSignLive.com.esl.sdk.PackageStatus.DRAFT, senderUID, from, to); // Display package id and name of packages in DRAFT from sender for(SenderCompletionReport senderCompletionReport : sdkCompletionReportForSender.getSenders()) { System.out.print("Sender: " + senderCompletionReport.getSender().getEmail()); System.out.println(" has " + senderCompletionReport.getPackages().size() + " packages in DRAFT"); for (PackageCompletionReport packageCompletionReport : senderCompletionReport.getPackages()) { System.out.println(packageCompletionReport.getId() + " , " + packageCompletionReport.getName() + " , Sender : " + getEslClient().getPackage(new PackageId(packageCompletionReport.getId())).getSenderInfo().getEmail()); } } // Download the completion report for all senders sdkCompletionReport = eslClient.getPackageService().downloadCompletionReport(com.eSignLive.com.esl.sdk.PackageStatus.DRAFT, from, to); csvCompletionReport = eslClient.getPackageService().downloadCompletionReportAsCSV(com.eSignLive.com.esl.sdk.PackageStatus.DRAFT, from, to); // Display package id and name of packages in DRAFT from sender System.out.println(); for(SenderCompletionReport senderCompletionReport : sdkCompletionReport.getSenders()) { System.out.print("Sender: " + senderCompletionReport.getSender().getEmail()); System.out.println(" has " + senderCompletionReport.getPackages().size() + " packages in DRAFT"); for (PackageCompletionReport packageCompletionReport : senderCompletionReport.getPackages()) { System.out.println(packageCompletionReport.getId() + " , " + packageCompletionReport.getName() + " , Sender : " + getEslClient().getPackage(new PackageId(packageCompletionReport.getId())).getSenderInfo().getEmail()); } } // Download the usage report sdkUsageReport = eslClient.getPackageService().downloadUsageReport(from, to); csvUsageReport = eslClient.getPackageService().downloadUsageReportAsCSV(from, to); } }

C# Code

using System; using System.IO; using eSignLive.com.ESL.SDK; using eSignLive.com.ESL.SDK.Builder; using eSignLive.com.ESL.SDK.Internal; using System.Collections.Generic; namespace SDK.Examples { public class DownloadCompletionAndUsageReportExample : SDKSample { public string email1; private string senderUID; private Stream fileStream1; public eSignLive.com.ESL.SDK.CompletionReport sdkCompletionReportForSender; public eSignLive.com.ESL.SDK.CompletionReport sdkCompletionReport; public eSignLive.com.ESL.SDK.UsageReport sdkUsageReport; public string csvCompletionReportForSender; public string csvCompletionReport; public string csvUsageReport; public static void Main(string[] args) { new DownloadCompletionAndUsageReportExample(Props.GetInstance()).Run(); } public DownloadCompletionAndUsageReportExample(Props props) : this(props.Get("api.key"), props.Get("api.url"), props.Get("1.email")) { } public DownloadCompletionAndUsageReportExample(string apiKey, string apiUrl, string email1) : base( apiKey, apiUrl ) { this.email1 = email1; this.senderUID = Converter.apiKeyToUID(apiKey); this.fileStream1 = File.OpenRead(new FileInfo(Directory.GetCurrentDirectory() + "/src/document.pdf").FullName); } override public void Execute() { DocumentPackage superDuperPackage = PackageBuilder.NewPackageNamed("DownloadCompletionAndUsageReport: " + DateTime.Now) .DescribedAs("This is a package created using the eSignLive SDK") .ExpiresOn(DateTime.Now.AddMonths(100)) .WithEmailMessage("This message should be delivered to all signers") .WithSigner(SignerBuilder.NewSignerWithEmail(email1) .WithCustomId("Client1") .WithFirstName("John") .WithLastName("Smith") .WithTitle("Managing Director") .WithCompany("Acme Inc.") ) .WithDocument(DocumentBuilder.NewDocumentNamed("First Document") .FromStream(fileStream1, DocumentType.PDF) .WithSignature(SignatureBuilder.SignatureFor(email1) .OnPage(0) .WithField(FieldBuilder.CheckBox() .OnPage(0) .AtPosition(400, 200) .WithValue(FieldBuilder.CHECKBOX_CHECKED) ) .AtPosition(100, 100) ) ) .Build(); packageId = eslClient.CreatePackage(superDuperPackage); // Date and time range to get completion report. DateTime from = DateTime.Today.AddDays(-1); DateTime to = DateTime.Now; // Download the completion report for a sender sdkCompletionReportForSender = eslClient.PackageService.DownloadCompletionReport(DocumentPackageStatus.DRAFT, senderUID, from, to); csvCompletionReportForSender = eslClient.PackageService.DownloadCompletionReportAsCSV(DocumentPackageStatus.DRAFT, senderUID, from, to); // Display package id and name of packages in DRAFT from sender foreach(SenderCompletionReport senderCompletionReport in sdkCompletionReportForSender.Senders) { Console.Write("Sender: " + senderCompletionReport.Sender.Email); Console.WriteLine(" has " + senderCompletionReport.Packages.Count + " packages in DRAFT"); foreach (PackageCompletionReport packageCompletionReport in senderCompletionReport.Packages) { Console.WriteLine(packageCompletionReport.Id + " , " + packageCompletionReport.Name + " , Sender : " + eslClient.GetPackage(new PackageId(packageCompletionReport.Id)).SenderInfo.Email); } } // Download the completion report for all senders sdkCompletionReport = eslClient.PackageService.DownloadCompletionReport(DocumentPackageStatus.DRAFT, from, to); csvCompletionReport = eslClient.PackageService.DownloadCompletionReportAsCSV(DocumentPackageStatus.DRAFT, from, to); // Display package id and name of packages in DRAFT from sender foreach(SenderCompletionReport senderCompletionReport in sdkCompletionReport.Senders) { Console.Write("Sender: " + senderCompletionReport.Sender.Email); Console.WriteLine(" has " + senderCompletionReport.Packages.Count + " packages in DRAFT"); foreach (PackageCompletionReport packageCompletionReport in senderCompletionReport.Packages) { Console.WriteLine(packageCompletionReport.Id + " , " + packageCompletionReport.Name + " , Sender : " + eslClient.GetPackage(new PackageId(packageCompletionReport.Id)).SenderInfo.Email); } } // Download the usage report sdkUsageReport = eslClient.PackageService.DownloadUsageReport(from, to); csvUsageReport = eslClient.PackageService.DownloadUsageReportAsCSV(from, to); // Get the number of packages in draft for sender IDictionary<UsageReportCategory, int> categoryCounts = sdkUsageReport.SenderUsageReports[0].CountByUsageReportCategory; int numOfDrafts = categoryCounts[UsageReportCategory.DRAFT]; } } }

Retrieving IPEN Journal Entries

IPEN Journal entries can be retrieved in either JSON format or CSV format. The following code samples illustrate how to do both.

Java Code

package com.eSignLive.com.esl.sdk.examples; import com.eSignLive.com.esl.sdk.NotaryJournalEntry; import com.eSignLive.com.esl.sdk.internal.Converter; import java.util.List; import java.util.Properties; public class NotaryJournalExample extends SDKSample { public List<NotaryJournalEntry> sdkJournalEntries; public String csvJournalEntries; private String senderUID; public static void main( String... args ) { new NotaryJournalExample(Props.get()).run(); } public NotaryJournalExample( Properties props ) { this( props.getProperty( "api.key" ), props.getProperty( "api.url" ) ); } public NotaryJournalExample( String apiKey, String apiUrl ) { super( apiKey, apiUrl ); this.senderUID = Converter.apiKeyToUID(apiKey); } public void execute() { sdkJournalEntries = eslClient.getPackageService().getJournalEntries(senderUID); csvJournalEntries = eslClient.getPackageService().getJournalEntriesAsCSV(senderUID); } }

C# Code

using System; using System.Collections.Generic; using eSignLive.com.ESL.SDK; using eSignLive.com.ESL.SDK.Internal; namespace SDK.Examples { public class NotaryJournalExample : SDKSample { public List<NotaryJournalEntry> sdkJournalEntries; public string csvJournalEntries; private string senderUID; public static void Main(string[] args) { new NotaryJournalExample(Props.GetInstance()).Run(); } public NotaryJournalExample(Props props) : this(props.Get("api.key"), props.Get("api.url")) { } public NotaryJournalExample(string apiKey, string apiUrl) : base(apiKey, apiUrl) { this.senderUID = Converter.apiKeyToUID(apiKey); } override public void Execute() { sdkJournalEntries = eslClient.PackageService.GetJournalEntries(senderUID); csvJournalEntries = eslClient.PackageService.GetJournalEntriesAsCSV(senderUID); } } }

Was this information helpful?
X