Last modified: 2024-03-05

SDK Java

Il est fortement recommandé d'utiliser un écouteur de rappel (Callback Listener) au lieu d'interroger les statuts de transaction. L'utilisation de l'interrogation peut consommer des ressources inutiles tant de votre côté que du côté du service OneSpan Sign.

Cette section aborde les sujets suivants relatifs à la recherche d'informations sur les processus de signature électronique :

Récupération des informations sur la version

Les exemples de code suivants illustrent comment récupérer votre version de OneSpan Sign.

Code Java

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(); } }

Code C#

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(); } } }

Récupération d'informations pour l'assistance technique

Les exemples de code suivants illustrent comment récupérer les informations sur les transactions pour notre équipe de soutien.

Code Java

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); } }

Code C#

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); } } }

Récupération de toutes les approbations pour une transaction

Les exemples de code suivants illustrent comment récupérer toutes les approbations pour une transaction spécifiée.

Code Java

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); } }

Code C#

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); } } }

Récupération d'une transaction

Une fois que vous avez commencé à créer et à envoyer des transactions, vous pouvez souhaiter récupérer la dernière version d'une transaction particulière. Pour ce faire, vous avez besoin de l'ID de la transaction que vous souhaitez récupérer.

Les exemples de code suivants illustrent comment récupérer l'ID d'une transaction.

Code Java

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

Code C#

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

Téléchargement de documents

Une fois que vous avez commencé à créer et à envoyer des transactions, vous pouvez souhaiter récupérer les dernières versions des documents qui se trouvent dans une transaction particulière. Pour ce faire, vous avez besoin de l'ID de la transaction et des ID des documents pertinents.

Les exemples de code suivants illustrent la manière de procéder au téléchargement : (1) un document spécifique; (2) le résumé des preuves de la transaction; (3) un fichier compressé qui contient tous les documents de la transaction.

Code Java

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");

Code C#

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);

Téléchargement de documents achevés dans une plage de dates donnée

Les exemples de code suivants illustrent comment télécharger des documents qui ont été complétés dans une plage de dates spécifiée.

Code Java

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; } } }

Code C#

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; } } } }

Récupération de le statut d'une transaction

Une fois qu'une transaction a été créée, vous pouvez vouloir récupérer uniquement son statut de signature (au lieu de la transaction entière). Les exemples de code suivants illustrent comment récupérer le statut de signature d'une transaction.

Code Java

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());

Code C#

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);

Récupération des valeurs des champs

Lorsqu'une transaction a été effectuée, il peut être utile de récupérer les valeurs saisies dans certains champs. Un seul appel permet d'accéder à tous les champs de la transaction.

Les exemples de code suivants permettent de récupérer une liste de tous les champs, puis d'afficher leurs valeurs. Les échantillons supposent que : (1) la signature est terminée pour une transaction qui contient des champs; (2) vous connaissez le nom de la transaction PackageId.

Code Java

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() ); }

Code C#

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 ); }

Raisons du déclin de l'activité de récupération

Un signataire peut refuser de signer une transaction par voie électronique. Lorsque cela se produit, le signataire est invité à fournir un motif. Cette raison est enregistrée dans la liste des messages de la transaction.

Les exemples de code suivants illustrent comment récupérer un motif de refus à partir d'une transaction.

Code Java

// 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());

Code C#

// 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);

Récupération d'un rapport d'achèvement

Un Completion Report contient des informations sur : (1) un expéditeur; (2) ses transactions avec un statut spécifique (par exemple, ÉBAUCHE, ENVOYÉ, COMPLÉTÉ).

Un tel rapport peut être récupéré par deux méthodes alternatives : (1) sous forme d'un CompletionReport objet; (2) en format CSV.

Les exemples de code suivants illustrent comment récupérer un rapport d'achèvement en utilisant les deux méthodes.

Code Java

// 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()); }

Code C#

// 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); }

Récupération d'un rapport d'utilisation

Un Usage Report contient : (1) une liste de tous les expéditeurs sur un compte; (2) pour chaque expéditeur, le nombre de transactions et leurs statuts de signature (par exemple, ÉBAUCHE, ENVOYÉ, COMPLÉTÉ).

Un tel rapport peut être récupéré par deux méthodes alternatives : (1) sous forme d'un UsageReport objet; (2) en format CSV.

Les exemples de code suivants illustrent comment récupérer un rapport d'utilisation en utilisant les deux méthodes.

Code Java

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); } }

Code C#

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]; } } }

Récupération des entrées du journal e-Notary

les entrées du journal e-Notary peuvent être récupérées au format JSON ou CSV. Les exemples de code suivants illustrent comment faire les deux.

Code Java

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); } }

Code C#

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