Skip to content

Commit 2d9f291

Browse files
authored
Merge pull request #2 from signnow/v3.0.1
Release v3.0.1
2 parents 9972757 + 17ffb02 commit 2d9f291

File tree

514 files changed

+23024
-591
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

514 files changed

+23024
-591
lines changed

.env.example

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
## signNow API SDK configuration
33
##
44

5-
## Replace these dummy values with your actual credentials except API_HOST
6-
API_HOST=https://api.signnow.com
7-
API_BASIC_TOKEN=c2lnbk5vdyBBUEkgc2FtcGxlIEFwcCB2MS4wCg==
8-
API_USERNAME=[email protected]
9-
API_PASSWORD=coolest_pazzw0rd
5+
## Replace these dummy values with your actual credentials except SIGNNOW_API_HOST
6+
SIGNNOW_API_HOST=https://api.signnow.com
7+
SIGNNOW_API_BASIC_TOKEN=c2lnbk5vdyBBUEkgc2FtcGxlIEFwcCB2MS4wCg==
8+
SIGNNOW_API_USERNAME=[email protected]
9+
SIGNNOW_API_PASSWORD=coolest_pazzw0rd

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#### 2025-01-20 v3.0.1
2+
- feature: Added javadoc blocks
3+
- bug: Prefill document fields endpoint fails
4+
- example: Added examples/DocumentPrefillTextFieldExample.java
5+
- feature: [Config] Renamed env variables: adding SIGNNOW prefixes
6+
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
import com.signnow.api.document.request.DocumentPostRequest;
2+
import com.signnow.api.document.response.DocumentPostResponse;
3+
import com.signnow.api.documentfield.request.DocumentPrefillPutRequest;
4+
import com.signnow.api.documentfield.response.DocumentPrefillPutResponse;
5+
import com.signnow.core.ApiClient;
6+
import com.signnow.core.exception.SignNowApiException;
7+
import com.signnow.core.factory.SdkFactory;
8+
import com.signnow.api.documentfield.request.data.*;
9+
import com.signnow.core.response.Reply;
10+
public class DocumentPrefillTextFieldExample {
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 signerRole = "Product Manager";
19+
String pathToDocument = "/your/path/to/file.pdf";
20+
21+
try {
22+
ApiClient client = SdkFactory.createApiClientWithBearerToken(bearerToken);
23+
24+
// Upload a new document
25+
// or you can use an existing document
26+
DocumentPostRequest request = new DocumentPostRequest(new File(pathToDocument));
27+
DocumentPostResponse response = (DocumentPostResponse) client.send(request).getResponse();
28+
String documentId = response.getId();
29+
30+
// Add fields with roles to the new document
31+
var documentFields = new com.signnow.api.document.request.data.FieldCollection();
32+
documentFields.add(
33+
new com.signnow.api.document.request.data.Field(
34+
50,
35+
18,
36+
200,
37+
20,
38+
"text",
39+
0,
40+
true,
41+
signerRole,
42+
"field_1",
43+
"Reason to sign"));
44+
DocumentPutRequest putFieldsRequest = new DocumentPutRequest(documentFields);
45+
putFieldsRequest.withDocumentId(documentId);
46+
client.send(putFieldsRequest);
47+
48+
// Prefill an existing field by their name "field_1"
49+
var prefillFields = new FieldCollection();
50+
prefillFields.add(new Field("field_1", "custom prefilled text here"));
51+
DocumentPrefillPutRequest prefillPutRequest = new DocumentPrefillPutRequest(prefillFields);
52+
prefillPutRequest.withDocumentId(documentId);
53+
54+
Reply<DocumentPrefillPutResponse> responsePrefillFields = client.send(prefillPutRequest);
55+
System.out.println(responsePrefillFields.getStatusCode());
56+
} catch (SignNowApiException e) {
57+
System.out.println("ERROR: " + e.getMessage());
58+
}
59+
}
60+
}

pom.xml

Lines changed: 73 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,11 @@
55
<modelVersion>4.0.0</modelVersion>
66

