Package Attributes

This guide shows you how to add custom data to your package.

Custom package data is used for customized data related to the package. The data in this section of the package information is not interpreted by OneSpan Sign. The users of this data are free to store and interpret whatever data they want. The data is organized as a map.

The Code

You can download the complete example code from the Developer Community Code Share.

The sample code below shows you how to edit your DocumentPackage object in order to add package attributes.

DocumentPackage superDuperPackage1 = newPackageNamed( "Policy " + new SimpleDateFormat( "HH:mm:ss" ).format( new Date() ) )
        	     .describedAs( "This is a package created using the e-SignLive SDK" )
        	     .expiresAt( new Date() )
        	     .withEmailMessage( "This message should be delivered to all signers" )
        	     .withSigner( newSignerWithEmail( "signer1@xyz.com" )
        	          .withCustomId( "Client1" )
        	          .withFirstName( "John" )
        	          .withLastName( "Smith" )
        	          .withTitle( "Managing Director" )
        	          .withCompany( "Acme Inc." ) )
        	     .withDocument( newDocumentWithName( "First Document" )
        	          .fromStream( new java.io.FileInputStream(DOCUMENT_PATH), DocumentType.PDF )
        	          .withSignature( signatureFor( "signer1@xyz.com" )
        	               .onPage( 0 )
        	               .withField( FieldBuilder.checkBox()
        	                    .onPage( 0 )
        	                    .atPosition( 400, 200 )
        	                    .withValue( "x" ) )
        	               .atPosition( 100, 100 ) ) )
        	     .withAttributes(newDocumentPackageAttributes()
        	               .withAttribute( "First Name", "Bill" )
        	               .withAttribute("Last Name", "Johnson")
        	               .withAttribute("Signing Order", "1")
        	               .build())
        	          .build();

Attributes are set on a package level. To retrieve your attributes, you will first need to retrieve your package. Then, with your DocumentPackage object, you use the getAttributes() and getContents() methods to retrieve your attributes. As mentioned previously, attributes will be returned to you as a map.

DocumentPackage retrievedPackage = eslClient.getPackage( packageId );
		
Map<String, Object> attributes = retrievedPackage.getAttributes().getContents();

for (Map.Entry<String, Object> entry : attributes.entrySet())
{
      System.out.println( entry.getKey() + ": " + entry.getValue() );
}

Running Your Code

Below is a screenshot of the console output you can expect once you’ve run your code.

3

Get The Code

Custom package data is used for customized data related to the package. The data in this section of the package information is not interpreted by OneSpan Sign. The users of this data are free to store and interpret whatever data they want. The data is organized as a map.

The Code

You can download the complete example code from the Developer Community Code Share.

The sample code below shows you how to edit your DocumentPackage object in order to add package attributes.

DocumentPackage superDuperPackage = PackageBuilder.NewPackageNamed("Policy " + DateTime.Now)
                 .DescribedAs("This is a package created using the e-SignLive SDK")
                      .ExpiresOn(DateTime.Now.AddMonths(1))
                      .WithEmailMessage("This message should be delivered to all signers")
                      .WithSigner(SignerBuilder.NewSignerWithEmail("john.smith@example.com")
                           .WithCustomId("Client1")
                           .WithFirstName("John")
                           .WithLastName("Smith")
                           .WithTitle("Managing Director")
                           .WithCompany("Acme Inc."))
                      .WithDocument(DocumentBuilder.NewDocumentNamed("First Document")
                           .FromFile(@"C:/Users/hhaidary/Desktop/pdf/doc1.pdf")
                           .WithSignature(SignatureBuilder.SignatureFor("john.smith@example.com")
                           .OnPage(0)
                           .WithField(FieldBuilder.CheckBox()
                           .OnPage(0)
                           .AtPosition(400, 200)
                           .WithValue("x"))
                           .AtPosition(100, 100)))
                      .WithAttributes(new DocumentPackageAttributesBuilder()
                           .WithAttribute("First Name", "Bill")
                           .WithAttribute("Last Name", "Johnson")
                           .WithAttribute("Signing Order", "1")
                           .Build())
                      .Build();

Attributes are set on a package level. To retrieve your attributes, you will first need to retrieve your package. Then, with your DocumentPackage object, you use the getAttributes() and getContents() methods to retrieve your attributes. As mentioned previously, attributes will be returned to you as a map.

DocumentPackage retrievedPackage = eslClient.GetPackage(packageId);

IDictionary<string, Object> attributes = retrievedPackage.Attributes.Contents;

