Skip to content

Commit c701535

Browse files
committed
Release v3
1 parent 426e18c commit c701535

File tree

663 files changed

+43482
-0
lines changed

Some content is hidden

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

663 files changed

+43482
-0
lines changed

.env.example

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
##
2+
## signNow API SDK configuration
3+
##
4+
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

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/vendor
2+
/.idea
3+
/.fleet
4+
/.vscode
5+
/target
6+
.env
7+
.env.backup
8+
.env.production
9+
.env.development

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# The MIT License
2+
3+
Copyright (c) 2003-2019 airSlate Inc. [LICENSE](https://github.com/signnow/SignNowPHPSDK/blob/master/LICENSE.md)
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

Makefile

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
.PHONY: mock-up mock-stop mock-restart test tests
2+
3+
.SILENT: ; # no need for @
4+
.ONESHELL: ; # recipes execute in same shell
5+
.EXPORT_ALL_VARIABLES: ; # send all vars to shell
6+
7+
SHELL := /bin/bash
8+
APP_DIR ?= ${PWD}
9+
10+
# Raise WireMock docker container to mock signNow API
11+
mock-up:
12+
. ${APP_DIR}/src/test/resources/wiremock-config.env && \
13+
docker run -d --rm \
14+
-p $$WIREMOCK_PORT:8080 \
15+
-v $$WIREMOCK_ROOT_DIR:/home/wiremock/mappings \
16+
--name wiremock \
17+
$$WIREMOCK_IMAGE
18+
19+
# Stop WireMock docker container
20+
mock-stop:
21+
docker stop wiremock
22+
23+
# Stop/Start WireMock docker container
24+
mock-restart: mock-stop mock-up
25+
docker ps
26+
27+
# Run one test by specified argument
28+
# Example:
29+
# make test T=SdkTest
30+
# make test T=TokenTest#testPostToken
31+
test:
32+
mvn -Dtest=${T} test
33+
34+
# Run all the tests
35+
tests:
36+
mvn test

README.md

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
# signNow API Java SDK
2+
## v3.0.0
3+
4+
[![Java Version](https://img.shields.io/badge/codebase-java--11-yellowgreen)](https://www.java.com/)
5+
6+
### About SignNow
7+
SignNow is a powerful web-based e-signature solution that streamlines the signing process and overall document flow for businesses of any size. SignNow offers SaaS as well as public and private cloud deployment options using the same underlying API. With SignNow you can easily sign, share and manage documents in compliance with international data laws and industry-specific regulations. SignNow enables you to collect signatures from partners, employees and customers from any device within minutes. For more details, please, visit [SignNow API Reference](https://docs.signnow.com/docs/signnow/welcome).
8+
9+
### Requirements
10+
- Java 11
11+
- Maven
12+
13+
### Installation
14+
Get SDK code from GitHub:
15+
```bash
16+
git clone https://github.com/signnow/SNJavaSDK.git
17+
```
18+
Install dependencies
19+
```bash
20+
# We must run the API mock server first, as it is a dependency for the tests
21+
make mock-up
22+
23+
# Install all the dependencies and run the tests
24+
mvn install
25+
```
26+
27+
### Configuration
28+
Copy `.env.example` to `.env` and fill your credentials in the required values.
29+
```bash
30+
cp .env.example .env
31+
```
32+
33+
### Credentials
34+
To run examples or use the SDK in your project, you will need API keys. Follow these steps to obtain them:
35+
36+
1. Register for an account on SignNow [here](https://www.signnow.com/api)
37+
2. Create a new application.
38+
3. Obtain the Basic Authentication API token for your application.
39+
4. Add your email, password, and the Basic token to the .env file.
40+
41+
Now, you are ready to use the SDK.
42+
43+
### Run tests
44+
```bash
45+
## Run mock server locally (must be started first, before running tests)
46+
make mock-up
47+
48+
## Run all the tests
49+
make tests
50+
51+
## Run a specified test
52+
make test T=SdkTest
53+
make test T=TokenTest#testPostToken
54+
55+
## Stop mock server
56+
make mock-stop
57+
```
58+
Mock server will be available at `http://127.0.0.1:8086`.
59+
To change the host or port, edit [wiremock-config.env](./src/test/resources/wiremock-config.env) for starting WireMock,
60+
and [.env.test](./src/test/resources/.env.test) for running tests.
61+
62+
### Usage
63+
To start using the SDK, you need to create a new instance of the SDK API client. This can be done manually or through the SdkFactory.
64+
Example of manually creating a new token:
65+
```java
66+
import com.signnow.api.user.request.UserGetRequest;
67+
import com.signnow.api.user.response.UserGetResponse;
68+
import com.signnow.Sdk;
69+
import com.signnow.core.ApiClient;
70+
import com.signnow.core.exception.SignNowApiException;
71+
import com.signnow.core.token.BearerToken;
72+
73+
public class AuthenticateExample {
74+
public static void main(String[] args) {
75+
76+
try {
77+
// Create a new instance of the API client containing a freshly created bearer token
78+
Sdk sdk = new Sdk();
79+
ApiClient client = sdk
80+
.build()
81+
.authenticate()
82+
.getApiClient();
83+
84+
// you can save the token for further usage if you want
85+
BearerToken token = client.getBearerToken();
86+
87+
// or continue using client
88+
UserGetRequest request = new UserGetRequest();
89+
UserGetResponse response = (UserGetResponse) client.send(request);
90+
91+
System.out.println("User ID: " + response.getId());
92+
System.out.println("User name: " + response.getFirstName());
93+
} catch (SignNowApiException e) {
94+
System.out.println("ERROR: " + e.getMessage());
95+
}
96+
}
97+
}
98+
```
99+
100+
Example of using an already created token:
101+
```java
102+
import com.signnow.api.user.request.UserGetRequest;
103+
import com.signnow.api.user.response.UserGetResponse;
104+
import com.signnow.Sdk;
105+
import com.signnow.core.ApiClient;
106+
import com.signnow.core.exception.SignNowApiException;
107+
import com.signnow.core.token.BearerToken;
108+
109+
public class AuthenticateExample {
110+
public static void main(String[] args) {
111+
112+
try {
113+
// Create a new instance without authentication (no tokens)
114+
Sdk sdk = new Sdk();
115+
ApiClient client = sdk
116+
.build()
117+
.getApiClient();
118+
119+
// Use previously saved token
120+
client.setBearerToken(token);
121+
122+
// then continue using authenticated client with token
123+
UserGetRequest request = new UserGetRequest();
124+
UserGetResponse response = (UserGetResponse) client.send(request);
125+
126+
System.out.println("User ID: " + response.getId());
127+
System.out.println("User name: " + response.getFirstName());
128+
} catch (SignNowApiException e) {
129+
System.out.println("ERROR: " + e.getMessage());
130+
}
131+
}
132+
}
133+
```
134+
135+
Example of creating a new token through SDK:
136+
```java
137+
import com.signnow.api.document.request.DocumentGetRequest;
138+
import com.signnow.api.document.response.DocumentGetResponse;
139+
import com.signnow.core.ApiClient;
140+
import com.signnow.core.exception.SignNowApiException;
141+
import com.signnow.core.factory.SdkFactory;
142+
143+
public class DocumentGetExample {
144+
public static void main(String[] args) {
145+
146+
// Provide your actual document ID here
147+
String documentId = "05fbed799231d85cf3471121ecd6a4221f9c5610";
148+
149+
try {
150+
// The required authorization token will be created automatically by SdkFactory
151+
// using your credentials from .env file
152+
ApiClient client = SdkFactory.createApiClient();
153+
154+
// You are now ready to send API requests using the SDK
155+
DocumentGetRequest request = new DocumentGetRequest();
156+
request.withDocumentId(documentId);
157+
DocumentGetResponse response = (DocumentGetResponse) client.send(request);
158+
159+
System.out.println("Document ID: " + response.getId());
160+
System.out.println("Document Name: " + response.getDocumentName());
161+
System.out.println("Document Owner: " + response.getUserId());
162+
} catch (SignNowApiException e) {
163+
System.out.println("ERROR: " + e.getMessage());
164+
}
165+
}
166+
}
167+
```
168+
169+
### Examples
170+
You can find more examples of API usage in the [examples](./examples) directory.

examples/AuthCheckExample.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import com.signnow.api.auth.request.TokenGetRequest;
2+
import com.signnow.api.auth.response.TokenGetResponse;
3+
import com.signnow.core.ApiClient;
4+
import com.signnow.core.exception.SignNowApiException;
5+
import com.signnow.core.factory.SdkFactory;
6+
7+
public class AuthCheckExample {
8+
public static void main(String[] args) {
9+
10+
// Set your actual input data here
11+
// Note: following values are dummy, just for example
12+
//----------------------------------------------------
13+
// if it is empty or null, a new Bearer token will be created automatically
14+
String bearerToken = "";
15+
16+
try {
17+
ApiClient client = SdkFactory.createApiClientWithBearerToken(bearerToken);
18+
TokenGetResponse response = (TokenGetResponse) client.send(new TokenGetRequest()).getResponse();
19+
System.out.println("Token: " + response.getAccessToken());
20+
System.out.println("Type: " + response.getTokenType());
21+
System.out.println("Scope: " + response.getScope());
22+
System.out.println("Expires at: " + response.getExpiresIn());
23+
} catch (SignNowApiException e) {
24+
System.err.println("Exception when signNow API call TokenGetRequest");
25+
System.out.println("ERROR: " + e.getMessage());
26+
}
27+
}
28+
}

examples/BulkInviteExample.java

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import com.signnow.api.template.request.BulkInvitePostRequest;
2+
import com.signnow.api.template.response.BulkInvitePostResponse;
3+
import com.signnow.core.ApiClient;
4+
import com.signnow.core.exception.SignNowApiException;
5+
import com.signnow.core.factory.SdkFactory;
6+
import java.io.File;
7+
8+
public class BulkInviteExample {
9+
public static void main(String[] args) {
10+
11+
// Set your actual input data here
12+
// Note: following values are dummy, just for example
13+
// Details: https://docs.signnow.com/docs/signnow/template/operations/create-a-template-bulkinvite
14+
//----------------------------------------------------
15+
// if it is empty or null, a new Bearer token will be created automatically
16+
String bearerToken = "";
17+
// CSV file containing information for each invite in the bulk
18+
// Example: Signer 1|[email protected],Contract_0_Jack
19+
// "Signer 1" - signing role, must present in the template
20+
// "[email protected]" - signer email related for the signing role
21+
// "Contract_0_Jack" - contains 3 parts: "Contract" - document name, 0 - line/invite number,
22+
// "Jack" - signer name
23+
String csvFilePath = "/your/path/to/data.csv";
24+
// The template from which a new document will be cloned for each invite in the bulk.
25+
// The template must have at least one field assigned the same signing role that exists in your csv file
26+
// (i.e. "Signer 1")
27+
// Look at TemplateExample.java to find out how to create a template.
28+
// Look at FieldInviteExample.java to find out how to add a field to document or template.
29+
String templateId = "e2e913db4ba9815a31c8a28a196b7df96fe1cc46";
30+
// The folder to store documents cloned from the template.
31+
String folderId = "3073f8da73b9a5328f95ccc55a912e3f46da2d94";
32+
String documentNameClonedFromTemplate = "test_bulk_invite";
33+
String bulkInviteSubject = "email subject for all signers from CSV";
34+
String bulkInviteMessage = "email message for all signers from CSV";
35+
36+
try {
37+
ApiClient client = SdkFactory.createApiClientWithBearerToken(bearerToken);
38+
39+
BulkInvitePostRequest request =
40+
new BulkInvitePostRequest(
41+
new File(csvFilePath),
42+
folderId,
43+
0,
44+
documentNameClonedFromTemplate,
45+
bulkInviteSubject,
46+
bulkInviteMessage);
47+
request.withDocumentId(templateId);
48+
BulkInvitePostResponse response = (BulkInvitePostResponse) client.send(request).getResponse();
49+
50+
System.out.println("Status: " + response.getStatus());
51+
} catch (SignNowApiException e) {
52+
System.out.println("ERROR: " + e.getMessage());
53+
}
54+
}
55+
}

examples/DocumentGetExample.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import com.signnow.api.document.request.DocumentGetRequest;
2+
import com.signnow.api.document.response.DocumentGetResponse;
3+
import com.signnow.core.ApiClient;
4+
import com.signnow.core.exception.SignNowApiException;
5+
import com.signnow.core.factory.SdkFactory;
6+
7+
public class DocumentGetExample {
8+
public static void main(String[] args) {
9+
10+
// Set your actual input data here
11+
// Note: following values are dummy, just for example
12+
//----------------------------------------------------
13+
// if it is not specified here, a new Bearer token will be created automatically
14+
String bearerToken = "";
15+
String documentId = "05fbed799231d85cf3471121ecd6a4221f9c5610";
16+
17+
try {
18+
ApiClient client = SdkFactory.createApiClientWithBearerToken(bearerToken);
19+
DocumentGetRequest request = new DocumentGetRequest();
20+
request.withDocumentId(documentId);
21+
DocumentGetResponse response = (DocumentGetResponse) client.send(request).getResponse();
22+
System.out.println("Document ID: " + response.getId());
23+
System.out.println("Document Name: " + response.getDocumentName());
24+
System.out.println("Document Owner: " + response.getUserId());
25+
} catch (SignNowApiException e) {
26+
System.out.println("ERROR: " + e.getMessage());
27+
}
28+
}
29+
}

0 commit comments

Comments
 (0)