77
<groupId>com.signnow</groupId>
8-
<artifactId>java-sdk</artifactId>
9-
<version>3.0.0</version>
8+
<artifactId>signnow-java-sdk</artifactId>
9+
<version>3.0.1</version>
1010
<packaging>jar</packaging>
11-
<name>SignNow Java SDK</name>
12-
<description>The Official SignNow PHP SDK library for interacting with SignNow REST API.
13-
Sign documents, request e-signatures, and build role-based workflows with multiple signers using this client.
14-
</description>
11+
<name>signnow-java-sdk</name>
12+
<description>SignNow official Java SDK</description>
1513
<url>https://github.com/signnow/SNJavaSDK</url>
1614

1715
<licenses>
@@ -22,12 +20,6 @@
2220
</license>
2321
</licenses>
2422

25-
<scm>
26-
<url>https://github.com/signnow/SNJavaSDK</url>
27-
<connection>scm:git:github.com/signnow/SNJavaSDK.git</connection>
28-
<developerConnection>scm:git:ssh://github.com/signnow/SNJavaSDK.git</developerConnection>
29-
</scm>
30-
3123
<developers>
3224
<developer>
3325
<id>Jisoft</id>
@@ -36,6 +28,12 @@
3628
</developer>
3729
</developers>
3830

31+
<scm>
32+
<url>https://github.com/signnow/SNJavaSDK</url>
33+
<connection>scm:git:github.com/signnow/SNJavaSDK.git</connection>
34+
<developerConnection>scm:git:ssh://github.com/signnow/SNJavaSDK.git</developerConnection>
35+
</scm>
36+
3937
<properties>
4038
<maven.compiler.source>11</maven.compiler.source>
4139
<maven.compiler.target>11</maven.compiler.target>
@@ -53,7 +51,6 @@
5351
<artifactId>okhttp</artifactId>
5452
<version>4.12.0</version>
5553
</dependency>
56-
5754
<dependency>
5855
<groupId>org.junit.jupiter</groupId>
5956
<artifactId>junit-jupiter-api</artifactId>
@@ -81,7 +78,70 @@
8178
<artifactId>maven-surefire-plugin</artifactId>
8279
<version>3.0.0-M5</version>
8380
</plugin>
81+
<plugin>
82+
<groupId>org.apache.maven.plugins</groupId>
83+
<artifactId>maven-source-plugin</artifactId>
84+
<version>3.2.1</version>
85+
<executions>
86+
<execution>
87+
<id>attach-sources</id>
88+
<phase>package</phase>
89+
<goals>
90+
<goal>jar</goal>
91+
</goals>
92+
</execution>
93+
</executions>
94+
</plugin>
95+
<plugin>
96+
<groupId>org.apache.maven.plugins</groupId>
97+
<artifactId>maven-javadoc-plugin</artifactId>
98+
<version>3.4.0</version>
99+
<executions>
100+
<execution>
101+
<id>attach-javadocs</id>
102+
<phase>package</phase>
103+
<goals>
104+
<goal>jar</goal>
105+
</goals>
106+
</execution>
107+
</executions>
108+
</plugin>
109+
<plugin>
110+
<groupId>org.apache.maven.plugins</groupId>
111+
<artifactId>maven-gpg-plugin</artifactId>
112+
<version>3.0.1</version>
113+
<executions>
114+
<execution>
115+
<id>sign-artifacts</id>
116+
<phase>verify</phase>
117+
<goals>
118+
<goal>sign</goal>
119+
</goals>
120+
</execution>
121+
</executions>
122+
</plugin>
123+
<plugin>
124+
<groupId>org.sonatype.plugins</groupId>
125+
<artifactId>nexus-staging-maven-plugin</artifactId>
126+
<version>1.6.13</version>
127+
<extensions>true</extensions>
128+
<configuration>
129+
<serverId>ossrh</serverId>
130+
<nexusUrl>https://s01.oss.sonatype.org/</nexusUrl>
131+
<autoReleaseAfterClose>true</autoReleaseAfterClose>
132+
</configuration>
133+
</plugin>
84134
</plugins>
85135
</build>
86136

137+
<distributionManagement>
138+
<repository>
139+
<id>ossrh</id>
140+
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/</url>
141+
</repository>
142+
<snapshotRepository>
143+
<id>ossrh</id>
144+
<url>https://s01.oss.sonatype.org/content/repositories/snapshots/</url>
145+
</snapshotRepository>
146+
</distributionManagement>
87147
</project>

