-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathEmbeddedSendingDocumentGroupExample.java
More file actions
64 lines (55 loc) · 2.98 KB
/
EmbeddedSendingDocumentGroupExample.java
File metadata and controls
64 lines (55 loc) · 2.98 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
import java.io.File;
import com.signnow.api.document.request.DocumentPostRequest;
import com.signnow.api.document.response.DocumentPostResponse;
import com.signnow.api.documentgroup.request.DocumentGroupPostRequest;
import com.signnow.api.documentgroup.request.data.DocumentIdCollection;
import com.signnow.api.documentgroup.response.DocumentGroupPostResponse;
import com.signnow.api.embeddedsending.request.DocumentGroupEmbeddedSendingLinkPostRequest;
import com.signnow.api.embeddedsending.response.DocumentGroupEmbeddedSendingLinkPostResponse;
import com.signnow.core.ApiClient;
import com.signnow.core.exception.SignNowApiException;
import com.signnow.core.factory.SdkFactory;
public class EmbeddedSendingDocumentGroupExample {
public static void main(String[] args) {
/**
* Important:
* - The following variables are dummy, for example purposes only. Please provide actual data.
* - If you do not specify a Bearer token, it will be generated automatically.
*/
String bearerToken = "";
String groupName = "Test Document Group";
String pathToDocument = "/your/path/to/file.pdf";
try {
ApiClient client = SdkFactory.createApiClientWithBearerToken(bearerToken);
/** Upload documents to create a document group, specify the paths to the files. */
DocumentPostRequest request = new DocumentPostRequest(new File(pathToDocument));
DocumentPostResponse response = (DocumentPostResponse) client.send(request).getResponse();
String documentId1 = response.getId();
DocumentPostRequest request2 = new DocumentPostRequest(new File(pathToDocument));
DocumentPostResponse response2 = (DocumentPostResponse) client.send(request2).getResponse();
String documentId2 = response2.getId();
/**
* Create a document group by specifying its name
* and the IDs of the documents it will consist of.
*/
DocumentIdCollection documentIds = new DocumentIdCollection();
documentIds.add(documentId1);
documentIds.add(documentId2);
DocumentGroupPostRequest groupRequest = new DocumentGroupPostRequest(documentIds, groupName);
DocumentGroupPostResponse groupResponse =
(DocumentGroupPostResponse) client.send(groupRequest).getResponse();
String groupId = groupResponse.getId();
/** Create an embedded sending link for the created document group. */
DocumentGroupEmbeddedSendingLinkPostRequest embeddedSendingRequest =
new DocumentGroupEmbeddedSendingLinkPostRequest("https://example.com", 15, "self", "manage");
embeddedSendingRequest.withDocumentGroupId(groupId);
DocumentGroupEmbeddedSendingLinkPostResponse embeddedSendingResponse =
(DocumentGroupEmbeddedSendingLinkPostResponse)
client.send(embeddedSendingRequest).getResponse();
System.out.println(
"Link for embedded sending: " + embeddedSendingResponse.getData().getUrl());
} catch (SignNowApiException e) {
System.out.println("ERROR: " + e.getMessage());
}
}
}