-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathEmbeddedEditorDocumentGroupExample.java
58 lines (50 loc) · 2.77 KB
/
EmbeddedEditorDocumentGroupExample.java
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
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.embeddededitor.request.DocumentGroupEmbeddedEditorLinkPostRequest;
import com.signnow.api.embeddededitor.response.DocumentGroupEmbeddedEditorLinkPostResponse;
import com.signnow.core.ApiClient;
import com.signnow.core.exception.SignNowApiException;
import com.signnow.core.factory.SdkFactory;
import java.io.File;
public class DocumentUploadExample {
public static void main(String[] args) {
// Set your actual input data here
// Note: following values are dummy, just for example
// ----------------------------------------------------
// if it is not specified here, a new Bearer token will be created automatically
String bearerToken = "";
String groupName = "Test Document Group";
String pathToDocument = "/your/path/to/file.pdf";
try {
ApiClient client = SdkFactory.createApiClientWithBearerToken(bearerToken);
// Create first document
DocumentPostRequest request = new DocumentPostRequest(new File(pathToDocument));
DocumentPostResponse response = (DocumentPostResponse) client.send(request).getResponse();
String documentId1 = response.getId();
// Create second document
DocumentPostRequest request2 = new DocumentPostRequest(new File(pathToDocument));
DocumentPostResponse response2 = (DocumentPostResponse) client.send(request2).getResponse();
String documentId2 = response2.getId();
// Create document group from both documents
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 a link to the document editor
DocumentGroupEmbeddedEditorLinkPostRequest editorRequest =
new DocumentGroupEmbeddedEditorLinkPostRequest("https://example.com", "blank", 15);
editorRequest.withDocumentGroupId(groupId);
DocumentGroupEmbeddedEditorLinkPostResponse editorResponse =
(DocumentGroupEmbeddedEditorLinkPostResponse) client.send(editorRequest).getResponse();
System.out.println("Link to embedded editor: " + editorResponse.getData().getUrl());
} catch (SignNowApiException e) {
System.out.println("ERROR: " + e.getMessage());
}
}
}