src/main/java/com/signnow/Sdk.java

Lines changed: 49 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
import com.signnow.core.provider.ApiServiceProvider;
1818
import com.signnow.core.token.BearerToken;
1919

20+
/**
21+
* Main class for the signNow SDK.
22+
*/
2023
public class Sdk {
2124

2225
private static final String API_VERSION = "2024-08-30";
@@ -25,13 +28,23 @@ public class Sdk {
2528
private static final String EMPTY_CODE = "";
2629
private static final String GRANT_TYPE_BY_PASSWORD = "password";
2730

28-
/** signNow SDK Service Provider * */
31+
/**
32+
* signNow SDK Service Provider
33+
*/
2934
private final ApiServiceProvider apiServiceProvider;
3035

36+
/**
37+
* Default constructor that initializes the ApiServiceProvider with the default configuration.
38+
*/
3139
public Sdk() {
3240
this.apiServiceProvider = new ApiServiceProvider(DEFAULT_CONFIG);
3341
}
3442

43+
/**
44+
* Constructor that initializes the ApiServiceProvider with the provided configuration path.
45+
*
46+
* @param configPath the path to the configuration file
47+
*/
3548
public Sdk(String configPath) {
3649
if (configPath == null || configPath.isEmpty()) {
3750
configPath = DEFAULT_CONFIG;
@@ -40,18 +53,36 @@ public Sdk(String configPath) {
4053
this.apiServiceProvider = new ApiServiceProvider(configPath);
4154
}
4255

56+
/**
57+
* Builds the SDK by registering the services.
58+
*
59+
* @return the built SDK
60+
* @throws SignNowApiException if an error occurs during the registration of services
61+
*/
4362
public Sdk build() throws SignNowApiException {
4463
this.apiServiceProvider.register();
4564
return this;
4665
}
4766

67+
/**
68+
* Retrieves the ApiClient from the services.
69+
*
70+
* @return the ApiClient
71+
* @throws SignNowApiException if an error occurs during the retrieval of the ApiClient
72+
*/
4873
public ApiClient getApiClient() throws SignNowApiException {
4974
if (this.apiServiceProvider.services().isEmpty()) {
5075
this.build();
5176
}
5277
return (ApiClient) this.apiServiceProvider.services().get("client");
5378
}
5479

80+
/**
81+
* Authenticates the SDK by sending a TokenPostRequest and setting the BearerToken.
82+
*
83+
* @return the authenticated SDK
84+
* @throws SignNowApiException if an error occurs during the authentication
85+
*/
5586
public Sdk authenticate() throws SignNowApiException {
5687
ConfigRepository config = (ConfigRepository) this.apiServiceProvider.services().get("config");
5788
ApiClient client = (ApiClient) this.apiServiceProvider.services().get("client");
@@ -70,17 +101,34 @@ public Sdk authenticate() throws SignNowApiException {
70101
return this;
71102
}
72103

104+
/**
105+
* Sets the BearerToken for the ApiClient.
106+
*
107+
* @param bearerToken the BearerToken to be set
108+
* @return the SDK with the set BearerToken
109+
*/
73110
public Sdk withBearerToken(BearerToken bearerToken) {
74111
ApiClient client = (ApiClient) this.apiServiceProvider.services().get("client");
75112
client.setBearerToken(bearerToken);
76113
this.apiServiceProvider.services().set("client", client);
77114
return this;
78115
}
79116

117+
/**
118+
* Retrieves the actual BearerToken of the ApiClient.
119+
*
120+
* @return the actual BearerToken
121+
* @throws SignNowApiException if an error occurs during the retrieval of the BearerToken
122+
*/
80123
public BearerToken getActualBearerToken() throws SignNowApiException {
81124
return this.getApiClient().getBearerToken();
82125
}
83126

127+
/**
128+
* Retrieves the version of the API.
129+
*
130+
* @return the version of the API
131+
*/
84132
public String version() {
85133
return API_VERSION;
86134
}

0 commit comments

Comments
 (0)