Skip to content

Commit 532a5b8

Browse files
committed
Update README.md
1 parent 13a52e1 commit 532a5b8

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

README.md

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Or you can manually download and add the following JARs to your project:
6767
Usage
6868
=====
6969

70-
To initialize the client and make the Login API Call:
70+
To send a signature request from a Template:
7171

7272
```java
7373
import com.docusign.esign.api.*;
@@ -90,9 +90,48 @@ public class DocuSignExample {
9090
Configuration.setDefaultApiClient(apiClient);
9191
try
9292
{
93+
94+
/////////////////////////////////////////////////////////////////////////////////////////////////////////
95+
// STEP 1: LOGIN API
96+
/////////////////////////////////////////////////////////////////////////////////////////////////////////
9397
AuthenticationApi authApi = new AuthenticationApi();
9498
LoginInformation loginInfo = authApi.login();
99+
100+
// parse first account ID (user might belong to multiple accounts)
95101
String accountId = loginInfo.getLoginAccounts().get(0).getAccountId();
102+
103+
/////////////////////////////////////////////////////////////////////////////////////////////////////////
104+
// *** STEP 2: CREATE ENVELOPE FROM TEMPLATE
105+
/////////////////////////////////////////////////////////////////////////////////////////////////////////
106+
107+
// create a new envelope to manage the signature request
108+
EnvelopeDefinition envDef = new EnvelopeDefinition();
109+
envDef.setEmailSubject("DocuSign Java SDK - Sample Signature Request");
110+
111+
// assign template information including ID and role(s)
112+
envDef.setTemplateId("[TEMPLATE_ID]");
113+
114+
// create a template role with a valid templateId and roleName and assign signer info
115+
TemplateRole tRole = new TemplateRole();
116+
tRole.setRoleName("[ROLE_NAME]");
117+
tRole.setName("[SIGNER_NAME]");
118+
tRole.setEmail("[SIGNER_EMAIL]");
119+
120+
// create a list of template roles and add our newly created role
121+
List<TemplateRole> templateRolesList = new ArrayList<TemplateRole>();
122+
templateRolesList.add(tRole);
123+
124+
// assign template role(s) to the envelope
125+
envDef.setTemplateRoles(templateRolesList);
126+
127+
// send the envelope by setting |status| to "sent". To save as a draft set to "created"
128+
envDef.setStatus("sent");
129+
130+
// instantiate a new EnvelopesApi object
131+
EnvelopesApi envelopesApi = new EnvelopesApi();
132+
133+
// call the createEnvelope() API
134+
EnvelopeSummary envelopeSummary = envelopesApi.createEnvelope(accountId, envDef);
96135
}
97136
catch (com.docusign.esign.client.ApiException ex)
98137
{

0 commit comments

Comments
 (0)