Skip to content

Commit f699326

Browse files
author
Kharko, Yaryna
committed
Fixed merge conflicts
2 parents d458806 + f914a19 commit f699326

21 files changed

Lines changed: 710 additions & 36 deletions

README.md

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,17 @@
11
# Java Launcher Code Examples
22

3-
This GitHub repo includes code example for both the DocuSign eSignature REST API as well as the DocuSign Rooms API. To use the Rooms API code examples, change the **DS_API_NAME** value to `ROOMS` in the application.json config file.
3+
This GitHub repo includes code example for the DocuSign eSignature REST API, for the DocuSign Rooms API and for the Click API. To use the Rooms API code examples, change the **DS_API_NAME** value to `ROOMS` in the application.json config file, to use the Click API, change the **DS_API_NAME** value to `CLICK` in the application.json config file.
44

55
**Note:** to use the Rooms API you must also [create your DocuSign Developer Account for Rooms](https://developers.docusign.com/docs/rooms-api/rooms101/create-account).
66

77
## Introduction
88
This repo is a Java Spring Boot application that demonstrates:
99

10-
1. **Embedded Signing.**
10+
## eSignature API
11+
12+
For more information about the scopes used for obtaining authorization to use the eSignature API, see the [Required Scopes section](https://developers.docusign.com/docs/esign-rest-api/esign101/auth)
13+
14+
1. **Use embedded signing.**
1115
[Source.](./src/main/java/com/docusign/EG001ControllerEmbeddedSigning.java)
1216
This example sends an envelope, and then uses embedded signing for the first signer.
1317
With embedded signing, DocuSign signing is initiated from your website.
@@ -34,11 +38,11 @@ This repo is a Java Spring Boot application that demonstrates:
3438
1. **Send an envelope and upload its documents with multipart binary transfer.**
3539
[Source.](./src/main/java/com/docusign/controller/eSignature/examples/EG010ControllerSendBinaryDocs.java)
3640
Binary transfer is 33% more efficient than using Base64 encoding.
37-
1. **Embedded sending.**
41+
1. **Use embedded sending.**
3842
[Source.](./src/main/java/com/docusign/controller/eSignature/examples/EG011ControllerEmbeddedSending.java)
3943
1. **Embedded DocuSign web tool (NDSE).**
4044
[Source.](./src/main/java/com/docusign/controller/eSignature/examples/EG012ControllerEmbeddedConsole.java)
41-
1. **Embedded Signing from a template with an added document.**
45+
1. **Use embedded signing from a template with an added document.**
4246
[Source.](./src/main/java/com/docusign/controller/eSignature/examples/EG013ControllerAddDocToTemplate.java)
4347
This example sends an envelope based on a template.
4448
In addition to the template's document(s), the example adds an
@@ -103,12 +107,36 @@ This repo is a Java Spring Boot application that demonstrates:
103107
[Source.](./src/main/java/com/docusign/controller/eSignature/examples/EG030ControllerApplyBrandToTemplate.java)
104108
This code example demonstrates how to apply a brand you've created to a template using using the [Create Envelope](https://developers.docusign.com/esign-rest-api/reference/Envelopes/Envelopes/create) method.
105109
You must have at least one created template and brand.
106-
107110
1. **Bulk sending envelopes to multiple recipients**
108111
[Source.](./src/main/java/com/docusign/controller/eSignature/examples/EG031ControllerBulkSendEnvelopes.java)
109112
This example creates and sends a bulk envelope by generating a bulk recipient list and initiating a bulk send.
113+
1. **Pausing a signature workflow Source.**
114+
[Source.](./src/main/java/com/docusign/controller/eSignature/examples/EG032ControllerPauseSignatureWorkflow.java)
115+
This code example demonstrates how to create an envelope where the workflow is paused before the envelope is sent to a second recipient.
116+
1. **Unpausing a signature workflow**
117+
[Source.](./src/main/java/com/docusign/controller/eSignature/examples/EG033ControllerUnpauseSignatureWorkflow.java)
118+
This code example demonstrates how to resume an envelope workflow that has been paused
119+
1. **Using conditional recipients**
120+
[Source.](./src/main/java/com/docusign/controller/eSignature/examples/EG034ControllerUseConditionalRecipients.java)
121+
This code example demonstrates how to create an envelope where the workflow is routed to different recipients based on the value of a transaction.
122+
123+
124+
1. **Сreating an envelope where the workflow is paused**
125+
[Source.](./src/main/java/com/docusign/controller/eSignature/examples/EG032ControllerPauseSignatureWorkflow.java)
126+
This topic demonstrates how to create an envelope where the workflow is paused before the envelope is sent to a second recipient.
127+
128+
1. **Resuming an envelope workflow that has been paused**
129+
[Source.](./src/main/java/com/docusign/controller/eSignature/examples/EG033ControllerUnpauseSignatureWorkflow.java)
130+
This topic demonstrates how to resume an envelope workflow that has been paused.
131+
132+
1. **Use conditional recipients**
133+
[Source.](./src/main/java/com/docusign/controller/eSignature/examples/EG034ControllerUseConditionalRecipients.java)
134+
This topic demonstrates how to create an envelope where the workflow is paused before the envelope is sent to a second recipient.
110135

111136
## Rooms API
137+
138+
For more information about the scopes used for obtaining authorization to use the Rooms API, see the [Required Scopes section](https://developers.docusign.com/docs/rooms-api/rooms101/auth/)
139+
112140
**Note:** to use the Rooms API you must also [create your DocuSign Developer Account for Rooms](https://developers.docusign.com/docs/rooms-api/rooms101/create-account).
113141

114142

@@ -166,6 +194,8 @@ The **refresh token** is not used in this example.
166194
* Authentication with DocuSign via the [JSON Web Token (JWT) Grant](https://developers.docusign.com/platform/auth/jwt/).
167195
When the token expires, it updates automatically.
168196

197+
**Note:** Before you can make any API calls using JWT Grant, you must get your user’s consent for your app to impersonate them. To do this, the `impersonation` scope is added when requesting a JSON Web Token.
198+
169199

170200
## Installation
171201

src/main/java/com/docusign/EG001ControllerEmbeddedSigning.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929

3030

3131
/**
32-
* Embedded Signing Ceremony.<br/>
33-
* This example sends an envelope, and then uses an embedded signing ceremony
32+
* Use embedded signing.<br/>
33+
* This example sends an envelope, and then uses embedded signing
3434
* for the first signer. Embedded signing provides a smoother user experience
35-
* for the signer: the DocuSign signing ceremony is initiated from your site.
35+
* for the signer: the DocuSign signing is initiated from your site.
3636
*/
3737
@Controller
3838
@RequestMapping("/eg001")
@@ -50,7 +50,7 @@ public class EG001ControllerEmbeddedSigning extends AbstractEsignatureController
5050

5151
@Autowired
5252
public EG001ControllerEmbeddedSigning(DSConfiguration config, Session session, User user) {
53-
super(config, "eg001", "Embedded Signing Ceremony");
53+
super(config, "eg001", "Use embedded signing");
5454
this.session = session;
5555
this.user = user;
5656
}
@@ -73,11 +73,11 @@ protected Object doWork(WorkArguments args, ModelMap model,
7373
String envelopeId = envelopeSummary.getEnvelopeId();
7474
session.setEnvelopeId(envelopeId);
7575

76-
// Step 3. create the recipient view, the Signing Ceremony
76+
// Step 3. create the recipient view, the embedded signing
7777
RecipientViewRequest viewRequest = makeRecipientViewRequest(signerEmail, signerName);
7878
ViewUrl viewUrl = envelopesApi.createRecipientView(accountId, envelopeId, viewRequest);
7979

80-
// Step 4. Redirect the user to the Signing Ceremony
80+
// Step 4. Redirect the user to the embedded signing
8181
// Don't use an iFrame!
8282
// State can be stored/recovered using the framework's session or a
8383
// query parameter on the returnUrl (see the makeRecipientViewRequest method)
@@ -90,7 +90,7 @@ private RecipientViewRequest makeRecipientViewRequest(String signerEmail, String
9090
// should typically be a callback route somewhere in your app.
9191
// The query parameter is included as an example of how
9292
// to save/recover state information during the redirect to
93-
// the DocuSign signing ceremony. It's usually better to use
93+
// the DocuSign signing. It's usually better to use
9494
// the session mechanism of your web framework. Query parameters
9595
// can be changed/spoofed very easily.
9696
viewRequest.setReturnUrl(config.getDsReturnUrl() + "?state=123");
@@ -107,9 +107,9 @@ private RecipientViewRequest makeRecipientViewRequest(String signerEmail, String
107107
viewRequest.setClientUserId(SIGNER_CLIENT_ID);
108108

109109
// DocuSign recommends that you redirect to DocuSign for the
110-
// Signing Ceremony. There are multiple ways to save state.
110+
// embedded signing. There are multiple ways to save state.
111111
// To maintain your application's session, use the pingUrl
112-
// parameter. It causes the DocuSign Signing Ceremony web page
112+
// parameter. It causes the DocuSign signing web page
113113
// (not the DocuSign server) to send pings via AJAX to your app.
114114
// NOTE: The pings will only be sent if the pingUrl is an https address
115115
viewRequest.setPingFrequency("600"); // seconds

src/main/java/com/docusign/common/WorkArguments.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ public class WorkArguments {
2828
private String dsReturnUrl;
2929
private String dsPingUrl;
3030
private String signerClientId;
31+
private String signerCheckedEmail;
32+
private String signerCheckedName;
33+
private String signerNotCheckedEmail;
34+
private String signerNotCheckedName;
3135
private String docSelect;
3236
private String accessCode;
3337
private String brandName;

src/main/java/com/docusign/controller/eSignature/examples/EG011ControllerEmbeddedSending.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424

2525
/**
26-
* Embedded Sending<br />
26+
* Use embedded sending<br />
2727
* An envelope will be created in draft mode. A browser will then be redirected
2828
* to the DocuSign web tool where the envelope can be (optionally) updated and
2929
* then sent. The envelope includes a pdf, Word, and HTML document.

src/main/java/com/docusign/controller/eSignature/examples/EG013ControllerAddDocToTemplate.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535

3636
/**
37-
* Embedded Signing Ceremony from a template with an added document. <br/>
37+
* Use embedded signing from a template with an added document. <br/>
3838
* This example sends an envelope based on a template. In addition to the
3939
* template's document(s), the example adds an additional document to the
4040
* envelope by using the Composite Templates.
@@ -56,7 +56,7 @@ public class EG013ControllerAddDocToTemplate extends AbstractEsignatureControlle
5656

5757
@Autowired
5858
public EG013ControllerAddDocToTemplate(DSConfiguration config, Session session, User user) {
59-
super(config, "eg013", "Embedded Signing Ceremony from template and extra doc");
59+
super(config, "eg013", "Use embedded signing from template and extra doc");
6060
this.session = session;
6161
this.user = user;
6262
}
@@ -86,7 +86,7 @@ protected Object doWork(WorkArguments args, ModelMap model,
8686
// Step 2. call Envelopes::create API method
8787
EnvelopeSummary results = envelopesApi.createEnvelope(accountId, envelope);
8888

89-
// Step 3. create the recipient view, the Signing Ceremony
89+
// Step 3. create the recipient view, the embedded signing
9090
RecipientViewRequest viewRequest = makeRecipientViewRequest(args);
9191
ViewUrl viewUrl = envelopesApi.createRecipientView(accountId, results.getEnvelopeId(), viewRequest);
9292
return new RedirectView(viewUrl.getUrl());
@@ -108,9 +108,9 @@ private static RecipientViewRequest makeRecipientViewRequest(WorkArguments args)
108108
viewRequest.setClientUserId(args.getSignerClientId());
109109

110110
// DocuSign recommends that you redirect to DocuSign for the
111-
// Signing Ceremony. There are multiple ways to save state.
111+
// embedded signing. There are multiple ways to save state.
112112
// To maintain your application's session, use the pingUrl
113-
// parameter. It causes the DocuSign Signing Ceremony web page
113+
// parameter. It causes the DocuSign signing web page
114114
// (not the DocuSign server) to send pings via AJAX to your app.
115115
// NOTE: The pings will only be sent if the pingUrl is an https address
116116
viewRequest.setPingFrequency("600");

src/main/java/com/docusign/controller/eSignature/examples/EG016ControllerSetTabValues.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ private RecipientViewRequest makeRecipientViewRequest(String signerEmail, String
7777
// should typically be a callback route somewhere in your app.
7878
// The query parameter is included as an example of how
7979
// to save/recover state information during the redirect to
80-
// the DocuSign signing ceremony. It's usually better to use
80+
// the DocuSign signing. It's usually better to use
8181
// the session mechanism of your web framework. Query parameters
8282
// can be changed/spoofed very easily.
8383
viewRequest.setReturnUrl(config.getDsReturnUrl() + "?state=123");
@@ -94,9 +94,9 @@ private RecipientViewRequest makeRecipientViewRequest(String signerEmail, String
9494
viewRequest.setClientUserId(SIGNER_CLIENT_ID);
9595

9696
// DocuSign recommends that you redirect to DocuSign for the
97-
// Signing Ceremony. There are multiple ways to save state.
97+
// Embedded signing . There are multiple ways to save state.
9898
// To maintain your application's session, use the pingUrl
99-
// parameter. It causes the DocuSign Signing Ceremony web page
99+
// parameter. It causes the DocuSign signing web page
100100
// (not the DocuSign server) to send pings via AJAX to your app.
101101
// NOTE: The pings will only be sent if the pingUrl is an https address
102102
viewRequest.setPingFrequency("600"); // seconds

src/main/java/com/docusign/controller/eSignature/examples/EG017ControllerSetTemplateTabValues.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ private RecipientViewRequest makeRecipientViewRequest(String signerEmail, String
8989
// should typically be a callback route somewhere in your app.
9090
// The query parameter is included as an example of how
9191
// to save/recover state information during the redirect to
92-
// the DocuSign signing ceremony. It's usually better to use
92+
// the DocuSign signing. It's usually better to use
9393
// the session mechanism of your web framework. Query parameters
9494
// can be changed/spoofed very easily.
9595
viewRequest.setReturnUrl(config.getDsReturnUrl() + "?state=123");
@@ -106,9 +106,9 @@ private RecipientViewRequest makeRecipientViewRequest(String signerEmail, String
106106
viewRequest.setClientUserId(SIGNER_CLIENT_ID);
107107

108108
// DocuSign recommends that you redirect to DocuSign for the
109-
// Signing Ceremony. There are multiple ways to save state.
109+
// embedded signing. There are multiple ways to save state.
110110
// To maintain your application's session, use the pingUrl
111-
// parameter. It causes the DocuSign Signing Ceremony web page
111+
// parameter. It causes the DocuSign signing web page
112112
// (not the DocuSign server) to send pings via AJAX to your app.
113113
// NOTE: The pings will only be sent if the pingUrl is an https address
114114
viewRequest.setPingFrequency("600"); // seconds
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
package com.docusign.controller.eSignature.examples;
2+
3+
import com.docusign.DSConfiguration;
4+
import com.docusign.common.WorkArguments;
5+
import com.docusign.core.model.DoneExample;
6+
import com.docusign.core.model.Session;
7+
import com.docusign.core.model.User;
8+
import com.docusign.esign.api.EnvelopesApi;
9+
import com.docusign.esign.client.ApiException;
10+
import com.docusign.esign.model.*;
11+
import org.springframework.beans.factory.annotation.Autowired;
12+
import org.springframework.stereotype.Controller;
13+
import org.springframework.ui.ModelMap;
14+
import org.springframework.web.bind.annotation.RequestMapping;
15+
16+
import javax.servlet.http.HttpServletResponse;
17+
import java.io.IOException;
18+
import java.util.Arrays;
19+
import java.util.Collections;
20+
21+
/**
22+
* This topic demonstrates how to create an envelope where the workflow
23+
* is paused before the envelope is sent to a second recipient.
24+
*/
25+
@Controller
26+
@RequestMapping("/eg032")
27+
public class EG032ControllerPauseSignatureWorkflow extends AbstractEsignatureController {
28+
29+
private static final String DOCUMENT_FILE_NAME = "Welcome.txt";
30+
private static final String DOCUMENT_ID = "1";
31+
private static final String DOCUMENT_NAME = "Welcome";
32+
33+
private final Session session;
34+
private final User user;
35+
36+
37+
@Autowired
38+
public EG032ControllerPauseSignatureWorkflow(DSConfiguration config, Session session, User user) {
39+
super(config, "eg032", "Pause a signature workflow.");
40+
this.session = session;
41+
this.user = user;
42+
}
43+
44+
@Override
45+
protected Object doWork(WorkArguments args, ModelMap model, HttpServletResponse response) throws ApiException, IOException {
46+
47+
// Step 2: Construct your API headers
48+
EnvelopesApi envelopesApi = createEnvelopesApi(this.session.getBasePath(), this.user.getAccessToken());
49+
50+
// Step 3: Construct your envelope JSON body
51+
EnvelopeDefinition envelope = createEnvelope(args);
52+
53+
// Step 4: Call the eSignature REST API
54+
EnvelopeSummary results = envelopesApi.createEnvelope(this.session.getAccountId(), envelope);
55+
56+
this.session.setEnvelopeId(results.getEnvelopeId());
57+
DoneExample.createDefault(this.title)
58+
.withJsonObject(results)
59+
.withMessage(
60+
"The envelope where the workflow is paused before the envelope is sent to a second recipient " +
61+
"has been created and sent!<br />Envelope ID "
62+
+ this.session.getEnvelopeId() + ".")
63+
.addToModel(model);
64+
65+
return DONE_EXAMPLE_PAGE;
66+
}
67+
68+
private static EnvelopeDefinition createEnvelope(WorkArguments args) throws IOException {
69+
Document document = EnvelopeHelpers.createDocumentFromFile(DOCUMENT_FILE_NAME, DOCUMENT_NAME, DOCUMENT_ID);
70+
71+
WorkflowStep workflowStep = new WorkflowStep();
72+
workflowStep.setAction(EnvelopeHelpers.WORKFLOW_STEP_ACTION_PAUSE);
73+
workflowStep.setTriggerOnItem(EnvelopeHelpers.WORKFLOW_TRIGGER_ROUTING_ORDER);
74+
workflowStep.setItemId("2");
75+
76+
Workflow workflow = new Workflow();
77+
workflow.setWorkflowSteps(Collections.singletonList(workflowStep));
78+
79+
SignHere signHere1 = new SignHere();
80+
signHere1.setName("SignHereTabs");
81+
signHere1.setXPosition("200");
82+
signHere1.setYPosition("200");
83+
signHere1.setTabLabel("Sign Here");
84+
signHere1.setPageNumber("1");
85+
signHere1.setDocumentId(document.getDocumentId());
86+
87+
Signer signer1 = new Signer();
88+
signer1.setName(args.getSignerName());
89+
signer1.setEmail(args.getSignerEmail());
90+
signer1.setRoutingOrder("1");
91+
signer1.setRecipientId("1");
92+
signer1.setTabs(EnvelopeHelpers.createSignerTabs(signHere1));
93+
94+
SignHere signHere2 = new SignHere();
95+
signHere2.setName("SignHereTabs");
96+
signHere2.setXPosition("300");
97+
signHere2.setYPosition("200");
98+
signHere2.setTabLabel("Sign Here");
99+
signHere2.setPageNumber("1");
100+
signHere2.setDocumentId(document.getDocumentId());
101+
102+
Signer signer2 = new Signer();
103+
signer2.setName(args.getSignerName2());
104+
signer2.setEmail(args.getSignerEmail2());
105+
signer2.setRoutingOrder("2");
106+
signer2.setRecipientId("2");
107+
signer2.setTabs(EnvelopeHelpers.createSignerTabs(signHere2));
108+
109+
Recipients recipients = new Recipients();
110+
recipients.setSigners(Arrays.asList(signer1, signer2));
111+
112+
EnvelopeDefinition envelope = new EnvelopeDefinition();
113+
envelope.setEmailSubject("EnvelopeWorkflowTest");
114+
envelope.setDocuments(Collections.singletonList(document));
115+
envelope.setStatus(EnvelopeHelpers.ENVELOPE_STATUS_SENT);
116+
envelope.setRecipients(recipients);
117+
envelope.setWorkflow(workflow);
118+
119+
return envelope;
120+
}
121+
}

0 commit comments

Comments
 (0)