Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions .github/workflows/functional.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Functional tests

on:
pull_request:
branches:
- master

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Raise mock server
run: make mock-up

- name: Run functional tests
run: make tests

- name: Stop mock server
run: make mock-stop
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# signNow API Java SDK
## v3.0.0
## v3.1.0

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

Expand Down
38 changes: 38 additions & 0 deletions examples/EmbeddedEditorDocumentExample.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import com.signnow.api.document.request.DocumentPostRequest;
import com.signnow.api.document.response.DocumentPostResponse;
import com.signnow.api.embeddededitor.request.DocumentEmbeddedEditorLinkPostRequest;
import com.signnow.api.embeddededitor.response.DocumentEmbeddedEditorLinkPostResponse;
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 pathToDocument = "/your/path/to/file.pdf";

try {
ApiClient client = SdkFactory.createApiClientWithBearerToken(bearerToken);

DocumentPostRequest request = new DocumentPostRequest(new File(pathToDocument));
DocumentPostResponse response = (DocumentPostResponse) client.send(request).getResponse();

// Create a link to the document editor
DocumentEmbeddedEditorLinkPostRequest editorRequest =
new DocumentEmbeddedEditorLinkPostRequest("https://example.com", "blank", 15);
editorRequest.withDocumentId(response.getId());
DocumentEmbeddedEditorLinkPostResponse editorResponse =
(DocumentEmbeddedEditorLinkPostResponse) client.send(editorRequest).getResponse();

System.out.println("Link to embedded editor: " + editorResponse.getData().getUrl());
} catch (SignNowApiException e) {
System.out.println("ERROR: " + e.getMessage());
}
}
}
58 changes: 58 additions & 0 deletions examples/EmbeddedEditorDocumentGroupExample.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,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());
}
}
}
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.signnow</groupId>
<artifactId>signnow-java-sdk</artifactId>
<version>3.0.1</version>
<version>3.1.0</version>
<packaging>jar</packaging>
<name>signnow-java-sdk</name>
<description>SignNow official Java SDK</description>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
/*
* This file is a part of signNow SDK API client.
*
* (с) Copyright © 2011-present airSlate Inc. (https://www.signnow.com)
*
* For more details on copyright, see LICENSE.md file
*/

package com.signnow.api.embeddededitor.request;

import com.signnow.core.request.ApiEndpoint;
import com.signnow.core.request.RequestInterface;
import java.util.HashMap;
import java.util.Map;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;

