From 0e7e07de4e238e0844cf84765091b8590774d9eb Mon Sep 17 00:00:00 2001 From: Ihor Cherkashyn Date: Mon, 3 Feb 2025 14:55:53 +0100 Subject: [PATCH 1/3] Release v3.1.0 --- README.md | 2 +- examples/EmbeddedEditorDocumentExample.java | 38 ++++++ .../EmbeddedEditorDocumentGroupExample.java | 58 ++++++++ ...DocumentEmbeddedEditorLinkPostRequest.java | 124 +++++++++++++++++ ...entGroupEmbeddedEditorLinkPostRequest.java | 129 ++++++++++++++++++ ...ocumentEmbeddedEditorLinkPostResponse.java | 43 ++++++ ...ntGroupEmbeddedEditorLinkPostResponse.java | 43 ++++++ .../embeddededitor/response/data/DataUrl.java | 69 ++++++++++ .../DocumentEmbeddedEditorLinkTest.java | 62 +++++++++ .../DocumentGroupEmbeddedEditorLinkTest.java | 64 +++++++++ ...te_document_embedded_editor_link_post.json | 13 ++ ...ument_group_embedded_editor_link_post.json | 13 ++ 12 files changed, 657 insertions(+), 1 deletion(-) create mode 100644 examples/EmbeddedEditorDocumentExample.java create mode 100644 examples/EmbeddedEditorDocumentGroupExample.java create mode 100644 src/main/java/com/signnow/api/embeddededitor/request/DocumentEmbeddedEditorLinkPostRequest.java create mode 100644 src/main/java/com/signnow/api/embeddededitor/request/DocumentGroupEmbeddedEditorLinkPostRequest.java create mode 100644 src/main/java/com/signnow/api/embeddededitor/response/DocumentEmbeddedEditorLinkPostResponse.java create mode 100644 src/main/java/com/signnow/api/embeddededitor/response/DocumentGroupEmbeddedEditorLinkPostResponse.java create mode 100644 src/main/java/com/signnow/api/embeddededitor/response/data/DataUrl.java create mode 100644 src/test/java/com/signnow/api/embeddededitor/DocumentEmbeddedEditorLinkTest.java create mode 100644 src/test/java/com/signnow/api/embeddededitor/DocumentGroupEmbeddedEditorLinkTest.java create mode 100644 src/test/resources/wiremock/mappings/create_document_embedded_editor_link_post.json create mode 100644 src/test/resources/wiremock/mappings/create_document_group_embedded_editor_link_post.json diff --git a/README.md b/README.md index 26a69df..7ddaa7b 100644 --- a/README.md +++ b/README.md @@ -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/) diff --git a/examples/EmbeddedEditorDocumentExample.java b/examples/EmbeddedEditorDocumentExample.java new file mode 100644 index 0000000..22ac431 --- /dev/null +++ b/examples/EmbeddedEditorDocumentExample.java @@ -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()); + } + } +} diff --git a/examples/EmbeddedEditorDocumentGroupExample.java b/examples/EmbeddedEditorDocumentGroupExample.java new file mode 100644 index 0000000..675bed0 --- /dev/null +++ b/examples/EmbeddedEditorDocumentGroupExample.java @@ -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()); + } + } +} diff --git a/src/main/java/com/signnow/api/embeddededitor/request/DocumentEmbeddedEditorLinkPostRequest.java b/src/main/java/com/signnow/api/embeddededitor/request/DocumentEmbeddedEditorLinkPostRequest.java new file mode 100644 index 0000000..56b7800 --- /dev/null +++ b/src/main/java/com/signnow/api/embeddededitor/request/DocumentEmbeddedEditorLinkPostRequest.java @@ -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 { + + /** 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 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 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 payload() { + Map map = new HashMap<>(); + map.put("redirect_uri", this.getRedirectUri()); + map.put("redirect_target", this.getRedirectTarget()); + map.put("link_expiration", this.getLinkExpiration()); + return map; + } +} diff --git a/src/main/java/com/signnow/api/embeddededitor/request/DocumentGroupEmbeddedEditorLinkPostRequest.java b/src/main/java/com/signnow/api/embeddededitor/request/DocumentGroupEmbeddedEditorLinkPostRequest.java new file mode 100644 index 0000000..d680621 --- /dev/null +++ b/src/main/java/com/signnow/api/embeddededitor/request/DocumentGroupEmbeddedEditorLinkPostRequest.java @@ -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 { + + /** 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 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 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 payload() { + Map map = new HashMap<>(); + map.put("redirect_uri", this.getRedirectUri()); + map.put("redirect_target", this.getRedirectTarget()); + map.put("link_expiration", this.getLinkExpiration()); + return map; + } +} diff --git a/src/main/java/com/signnow/api/embeddededitor/response/DocumentEmbeddedEditorLinkPostResponse.java b/src/main/java/com/signnow/api/embeddededitor/response/DocumentEmbeddedEditorLinkPostResponse.java new file mode 100644 index 0000000..65911e9 --- /dev/null +++ b/src/main/java/com/signnow/api/embeddededitor/response/DocumentEmbeddedEditorLinkPostResponse.java @@ -0,0 +1,43 @@ +/* + * 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.response; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.signnow.api.embeddededitor.response.data.DataUrl; + +/** This class represents the response containing the embedded editor link for a document. */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class DocumentEmbeddedEditorLinkPostResponse { + + /** The link for document editor inside 'data' object. */ + @JsonProperty("data") + private final DataUrl data; + + /** + * Constructs a new DocumentEmbeddedEditorLinkPostResponse with the specified data URL. + * + * @param data the link for document editor inside 'data' object. + */ + @JsonCreator + public DocumentEmbeddedEditorLinkPostResponse(@JsonProperty("data") DataUrl data) { + this.data = data; + } + + /** + * Returns the data URL associated with the document embedded editor link. + * + * @return the data URL associated with the document embedded editor link. + */ + public DataUrl getData() { + return this.data; + } +} diff --git a/src/main/java/com/signnow/api/embeddededitor/response/DocumentGroupEmbeddedEditorLinkPostResponse.java b/src/main/java/com/signnow/api/embeddededitor/response/DocumentGroupEmbeddedEditorLinkPostResponse.java new file mode 100644 index 0000000..c33e1dd --- /dev/null +++ b/src/main/java/com/signnow/api/embeddededitor/response/DocumentGroupEmbeddedEditorLinkPostResponse.java @@ -0,0 +1,43 @@ +/* + * 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.response; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.signnow.api.embeddededitor.response.data.DataUrl; + +/** This class represents the response containing the embedded editor link for a document group. */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class DocumentGroupEmbeddedEditorLinkPostResponse { + + /** The link for document editor inside 'data' object. */ + @JsonProperty("data") + private final DataUrl data; + + /** + * Constructs a new DocumentGroupEmbeddedEditorLinkPostResponse with the specified data URL. + * + * @param data the link for document editor inside 'data' object. + */ + @JsonCreator + public DocumentGroupEmbeddedEditorLinkPostResponse(@JsonProperty("data") DataUrl data) { + this.data = data; + } + + /** + * Returns the data URL associated with the document embedded editor link. + * + * @return the data URL associated with the document embedded editor link. + */ + public DataUrl getData() { + return this.data; + } +} diff --git a/src/main/java/com/signnow/api/embeddededitor/response/data/DataUrl.java b/src/main/java/com/signnow/api/embeddededitor/response/data/DataUrl.java new file mode 100644 index 0000000..40b4e33 --- /dev/null +++ b/src/main/java/com/signnow/api/embeddededitor/response/data/DataUrl.java @@ -0,0 +1,69 @@ +/* + * 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.response.data; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.signnow.core.data.ApiData; +import java.util.LinkedHashMap; +import java.util.Map; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; + +/** Represents a DataUrl object with a URL property. */ +public final class DataUrl extends ApiData { + + @JsonProperty("url") + private final String url; + + /** + * Constructs a DataUrl instance with the specified URL. + * + * @param url the URL string + */ + @JsonCreator + public DataUrl(@JsonProperty("url") String url) { + this.url = url; + } + + /** + * Returns the URL string. + * + * @return the URL string + */ + public String getUrl() { + return this.url; + } + + /** + * Converts the DataUrl object to a map representation. + * + * @return a map containing the URL + */ + @NotNull + @Override + public Map toMap() { + Map map = new LinkedHashMap<>(); + map.put("url", this.getUrl()); + return map; + } + + /** + * Creates a DataUrl instance from a map representation. + * + * @param data the map containing the URL + * @return a new DataUrl instance + */ + @NotNull + @Contract("_ -> new") + public static DataUrl fromMap(@NotNull Map data) { + return new DataUrl((String) data.get("url")); + } +} diff --git a/src/test/java/com/signnow/api/embeddededitor/DocumentEmbeddedEditorLinkTest.java b/src/test/java/com/signnow/api/embeddededitor/DocumentEmbeddedEditorLinkTest.java new file mode 100644 index 0000000..3bd0116 --- /dev/null +++ b/src/test/java/com/signnow/api/embeddededitor/DocumentEmbeddedEditorLinkTest.java @@ -0,0 +1,62 @@ +/* + * 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; + +import static org.junit.jupiter.api.Assertions.*; + +import com.signnow.BaseTest; +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.mock.expectation.Expectation; +import com.signnow.mock.faker.SignNowFaker; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class DocumentEmbeddedEditorLinkTest extends BaseTest { + + private ApiClient apiClient; + + private SignNowFaker faker; + + private Expectation expectation; + + @BeforeEach + public void setUp() { + try { + apiClient = this.client(); + } catch (SignNowApiException e) { + fail(e.getMessage()); + } + faker = this.faker(); + } + + @Test + public void testPostDocumentEmbeddedEditorLink() { + expectation = this.expectation("create_document_embedded_editor_link", "post"); + + DocumentEmbeddedEditorLinkPostRequest request = + new DocumentEmbeddedEditorLinkPostRequest( + faker.redirectUri(), faker.redirectTarget(), faker.linkExpiration()); + + request.withDocumentId(faker.documentId()); + + assertDoesNotThrow( + () -> { + DocumentEmbeddedEditorLinkPostResponse response = + (DocumentEmbeddedEditorLinkPostResponse) apiClient.send(request).getResponse(); + + assertNotNull(response, "DocumentEmbeddedEditorLinkPostResponse should not be null."); + + this.assertSame(expectation.get("data"), response.getData()); + }, + "Sending DocumentEmbeddedEditorLinkPostResponse should not throw any exception."); + } +} diff --git a/src/test/java/com/signnow/api/embeddededitor/DocumentGroupEmbeddedEditorLinkTest.java b/src/test/java/com/signnow/api/embeddededitor/DocumentGroupEmbeddedEditorLinkTest.java new file mode 100644 index 0000000..c3b4606 --- /dev/null +++ b/src/test/java/com/signnow/api/embeddededitor/DocumentGroupEmbeddedEditorLinkTest.java @@ -0,0 +1,64 @@ +/* + * 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; + +import static org.junit.jupiter.api.Assertions.*; + +import com.signnow.BaseTest; +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.mock.expectation.Expectation; +import com.signnow.mock.faker.SignNowFaker; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class DocumentGroupEmbeddedEditorLinkTest extends BaseTest { + + private ApiClient apiClient; + + private SignNowFaker faker; + + private Expectation expectation; + + @BeforeEach + public void setUp() { + try { + apiClient = this.client(); + } catch (SignNowApiException e) { + fail(e.getMessage()); + } + faker = this.faker(); + } + + @Test + public void testPostDocumentGroupEmbedEditorLink() { + expectation = this.expectation("create_document_group_embedded_editor_link", "post"); + + DocumentGroupEmbeddedEditorLinkPostRequest request = + new DocumentGroupEmbeddedEditorLinkPostRequest( + faker.redirectUri(), faker.redirectTarget(), faker.linkExpiration()); + + request.withDocumentGroupId(faker.documentGroupId()); + + assertDoesNotThrow( + () -> { + DocumentGroupEmbeddedEditorLinkPostResponse response = + (DocumentGroupEmbeddedEditorLinkPostResponse) apiClient.send(request).getResponse(); + + assertNotNull( + response, "DocumentGroupEmbeddedEditorLinkPostResponse should not be null."); + + this.assertSame(expectation.get("data"), response.getData()); + }, + "Sending DocumentGroupEmbedEditorLinkPostRequest should not throw any exception."); + } +} diff --git a/src/test/resources/wiremock/mappings/create_document_embedded_editor_link_post.json b/src/test/resources/wiremock/mappings/create_document_embedded_editor_link_post.json new file mode 100644 index 0000000..7d9f23d --- /dev/null +++ b/src/test/resources/wiremock/mappings/create_document_embedded_editor_link_post.json @@ -0,0 +1,13 @@ +{ + "request": { + "method": "POST", + "urlPathPattern": "/v2/documents/[0-9a-z]{40}/embedded-editor" + }, + "response": { + "status": 200, + "body": "{\"data\":{\"url\":\"http:\\/\\/www.kerluke.org\\/rem-consequatur-eum-alias-id\"}}", + "headers": { + "Content-Type": "application/json" + } + } +} diff --git a/src/test/resources/wiremock/mappings/create_document_group_embedded_editor_link_post.json b/src/test/resources/wiremock/mappings/create_document_group_embedded_editor_link_post.json new file mode 100644 index 0000000..ae9c2ac --- /dev/null +++ b/src/test/resources/wiremock/mappings/create_document_group_embedded_editor_link_post.json @@ -0,0 +1,13 @@ +{ + "request": { + "method": "POST", + "urlPathPattern": "/v2/document-groups/[0-9a-z]{40}/embedded-editor" + }, + "response": { + "status": 200, + "body": "{\"data\":{\"url\":\"http:\\/\\/www.little.org\\/ut-porro-tenetur-nihil-aut-quisquam-voluptatibus-veniam\"}}", + "headers": { + "Content-Type": "application/json" + } + } +} From e9f25f68ad7749926c8b0b54097721b20138fd81 Mon Sep 17 00:00:00 2001 From: Ihor Cherkashyn Date: Mon, 3 Feb 2025 15:59:45 +0100 Subject: [PATCH 2/3] Updated pom.xml with new version --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 27703f7..a0060d4 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.signnow signnow-java-sdk - 3.0.1 + 3.1.0 jar signnow-java-sdk SignNow official Java SDK From b0eedd79d355de54af81c8d5899a478a4f982cdf Mon Sep 17 00:00:00 2001 From: Ihor Cherkashyn Date: Tue, 4 Feb 2025 16:27:12 +0100 Subject: [PATCH 3/3] Added GitHub Actions (tests) --- .github/workflows/functional.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 .github/workflows/functional.yml diff --git a/.github/workflows/functional.yml b/.github/workflows/functional.yml new file mode 100644 index 0000000..3644447 --- /dev/null +++ b/.github/workflows/functional.yml @@ -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