Repository navigation
Expand file tree
/
Copy pathTemplateCreateFormFieldsPerDocumentExample.java
More file actions
120 lines (104 loc) · 4.47 KB
/
Copy pathTemplateCreateFormFieldsPerDocumentExample.java
File metadata and controls
120 lines (104 loc) · 4.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
package com.dropbox.sign_sandbox;
import com.dropbox.sign.ApiException;
import com.dropbox.sign.Configuration;
import com.dropbox.sign.api.*;
import com.dropbox.sign.auth.*;
import com.dropbox.sign.JSON;
import com.dropbox.sign.model.*;
import java.io.File;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class TemplateCreateFormFieldsPerDocumentExample
{
public static void main(String[] args)
{
var config = Configuration.getDefaultApiClient();
((HttpBasicAuth) config.getAuthentication("api_key")).setUsername("YOUR_API_KEY");
// ((HttpBearerAuth) config.getAuthentication("oauth2")).setBearerToken("YOUR_ACCESS_TOKEN");
var fieldOptions = new SubFieldOptions();
fieldOptions.dateFormat(SubFieldOptions.DateFormatEnum.DD_MM_YYYY);
var signerRoles1 = new SubTemplateRole();
signerRoles1.name("Client");
signerRoles1.order(0);
var signerRoles2 = new SubTemplateRole();
signerRoles2.name("Witness");
signerRoles2.order(1);
var signerRoles = new ArrayList<SubTemplateRole>(List.of (
signerRoles1,
signerRoles2
));
var formFieldsPerDocument1 = new SubFormFieldsPerDocumentText();
formFieldsPerDocument1.documentIndex(0);
formFieldsPerDocument1.apiId("uniqueIdHere_1");
formFieldsPerDocument1.type("text");
formFieldsPerDocument1.required(true);
formFieldsPerDocument1.signer("1");
formFieldsPerDocument1.width(100);
formFieldsPerDocument1.height(16);
formFieldsPerDocument1.x(112);
formFieldsPerDocument1.y(328);
formFieldsPerDocument1.name("");
formFieldsPerDocument1.page(1);
formFieldsPerDocument1.placeholder("");
formFieldsPerDocument1.validationType(SubFormFieldsPerDocumentText.ValidationTypeEnum.NUMBERS_ONLY);
var formFieldsPerDocument2 = new SubFormFieldsPerDocumentSignature();
formFieldsPerDocument2.documentIndex(0);
formFieldsPerDocument2.apiId("uniqueIdHere_2");
formFieldsPerDocument2.type("signature");
formFieldsPerDocument2.required(true);
formFieldsPerDocument2.signer("0");
formFieldsPerDocument2.width(120);
formFieldsPerDocument2.height(30);
formFieldsPerDocument2.x(530);
formFieldsPerDocument2.y(415);
formFieldsPerDocument2.name("");
formFieldsPerDocument2.page(1);
var formFieldsPerDocument = new ArrayList<SubFormFieldsPerDocumentBase>(List.of (
formFieldsPerDocument1,
formFieldsPerDocument2
));
var mergeFields1 = new SubMergeField();
mergeFields1.name("Full Name");
mergeFields1.type(SubMergeField.TypeEnum.TEXT);
var mergeFields2 = new SubMergeField();
mergeFields2.name("Is Registered?");
mergeFields2.type(SubMergeField.TypeEnum.CHECKBOX);
var mergeFields = new ArrayList<SubMergeField>(List.of (
mergeFields1,
mergeFields2
));
var templateCreateRequest = new TemplateCreateRequest();
templateCreateRequest.clientId("37dee8d8440c66d54cfa05d92c160882");
templateCreateRequest.message("For your approval");
templateCreateRequest.subject("Please sign this document");
templateCreateRequest.testMode(true);
templateCreateRequest.title("Test Template");
templateCreateRequest.fileUrls(List.of (
"https://www.dropbox.com/s/ad9qnhbrjjn64tu/mutual-NDA-example.pdf?dl=1"
));
templateCreateRequest.ccRoles(List.of (
"Manager"
));
templateCreateRequest.fieldOptions(fieldOptions);
templateCreateRequest.signerRoles(signerRoles);
templateCreateRequest.formFieldsPerDocument(formFieldsPerDocument);
templateCreateRequest.mergeFields(mergeFields);
try
{
var response = new TemplateApi(config).templateCreate(
templateCreateRequest
);
System.out.println(response);
} catch (ApiException e) {
System.err.println("Exception when calling TemplateApi#templateCreate");
System.err.println("Status code: " + e.getCode());
System.err.println("Reason: " + e.getResponseBody());
System.err.println("Response headers: " + e.getResponseHeaders());
e.printStackTrace();
}
}
}