Skip to content

Commit 2d05209

Browse files
committed
Merge branch 'master' into feature/add-maestro-examples
# Conflicts: # src/main/java/com/docusign/DSConfiguration.java # src/main/java/com/docusign/common/ApiIndex.java # src/main/resources/application.example.json # src/main/resources/public/assets/search.js # src/main/webapp/WEB-INF/templates/views/pages/esignature/index.jsp
2 parents 0b4674e + 6a3ba8a commit 2d05209

26 files changed

+1197
-50
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,15 @@ For information about the scopes used for obtaining authorization to use the Adm
5959
For a list of code examples that use the Admin API, see the [How-to guides overview](https://developers.docusign.com/docs/admin-api/how-to/) on the DocuSign Developer Center.
6060

6161

62+
## Web Forms API
63+
64+
The Web Forms API is available in all developer accounts, but only in certain production account plans. Contact [DocuSign Support](https://support.docusign.com/) or your account manager to find out whether the Web Forms API is available for your production account plan.
65+
66+
For more information about the scopes used for obtaining authorization to use the Rooms API, see [Required scopes](https://developers.docusign.com/docs/web-forms-api/plan-integration/authentication/).
67+
68+
For a list of code examples that use the Web Forms API, see the [How-to guides overview](https://developers.docusign.com/docs/web-forms-api/how-to/) on the DocuSign Developer Center.
69+
70+
6271
## Installation
6372

6473
### Prerequisites

azure-pipelines.yml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ steps:
4848
name: tests_config_properties
4949
displayName: 'download config.properties'
5050
inputs:
51-
secureFile: 'java-php.config.properties'
51+
secureFile: 'java.config.properties'
5252

5353

5454
- script: |
@@ -110,4 +110,13 @@ steps:
110110
- script: |
111111
docker stop $(docker ps -a -q)
112112
docker rm $(docker ps -a -q)
113-
displayName: 'stop java app'
113+
displayName: 'stop java app'
114+
115+
- script: |
116+
allure generate --clean --output $(Build.SourcesDirectory)/java-allure-output '$(Build.SourcesDirectory)/launcher-automation/target/allure-results'
117+
displayName: generate allure html reports
118+
119+
- task: PublishAllureReport@1
120+
displayName: 'Publish Allure Report'
121+
inputs:
122+
reportDir: '$(Build.SourcesDirectory)/java-allure-output'

pom.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@
3131
<click.version> 1.4.0</click.version>
3232
<monitor.version>1.3.0</monitor.version>
3333
<admin.version>1.3.0</admin.version>
34+
<webforms.version>1.0.2-RC12</webforms.version>
3435
<swagger-core-version>2.2.8</swagger-core-version>
3536
<jackson-version>2.14.2</jackson-version>
3637
<jersey2.version>3.0.9</jersey2.version>
3738
</properties>
3839

39-
4040
<dependencies>
4141
<dependency>
4242
<groupId>org.springframework.boot</groupId>
@@ -188,6 +188,12 @@
188188
<classifier>shaded</classifier>
189189
</dependency>
190190

191+
<dependency>
192+
<groupId>com.docusign</groupId>
193+
<artifactId>docusign-webforms-java</artifactId>
194+
<version>${webforms.version}</version>
195+
</dependency>
196+
191197
<dependency>
192198
<groupId>org.springframework.boot</groupId>
193199
<artifactId>spring-boot-autoconfigure</artifactId>

src/main/java/com/docusign/DSConfiguration.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ public class DSConfiguration {
103103
@Value("${DS_ADMIN_BASE_PATH}")
104104
private String adminBasePath;
105105

106+
@Value("${DS_WEBFORMS_BASE_PATH}")
107+
private String webFormsBasePath;
108+
106109
@Value("${DS_MAESTRO_BASE_PATH}")
107110
private String maestroBasePath;
108111

src/main/java/com/docusign/HttpsConnectWebhookhMacValidation.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ public static boolean HashIsValid(String secret, byte[] payload, String verify)
4343
return isEqual;
4444
}
4545
//ds-snippet-end:Connect1Step1
46-
public static void main(String[] args) {
4746

47+
public static void main(String[] args)
48+
{
4849
LOGGER.info("DocuSign HMAC Tester");
4950
try {
5051
Boolean response = HttpsConnectWebhookhMacValidation.HashIsValid("{DocuSign HMAC private key}",

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ public enum ApiIndex {
77
MAESTRO("/pages/maestro/index", "", "/mae001", "/mae"),
88
MONITOR("/pages/monitor/index", "", "/m001", "/m"),
99
ADMIN("/pages/admin/index", "/management", "/a001", "/a"),
10-
CONNECT("/pages/connect/index", "", "/con001", "/con");
10+
CONNECT("/pages/connect/index", "", "/con001", "/con"),
11+
WEBFORMS("/pages/webforms/index", "/restapi", "/web001", "/web");
1112

1213
private final String indexPath;
1314

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,15 @@ protected void onInitModel(WorkArguments args, ModelMap model) throws Exception
4949
protected Object doWork(WorkArguments args, ModelMap model, HttpServletResponse response) throws ApiException {
5050
EnvelopesApi envelopesApi = createEnvelopesApi(session.getBasePath(), user.getAccessToken());
5151

52-
// Step 1. List the envelope's documents
52+
// List the envelope's documents
53+
//ds-snippet-start:eSign6Step3
5354
EnvelopeDocumentsResult envelopeDocumentsResult = EnvelopeDocsService.envelopeDocs(
5455
envelopesApi,
5556
session.getAccountId(),
5657
session.getEnvelopeId());
57-
58-
// Step 2. Process results
58+
//ds-snippet-end:eSign6Step3
59+
60+
// Process results
5961
// Save the envelopeId and its list of documents in the session so
6062
// they can be used in example 7 (download a document)
6163
List<EnvelopeDocumentInfo> envelopeDocItems = new ArrayList<>();

src/main/java/com/docusign/controller/eSignature/services/DocumentGenerationService.java

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,7 @@ public final class DocumentGenerationService {
3232

3333
public static final String DEFAULT_ID = "1";
3434

35-
public static DateSigned createDateSigned() {
36-
DateSigned dateSigned = new DateSigned();
37-
38-
dateSigned.setAnchorString("Date");
39-
dateSigned.setAnchorUnits(ANCHOR_UNITS);
40-
dateSigned.setAnchorYOffset("-22");
41-
42-
return dateSigned;
43-
}
44-
45-
// Step 3b start
35+
//ds-snippet-start:eSign42Step3
4636
private static EnvelopeDefinition addDocumentTemplate(String offerDocDocx) throws IOException {
4737
String documentName = "OfferLetterDemo.docx";
4838
Document document = EnvelopeHelpers.createDocumentFromFile(offerDocDocx, documentName, DEFAULT_ID);
@@ -54,6 +44,7 @@ private static EnvelopeDefinition addDocumentTemplate(String offerDocDocx) throw
5444

5545
return envelopeDefinition;
5646
}
47+
//ds-snippet-end:eSign42Step3
5748

5849
public String generateDocument(
5950
String accountId,
@@ -67,27 +58,27 @@ public String generateDocument(
6758
EnvelopesApi envelopesApi,
6859
TemplatesApi templatesApi
6960
) throws ApiException, IOException {
70-
// Step 2a start
61+
//ds-snippet-start:eSign42Step2
7162
TemplateSummary template = templatesApi.createTemplate(accountId, makeTemplate());
7263
String templateId = template.getTemplateId();
73-
// Step 2a end
64+
//ds-snippet-end:eSign42Step2
7465

75-
// Step 3a start
66+
//ds-snippet-start:eSign42Step3
7667
templatesApi.updateDocument(accountId, templateId, DEFAULT_ID, addDocumentTemplate(offerDocDocx));
77-
// Step 3a end
68+
//ds-snippet-end:eSign42Step3
7869

79-
// Step 4a start
70+
//ds-snippet-start:eSign42Step4
8071
templatesApi.createTabs(accountId, templateId, DEFAULT_ID, prepareTabs());
81-
// Step 4a end
72+
//ds-snippet-end:eSign42Step4
8273

83-
// Step 5a start
74+
//ds-snippet-start:eSign42Step5
8475
EnvelopeSummary envelopeSummary = envelopesApi.createEnvelope(
8576
accountId,
8677
makeEnvelope(candidateEmail, candidateName, template.getTemplateId()));
8778
String envelopeId = envelopeSummary.getEnvelopeId();
88-
// Step 5a end
79+
//ds-snippet-end:eSign42Step5
8980

90-
// Step 6 start
81+
//ds-snippet-start:eSign42Step6
9182
DocGenFormFieldResponse formFieldResponse = envelopesApi.getEnvelopeDocGenFormFields(accountId, envelopeId);
9283
String documentId = "";
9384
if (!formFieldResponse.getDocGenFormFields().isEmpty()) {
@@ -96,8 +87,9 @@ public String generateDocument(
9687
documentId = docGenFormFields.getDocumentId();
9788
}
9889
}
99-
// Step 6 end
100-
// Step 7a start
90+
//ds-snippet-end:eSign42Step6
91+
92+
//ds-snippet-start:eSign42Step7
10193
DocGenFormFieldRequest formFields = getFormFields(
10294
documentId,
10395
candidateName,
@@ -107,18 +99,18 @@ public String generateDocument(
10799
startDate);
108100

109101
envelopesApi.updateEnvelopeDocGenFormFields(accountId, envelopeId, formFields);
110-
// Step 7a end
102+
//ds-snippet-end:eSign42Step7
111103

112-
// Step 8 start
104+
//ds-snippet-start:eSign42Step8
113105
Envelope envelope = new Envelope();
114106
envelope.setStatus(EnvelopeHelpers.ENVELOPE_STATUS_SENT);
115107

116108
EnvelopeUpdateSummary envelopeUpdateSummary = envelopesApi.update(accountId, envelopeId, envelope);
117-
// Step 8 end
109+
//ds-snippet-end:eSign42Step8
118110
return envelopeUpdateSummary.getEnvelopeId();
119111
}
120112

121-
// Step 4b start
113+
//ds-snippet-start:eSign42Step4
122114
private TemplateTabs prepareTabs() {
123115
SignHere signHere = createSignHere();
124116
DateSigned dateSigned = createDateSigned();
@@ -129,7 +121,6 @@ private TemplateTabs prepareTabs() {
129121

130122
return templateTabs;
131123
}
132-
// Step 4b end
133124

134125
private SignHere createSignHere() {
135126
SignHere signHere = new SignHere();
@@ -141,9 +132,19 @@ private SignHere createSignHere() {
141132

142133
return signHere;
143134
}
144-
// Step 7b end
145135

146-
// Step 7b start
136+
private DateSigned createDateSigned() {
137+
DateSigned dateSigned = new DateSigned();
138+
139+
dateSigned.setAnchorString("Date");
140+
dateSigned.setAnchorUnits(ANCHOR_UNITS);
141+
dateSigned.setAnchorYOffset("-22");
142+
143+
return dateSigned;
144+
}
145+
//ds-snippet-end:eSign42Step4
146+
147+
//ds-snippet-start:eSign42Step7
147148
private DocGenFormFieldRequest getFormFields(
148149
String documentId,
149150
String candidateName,
@@ -185,9 +186,9 @@ private DocGenFormFieldRequest getFormFields(
185186

186187
return docGenFormFieldRequest;
187188
}
188-
// Step 5b end
189+
//ds-snippet-end:eSign42Step7
189190

190-
// Step 5b start
191+
//ds-snippet-start:eSign42Step5
191192
private EnvelopeDefinition makeEnvelope(String candidateEmail, String candidateName, String templateId) {
192193
TemplateRole signerRole = new TemplateRole();
193194
signerRole.setName(candidateName);
@@ -201,9 +202,9 @@ private EnvelopeDefinition makeEnvelope(String candidateEmail, String candidateN
201202

202203
return envelopeDefinition;
203204
}
204-
// Step 2b end
205+
//ds-snippet-end:eSign42Step5
205206

206-
// Step 2b start
207+
//ds-snippet-start:eSign42Step2
207208
private EnvelopeTemplate makeTemplate() {
208209
Signer signer = new Signer();
209210
signer.setRoleName(EnvelopeHelpers.SIGNER_ROLE_NAME);
@@ -222,5 +223,5 @@ private EnvelopeTemplate makeTemplate() {
222223

223224
return template;
224225
}
225-
// Step 3b stop
226+
//ds-snippet-end:eSign42Step2
226227
}

src/main/java/com/docusign/controller/eSignature/services/ListEnvelopesServices.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ public final class ListEnvelopesServices {
1313
public static EnvelopesInformation listEnvelopes(EnvelopesApi envelopesApi, String accountId) throws ApiException {
1414
EnvelopesApi.ListStatusChangesOptions options = envelopesApi.new ListStatusChangesOptions();
1515
LocalDate date = LocalDate.now().minusDays(FROM_DATE_OFFSET_DAYS);
16-
options.setFromDate(DateUtils.DATE_WITH_SLASH.format(date));
16+
options.setFromDate(DateUtils.DATE_WITH_LINES.format(date));
1717
return envelopesApi.listStatusChanges(accountId, options);
1818
}
1919
}

src/main/java/com/docusign/controller/eSignature/services/SetDocumentVisibilityService.java

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,14 @@
44
import com.docusign.esign.model.*;
55

66
import java.io.IOException;
7+
import java.nio.charset.StandardCharsets;
78
import java.util.Arrays;
89
import java.util.Collections;
910

11+
import org.apache.commons.io.FilenameUtils;
12+
import org.springframework.core.io.ClassPathResource;
13+
import org.springframework.util.StreamUtils;
14+
1015
public final class SetDocumentVisibilityService {
1116
//ds-snippet-start:eSign40Step3
1217
public static EnvelopeDefinition makeEnvelope(
@@ -32,10 +37,15 @@ public static EnvelopeDefinition makeEnvelope(
3237
recipients.setCarbonCopies(Collections.singletonList(carbonCopy));
3338

3439
EnvelopeDefinition envelopeDefinition = new EnvelopeDefinition();
40+
envelopeDefinition.setEnforceSignerVisibility("true");
3541
envelopeDefinition.setEmailSubject("Please sign this document set");
3642
envelopeDefinition.setRecipients(recipients);
3743

3844
envelopeDefinition.setDocuments(Arrays.asList(prepareDocumentsForSending(
45+
signerEmail,
46+
signerName,
47+
ccEmail,
48+
ccName,
3949
documentFileNamePDF,
4050
documentFileNameDOCX,
4151
documentFileNameHTML)));
@@ -72,12 +82,26 @@ private static Signer[] prepareSigners(
7282
}
7383

7484
private static Document[] prepareDocumentsForSending(
85+
String signerEmail,
86+
String signerName,
87+
String ccEmail,
88+
String ccName,
7589
String documentFileNamePDF,
7690
String documentFileNameDOCX,
7791
String documentFileNameHTML) throws IOException {
78-
Document documentHTML = EnvelopeHelpers.createDocumentFromFile(
79-
documentFileNameHTML,
92+
ClassPathResource resource = new ClassPathResource(documentFileNameHTML);
93+
String documentHTMLContentsString = StreamUtils.copyToString(resource.getInputStream(), StandardCharsets.UTF_8);
94+
documentHTMLContentsString = documentHTMLContentsString.replace("{USER_EMAIL}", signerEmail);
95+
documentHTMLContentsString = documentHTMLContentsString.replace("{USER_FULLNAME}", signerName);
96+
documentHTMLContentsString = documentHTMLContentsString.replace("{CC_EMAIL}", ccEmail);
97+
documentHTMLContentsString = documentHTMLContentsString.replace("{CC_NAME}", ccName);
98+
byte[] documentHTMLContentsBytes = documentHTMLContentsString.getBytes(StandardCharsets.UTF_8);
99+
String extension = FilenameUtils.getExtension(documentFileNameHTML);
100+
101+
Document documentHTML = EnvelopeHelpers.createDocument(
102+
documentHTMLContentsBytes,
80103
"Order acknowledgement",
104+
extension,
81105
"1");
82106

83107
Document documentDOCX = EnvelopeHelpers.createDocumentFromFile(

0 commit comments

Comments
 (0)