foreach (KeyValuePair<string, Object> entry in attributes)
{
     Debug.WriteLine(entry.Key + ": " + entry.Value);
}

Running Your Code

Below is a screenshot of the console output you can expect once you’ve run your code.

3

Get The Code

Custom package data is used for customized data related to the package. The data in this section of the package information is not interpreted by OneSpan Sign. The users of this data are free to store and interpret whatever data they want.

The Code

You can download the complete example code from the Developer Community Code Share.

The sample request below shows you how to edit your DocumentPackage object in order to add package attributes.

HTTP Request
POST /api/packages

HTTP Headers
Accept: application/json
Content-Type: multipart/form-data
Authorization: Basic api_key

Request Payload

------WebKitFormBoundary1bNO60n7FqP5WO4t
Content-Disposition: form-data; name="file"; filename="testDocumentExtraction.pdf"
Content-Type: application/pdf

%PDF-1.5
%µµµµ
1 0 obj
<>>>
endobj.... 

------WebKitFormBoundary1bNO60n7FqP5WO4t
Content-Disposition: form-data; name="payload"

{
  "documents": [
    {
      "approvals": [
        {
          "id": "ExampleSignatureId",
          "role": "Signer1",
          "fields": [
            {
              "page": 0,
              "top": 200,
              "subtype": "LABEL",
              "height": 50,
              "left": 100,
              "width": 200,
              "id": "myLabelField",
              "type": "INPUT",
              "value": "Example label field value"
            },
            {
              "page": 0,
              "top": 100,
              "subtype": "FULLNAME",
              "height": 50,
              "left": 100,
              "width": 200,
              "type": "SIGNATURE",
              "name": "ExampleSignatureId"
            }
          ],
          "name": ""
        }
      ],
      "id": "sample-contract",
      "name": "Test Document"
    }
  ],
  "status": "DRAFT",
  "type": "PACKAGE",
  "roles": [
    {
      "id": "Signer1",
      "type": "SIGNER",
      "signers": [
        {
          "email": "signer@example.com",
          "firstName": "John",
          "lastName": "Smith",
          "id": "Signer1"
        }
      ],
      "name": "Signer1"
    }
  ],
  "name": "Example Package",
  "data": {
    "First Name": "Bill",
    "Last Name": "Johnson",
    "Signing Order": "1"
  }
}

------WebKitFormBoundary1bNO60n7FqP5WO4t--

For a complete description of each field, take a look at the JSON Properties section below.

Response Payload

{
    "id": "9sKhW-h-qS9m6Ho3zRv3n2a-rkI="
}

Attributes are set on a package level. Therefore, you will need to get your package JSON in order to retrieve your package attributes.

Running Your Code

Below is a screenshot of the console output you can expect once you’ve run your code.

3

Get The Code

JSON Properties

Property Type Editable Required Default Sample Value(s)
status string Yes No DRAFT DRAFT / SENT / COMPLETED / ARCHIVED / DECLINED / OPTED_OUT / EXPIRED
type string Yes No PACKAGE PACKAGE / TEMPLATE / LAYOUT
name string Yes Yes n/a Document Attributes Example
documents
name string Yes No n/a sample doc
id string Yes No n/a sample-contract
approvals
fields
subtype string Yes No n/a FULLNAME / INITIALS / CAPTURE / MOBILE_CAPTURE / LABEL / TEXTFIELD / TEXTAREA / CHECKBOX / DATE / RADIO / LIST
type string Yes No n/a SIGNATURE / INPUT
extract boolean Yes No false true / false
height integer Yes No 50 50 / 100 / 150 …
left integer Yes No 0 50 / 100 / 150 …
page integer Yes No 0 0 / 1 / 2 …
top integer Yes No 0 50 / 100 / 150 …
width integer Yes No 200 50 / 100 / 150 …
role string Yes No n/a Signer1
id string Yes No n/a ExampleSignatureId
roles
id string Yes No n/a Client1
name string Yes No n/a Client1
type string Yes No SIGNER SIGNER / SENDER
signers
email string Yes Yes n/a preparer.email@example.com
firstName string Yes Yes n/a John
lastName string Yes Yes n/a Smith
phone string Yes No n/a 514-555-8888
id string Yes No n/a Client1
company string Yes No n/a Acme Inc.
title string Yes No n/a Managing Director
data
First Name string Yes No n/a Bill
Last Name string Yes No n/a Johnson
Signing Order string Yes No n/a 1