Skip to content

Commit 2c3d60d

Browse files
authored
Merge pull request #3 from signnow/v3.1.0
V3.1.0
2 parents 2d9f291 + b0eedd7 commit 2c3d60d

14 files changed

+681
-2
lines changed

.github/workflows/functional.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Functional tests
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout repository
14+
uses: actions/checkout@v3
15+
16+
- name: Raise mock server
17+
run: make mock-up
18+
19+
- name: Run functional tests
20+
run: make tests
21+
22+
- name: Stop mock server
23+
run: make mock-stop

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# signNow API Java SDK
2-
## v3.0.0
2+
## v3.1.0
33

44
[![Java Version](https://img.shields.io/badge/codebase-java--11-yellowgreen)](https://www.java.com/)
55

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import com.signnow.api.document.request.DocumentPostRequest;
2+
import com.signnow.api.document.response.DocumentPostResponse;
3+
import com.signnow.api.embeddededitor.request.DocumentEmbeddedEditorLinkPostRequest;
4+
import com.signnow.api.embeddededitor.response.DocumentEmbeddedEditorLinkPostResponse;
5+
import com.signnow.core.ApiClient;
6+
import com.signnow.core.exception.SignNowApiException;
7+
import com.signnow.core.factory.SdkFactory;
8+
import java.io.File;
9+
10+
public class DocumentUploadExample {
11+
public static void main(String[] args) {
12+
13+
// Set your actual input data here
14+
// Note: following values are dummy, just for example
15+
// ----------------------------------------------------
16+
// if it is not specified here, a new Bearer token will be created automatically
17+
String bearerToken = "";
18+
String pathToDocument = "/your/path/to/file.pdf";
19+
20+
try {
21+
ApiClient client = SdkFactory.createApiClientWithBearerToken(bearerToken);
22+
23+
DocumentPostRequest request = new DocumentPostRequest(new File(pathToDocument));
24+
DocumentPostResponse response = (DocumentPostResponse) client.send(request).getResponse();
25+
26+
// Create a link to the document editor
27+
DocumentEmbeddedEditorLinkPostRequest editorRequest =
28+
new DocumentEmbeddedEditorLinkPostRequest("https://example.com", "blank", 15);
29+
editorRequest.withDocumentId(response.getId());
30+
DocumentEmbeddedEditorLinkPostResponse editorResponse =
31+
(DocumentEmbeddedEditorLinkPostResponse) client.send(editorRequest).getResponse();
32+
33+
System.out.println("Link to embedded editor: " + editorResponse.getData().getUrl());
34+
} catch (SignNowApiException e) {
35+
System.out.println("ERROR: " + e.getMessage());
36+
}
37+
}
38+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import com.signnow.api.document.request.DocumentPostRequest;
2+
import com.signnow.api.document.response.DocumentPostResponse;
3+
import com.signnow.api.documentgroup.request.DocumentGroupPostRequest;
4+
import com.signnow.api.documentgroup.request.data.DocumentIdCollection;
5+
import com.signnow.api.documentgroup.response.DocumentGroupPostResponse;
6+
import com.signnow.api.embeddededitor.request.DocumentGroupEmbeddedEditorLinkPostRequest;
7+
import com.signnow.api.embeddededitor.response.DocumentGroupEmbeddedEditorLinkPostResponse;
8+
import com.signnow.core.ApiClient;
9+
import com.signnow.core.exception.SignNowApiException;
10+
import com.signnow.core.factory.SdkFactory;
11+
import java.io.File;
12+
13+
public class DocumentUploadExample {
14+
public static void main(String[] args) {
15+
16+
// Set your actual input data here
17+
// Note: following values are dummy, just for example
18+
// ----------------------------------------------------
19+
// if it is not specified here, a new Bearer token will be created automatically
20+
String bearerToken = "";
21+
String groupName = "Test Document Group";
22+
String pathToDocument = "/your/path/to/file.pdf";
23+
24+
try {
25+
ApiClient client = SdkFactory.createApiClientWithBearerToken(bearerToken);
26+
27+
// Create first document
28+
DocumentPostRequest request = new DocumentPostRequest(new File(pathToDocument));
29+
DocumentPostResponse response = (DocumentPostResponse) client.send(request).getResponse();
30+
String documentId1 = response.getId();
31+
32+
// Create second document
33+
DocumentPostRequest request2 = new DocumentPostRequest(new File(pathToDocument));
34+
DocumentPostResponse response2 = (DocumentPostResponse) client.send(request2).getResponse();
35+
String documentId2 = response2.getId();
36+
37+
// Create document group from both documents
38+
DocumentIdCollection documentIds = new DocumentIdCollection();
39+
documentIds.add(documentId1);
40+
documentIds.add(documentId2);
41+
DocumentGroupPostRequest groupRequest = new DocumentGroupPostRequest(documentIds, groupName);
42+
DocumentGroupPostResponse groupResponse =
43+
(DocumentGroupPostResponse) client.send(groupRequest).getResponse();
44+
String groupId = groupResponse.getId();
45+
46+
// Create a link to the document editor
47+
DocumentGroupEmbeddedEditorLinkPostRequest editorRequest =
48+
new DocumentGroupEmbeddedEditorLinkPostRequest("https://example.com", "blank", 15);
49+
editorRequest.withDocumentGroupId(groupId);
50+
DocumentGroupEmbeddedEditorLinkPostResponse editorResponse =
51+
(DocumentGroupEmbeddedEditorLinkPostResponse) client.send(editorRequest).getResponse();
52+
53+
System.out.println("Link to embedded editor: " + editorResponse.getData().getUrl());
54+
} catch (SignNowApiException e) {
55+
System.out.println("ERROR: " + e.getMessage());
56+
}
57+
}
58+
}

pom.xml

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

77
<groupId>com.signnow</groupId>
88
<artifactId>signnow-java-sdk</artifactId>
9-
<version>3.0.1</version>
9+
<version>3.1.0</version>
1010
<packaging>jar</packaging>
1111
<name>signnow-java-sdk</name>
1212
<description>SignNow official Java SDK</description>
Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
/*
2+
* This file is a part of signNow SDK API client.
3+
*
4+
* (с) Copyright © 2011-present airSlate Inc. (https://www.signnow.com)
5+
*
6+
* For more details on copyright, see LICENSE.md file
7+
*/
8+
9+
package com.signnow.api.embeddededitor.request;
10+
11+
import com.signnow.core.request.ApiEndpoint;
12+
import com.signnow.core.request.RequestInterface;
13+
import java.util.HashMap;
14+
import java.util.Map;
15+
import org.jetbrains.annotations.Contract;
16+
import org.jetbrains.annotations.NotNull;
17+
18+
/**
19+
* This class represents a request to create a document embedded editor link. It implements the
20+
* RequestInterface with an Object type.
21+
*/
22+
@ApiEndpoint(
23+
name = "createDocumentEmbeddedEditorLink",
24+
url = "/v2/documents/{document_id}/embedded-editor",
25+
method = "post",
26+
auth = "bearer",
27+
namespace = "embeddedEditor",
28+
entity = "documentEmbeddedEditorLink",
29+
type = "application/json")
30+
public final class DocumentEmbeddedEditorLinkPostRequest implements RequestInterface<Object> {
31+
32+
/** The redirect URI for the request. */
33+
private final String redirectUri;
34+
35+
/** The redirect target for the request. */
36+
private final String redirectTarget;
37+
38+
/** The link expiration time for the request. */
39+
private final int linkExpiration;
40+
41+
/** The URI parameters for the request. */
42+
private final HashMap<String, String> uriParams = new HashMap<>();
43+
44+
/**
45+
* Constructs a new DocumentEmbeddedEditorLinkPostRequest with the specified redirect URI,
46+
* redirect target, and link expiration.
47+
*
48+
* @param redirectUri link that opens after the user has completed editing the document.
49+
* @param redirectTarget determines on what browser's tab should be opened the redirectUri
50+
* @param linkExpiration the link expiration time in minutes
51+
*/
52+
public DocumentEmbeddedEditorLinkPostRequest(
53+
String redirectUri, String redirectTarget, int linkExpiration) {
54+
this.redirectUri = redirectUri;
55+
this.redirectTarget = redirectTarget;
56+
this.linkExpiration = linkExpiration;
57+
}
58+
59+
/**
60+
* Returns link that opens after the user has completed editing the document.
61+
*
62+
* @return the redirect URI for the request
63+
*/
64+
public String getRedirectUri() {
65+
return this.redirectUri;
66+
}
67+
68+
/**
69+
* Returns the redirect target for the request (on what browser's tab should be opened the
70+
* redirectUri).
71+
*
72+
* @return the redirect target for the request (on what browser's tab should be opened the
73+
* redirectUri)
74+
*/
75+
public String getRedirectTarget() {
76+
return this.redirectTarget;
77+
}
78+
79+
/**
80+
* Returns the link expiration time for the request.
81+
*
82+
* @return the link expiration time for the request
83+
*/
84+
public int getLinkExpiration() {
85+
return this.linkExpiration;
86+
}
87+
88+
/**
89+
* Adds the document ID to the URI parameters and returns the current instance.
90+
*
91+
* @param documentId the document ID to add
92+
* @return the current instance with the updated URI parameters
93+
*/
94+
public DocumentEmbeddedEditorLinkPostRequest withDocumentId(String documentId) {
95+
this.uriParams.put("document_id", documentId);
96+
return this;
97+
}
98+
99+
/**
100+
* Returns the URI parameters for the request.
101+
*
102+
* @return a HashMap containing the URI parameters as key-value pairs
103+
*/
104+
@NotNull
105+
@Contract(value = " -> new", pure = true)
106+
@Override
107+
public HashMap<String, String> uriParams() {
108+
return new HashMap<>(this.uriParams);
109+
}
110+
111+
/**
112+
* Returns a Map with the payload of the request.
113+
*
114+
* @return a Map with the payload of the request
115+
*/
116+
@NotNull
117+
public Map<String, Object> payload() {
118+
Map<String, Object> map = new HashMap<>();
119+
map.put("redirect_uri", this.getRedirectUri());
120+
map.put("redirect_target", this.getRedirectTarget());
121+
map.put("link_expiration", this.getLinkExpiration());
122+
return map;
123+
}
124+
}
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
/*
2+
* This file is a part of signNow SDK API client.
3+
*
4+
* (с) Copyright © 2011-present airSlate Inc. (https://www.signnow.com)
5+
*
6+
* For more details on copyright, see LICENSE.md file
7+
* that was distributed with this source code.
8+
*/
9+
10+
package com.signnow.api.embeddededitor.request;
11+
12+
import com.signnow.core.request.ApiEndpoint;
13+
import com.signnow.core.request.RequestInterface;
14+
import java.util.HashMap;
15+
import java.util.Map;
16+
import org.jetbrains.annotations.Contract;
17+
import org.jetbrains.annotations.NotNull;
18+
19+
/**
20+
* This class represents a request to create a link to embedded document group editor. It implements
21+
* the RequestInterface with Object as the type parameter.
22+
*/
23+
@ApiEndpoint(
24+
name = "createDocumentGroupEmbeddedEditorLink",
25+
url = "/v2/document-groups/{document_group_id}/embedded-editor",
26+
method = "post",
27+
auth = "bearer",
28+
namespace = "embeddedEditor",
29+
entity = "documentGroupEmbeddedEditorLink",
30+
type = "application/json")
31+
public final class DocumentGroupEmbeddedEditorLinkPostRequest implements RequestInterface<Object> {
32+
33+
/** Optional: link that opens after the user has completed editing the document group. */
34+
private final String redirectUri;
35+
36+
/**
37+
* Determines whether to open the redirect link in the new tab in the browser, or in the same tab
38+
* after the signing session. Possible values: blank - opens the link in the new tab, self - opens
39+
* the link in the same tab, default value.
40+
*/
41+
private final String redirectTarget;
42+
43+
/**
44+
* Link expiration time in minutes. By default, 15 minutes. Can be set max to 43200 minutes by a
45+
* user with Admin level of access.
46+
*/
47+
private final int linkExpiration;
48+
49+
/** A HashMap to store the URI parameters for the request. */
50+
private final HashMap<String, String> uriParams = new HashMap<>();
51+
52+
/**
53+
* Constructor for DocumentEmbeddedEditorLinkRequest.
54+
*
55+
* @param redirectUri Link that opens after the user has completed editing the document group.
56+
* @param redirectTarget Determines on what browser's tab should be opened the redirectUri.
57+
* @param linkExpiration Link expiration time in minutes.
58+
*/
59+
public DocumentGroupEmbeddedEditorLinkPostRequest(
60+
String redirectUri, String redirectTarget, int linkExpiration) {
61+
this.redirectUri = redirectUri;
62+
this.redirectTarget = redirectTarget;
63+
this.linkExpiration = linkExpiration;
64+
}
65+
66+
/**
67+
* Link that opens after the user has completed editing the document group.
68+
*
69+
* @return String Link that opens after the user has completed editing the document group.
70+
*/
71+
public String getRedirectUri() {
72+
return this.redirectUri;
73+
}
74+
75+
/**
76+
* Determines on what browser's tab should be opened the redirectUri.
77+
*
78+
* @return String Determines on what browser's tab should be opened the redirectUri.
79+
*/
80+
public String getRedirectTarget() {
81+
return this.redirectTarget;
82+
}
83+
84+
/**
85+
* Link expiration time in minutes.
86+
*
87+
* @return int Link expiration time in minutes.
88+
*/
89+
public int getLinkExpiration() {
90+
return this.linkExpiration;
91+
}
92+
93+
/**
94+
* Method to add a document group ID to the URI parameters.
95+
*
96+
* @param documentGroupId The ID of the document group to be edited as embedded one.
97+
* @return The current DocumentGroupEmbeddedEditorLinkPostRequest instance.
98+
*/
99+
public DocumentGroupEmbeddedEditorLinkPostRequest withDocumentGroupId(String documentGroupId) {
100+
this.uriParams.put("document_group_id", documentGroupId);
101+
return this;
102+
}
103+
104+
/**
105+
* This method is used to get the URI parameters for the request.
106+
*
107+
* @return a new HashMap containing URI parameters
108+
*/
109+
@NotNull
110+
@Contract(value = " -> new", pure = true)
111+
@Override
112+
public HashMap<String, String> uriParams() {
113+
return new HashMap<>(this.uriParams);
114+
}
115+
116+
/**
117+
* Returns a Map containing the payload for the request.
118+
*
119+
* @return a Map containing the payload for the request
120+
*/
121+
@NotNull
122+
public Map<String, Object> payload() {
123+
Map<String, Object> map = new HashMap<>();
124+
map.put("redirect_uri", this.getRedirectUri());
125+
map.put("redirect_target", this.getRedirectTarget());
126+
map.put("link_expiration", this.getLinkExpiration());
127+
return map;
128+
}
129+
}

0 commit comments

Comments
 (0)