/**
* This class represents a request to create a document embedded editor link. It implements the
* RequestInterface with an Object type.
*/
@ApiEndpoint(
name = "createDocumentEmbeddedEditorLink",
url = "/v2/documents/{document_id}/embedded-editor",
method = "post",
auth = "bearer",
namespace = "embeddedEditor",
entity = "documentEmbeddedEditorLink",
type = "application/json")
public final class DocumentEmbeddedEditorLinkPostRequest implements RequestInterface<Object> {

/** The redirect URI for the request. */
private final String redirectUri;

/** The redirect target for the request. */
private final String redirectTarget;

/** The link expiration time for the request. */
private final int linkExpiration;

/** The URI parameters for the request. */
private final HashMap<String, String> uriParams = new HashMap<>();

/**
* Constructs a new DocumentEmbeddedEditorLinkPostRequest with the specified redirect URI,
* redirect target, and link expiration.
*
* @param redirectUri link that opens after the user has completed editing the document.
* @param redirectTarget determines on what browser's tab should be opened the redirectUri
* @param linkExpiration the link expiration time in minutes
*/
public DocumentEmbeddedEditorLinkPostRequest(
String redirectUri, String redirectTarget, int linkExpiration) {
this.redirectUri = redirectUri;
this.redirectTarget = redirectTarget;
this.linkExpiration = linkExpiration;
}

/**
* Returns link that opens after the user has completed editing the document.
*
* @return the redirect URI for the request
*/
public String getRedirectUri() {
return this.redirectUri;
}

/**
* Returns the redirect target for the request (on what browser's tab should be opened the
* redirectUri).
*
* @return the redirect target for the request (on what browser's tab should be opened the
* redirectUri)
*/
public String getRedirectTarget() {
return this.redirectTarget;
}

/**
* Returns the link expiration time for the request.
*
* @return the link expiration time for the request
*/
public int getLinkExpiration() {
return this.linkExpiration;
}

/**
* Adds the document ID to the URI parameters and returns the current instance.
*
* @param documentId the document ID to add
* @return the current instance with the updated URI parameters
*/
public DocumentEmbeddedEditorLinkPostRequest withDocumentId(String documentId) {
this.uriParams.put("document_id", documentId);
return this;
}

/**
* Returns the URI parameters for the request.
*
* @return a HashMap containing the URI parameters as key-value pairs
*/
@NotNull
@Contract(value = " -> new", pure = true)
@Override
public HashMap<String, String> uriParams() {
return new HashMap<>(this.uriParams);
}

/**
* Returns a Map with the payload of the request.
*
* @return a Map with the payload of the request
*/
@NotNull
public Map<String, Object> payload() {
Map<String, Object> map = new HashMap<>();
map.put("redirect_uri", this.getRedirectUri());
map.put("redirect_target", this.getRedirectTarget());
map.put("link_expiration", this.getLinkExpiration());
return map;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
/*
* This file is a part of signNow SDK API client.
*
* (с) Copyright © 2011-present airSlate Inc. (https://www.signnow.com)
*
* For more details on copyright, see LICENSE.md file
* that was distributed with this source code.
*/

package com.signnow.api.embeddededitor.request;

import com.signnow.core.request.ApiEndpoint;
import com.signnow.core.request.RequestInterface;
import java.util.HashMap;
import java.util.Map;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;

/**
* This class represents a request to create a link to embedded document group editor. It implements
* the RequestInterface with Object as the type parameter.
*/
@ApiEndpoint(
name = "createDocumentGroupEmbeddedEditorLink",
url = "/v2/document-groups/{document_group_id}/embedded-editor",
method = "post",
auth = "bearer",
namespace = "embeddedEditor",
entity = "documentGroupEmbeddedEditorLink",
type = "application/json")
public final class DocumentGroupEmbeddedEditorLinkPostRequest implements RequestInterface<Object> {

/** Optional: link that opens after the user has completed editing the document group. */
private final String redirectUri;

/**
* Determines whether to open the redirect link in the new tab in the browser, or in the same tab
* after the signing session. Possible values: blank - opens the link in the new tab, self - opens
* the link in the same tab, default value.
*/
private final String redirectTarget;

/**
* Link expiration time in minutes. By default, 15 minutes. Can be set max to 43200 minutes by a
* user with Admin level of access.
*/
private final int linkExpiration;

/** A HashMap to store the URI parameters for the request. */
private final HashMap<String, String> uriParams = new HashMap<>();

/**
* Constructor for DocumentEmbeddedEditorLinkRequest.
*
* @param redirectUri Link that opens after the user has completed editing the document group.
* @param redirectTarget Determines on what browser's tab should be opened the redirectUri.
* @param linkExpiration Link expiration time in minutes.
*/
public DocumentGroupEmbeddedEditorLinkPostRequest(
String redirectUri, String redirectTarget, int linkExpiration) {
this.redirectUri = redirectUri;
this.redirectTarget = redirectTarget;
this.linkExpiration = linkExpiration;
}

/**
* Link that opens after the user has completed editing the document group.
*
* @return String Link that opens after the user has completed editing the document group.
*/
public String getRedirectUri() {
return this.redirectUri;
}

/**
* Determines on what browser's tab should be opened the redirectUri.
*
* @return String Determines on what browser's tab should be opened the redirectUri.
*/
public String getRedirectTarget() {
return this.redirectTarget;
}

/**
* Link expiration time in minutes.
*
* @return int Link expiration time in minutes.
*/
public int getLinkExpiration() {
return this.linkExpiration;
}

/**
* Method to add a document group ID to the URI parameters.
*
* @param documentGroupId The ID of the document group to be edited as embedded one.
* @return The current DocumentGroupEmbeddedEditorLinkPostRequest instance.
*/
public DocumentGroupEmbeddedEditorLinkPostRequest withDocumentGroupId(String documentGroupId) {
this.uriParams.put("document_group_id", documentGroupId);
return this;
}

/**
* This method is used to get the URI parameters for the request.
*
* @return a new HashMap containing URI parameters
*/
@NotNull
@Contract(value = " -> new", pure = true)
@Override
public HashMap<String, String> uriParams() {
return new HashMap<>(this.uriParams);
}

/**
* Returns a Map containing the payload for the request.
*
* @return a Map containing the payload for the request
*/
@NotNull
public Map<String, Object> payload() {
Map<String, Object> map = new HashMap<>();
map.put("redirect_uri", this.getRedirectUri());
map.put("redirect_target", this.getRedirectTarget());
map.put("link_expiration", this.getLinkExpiration());
return map;
}
}
Loading