diff --git a/.env.example b/.env.example index e9ae4d0..f048b51 100644 --- a/.env.example +++ b/.env.example @@ -7,3 +7,9 @@ SIGNNOW_API_HOST=https://api.signnow.com SIGNNOW_API_BASIC_TOKEN=c2lnbk5vdyBBUEkgc2FtcGxlIEFwcCB2MS4wCg== SIGNNOW_API_USERNAME=user@signnow.com SIGNNOW_API_PASSWORD=coolest_pazzw0rd + +# Absolute or relative (starts with .) path to the directory +# where the downloaded files will be stored (make sure you have write permissions to this directory) +# +# Default: ./src/main/resources/downloads +SIGNNOW_DOWNLOADS_DIR=./src/main/resources/downloads diff --git a/README.md b/README.md index 7ddaa7b..3cebad4 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # signNow API Java SDK -## v3.1.0 +## v3.2.0 [![Java Version](https://img.shields.io/badge/codebase-java--11-yellowgreen)](https://www.java.com/) @@ -166,5 +166,19 @@ public class DocumentGetExample { } ``` +#### Proxy endpoints usage + +If you need to call an API endpoint that is not yet available in the SDK, you can still access it using the proxy mechanism. + +This allows you to send custom requests without waiting for an official SDK update. + +To do this, create a class that extends `CustomProxyRequest` and annotate it with `@ApiEndpoint`, setting: `namespace = "proxy"`. + +The `name` and `entity` values within the annotation can be arbitrary and do not affect functionality. + +Example of creating a request to proxy any unimplemented endpoint that returns JSON data: [ProxyJsonTest](./src/test/java/com/signnow/api/proxy/ProxyJsonTest.java). + +Example of creating a request to proxy any unimplemented endpoint that returns a file: [ProxyFileTest](./src/test/java/com/signnow/api/proxy/ProxyFileTest.java). + ### Examples You can find more examples of API usage in the [examples](./examples) directory. diff --git a/examples/DownloadDocumentExample.java b/examples/DownloadDocumentExample.java new file mode 100644 index 0000000..ba2a1d4 --- /dev/null +++ b/examples/DownloadDocumentExample.java @@ -0,0 +1,29 @@ +import com.signnow.api.document.request.DocumentDownloadGetRequest; +import com.signnow.api.document.response.DocumentDownloadGetResponse; +import com.signnow.core.ApiClient; +import com.signnow.core.exception.SignNowApiException; +import com.signnow.core.factory.SdkFactory; + +public class DownloadDocumentExample { + 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 documentId = "05fbed799231d85cf3471121ecd6a4221f9c5610"; + + try { + ApiClient client = SdkFactory.createApiClientWithBearerToken(bearerToken); + DocumentDownloadGetRequest request = new DocumentDownloadGetRequest(); + request.withDocumentId(documentId) + .withType("collapsed") + .withHistory("no"); + DocumentDownloadGetResponse response = (DocumentDownloadGetResponse) client.send(request).getResponse(); + File downloadedFile = response.getFile(); + System.out.println(downloadedFile.getAbsolutePath()); + } catch (SignNowApiException e) { + System.out.println("ERROR: " + e.getMessage()); + } + } +} diff --git a/examples/DownloadDocumentGroupExample.java b/examples/DownloadDocumentGroupExample.java new file mode 100644 index 0000000..01fa8fa --- /dev/null +++ b/examples/DownloadDocumentGroupExample.java @@ -0,0 +1,37 @@ +import com.signnow.api.documentgroup.request.DownloadDocumentGroupPostRequest; +import com.signnow.api.documentgroup.request.data.DocumentOrderCollection; +import com.signnow.api.documentgroup.response.DownloadDocumentGroupPostResponse; +import com.signnow.core.ApiClient; +import com.signnow.core.exception.SignNowApiException; +import com.signnow.core.factory.SdkFactory; + +public class DownloadDocumentGroupExample { + 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 documentGroupId = "e1b4c8a2f930d7e6a5b1f4c3d8a09e2b7c5d1f0a"; + String documentId1 = "05fbed799231d85cf3471121ecd6a4221f9c5610"; + String documentId2 = "9a3b1e4f0c2d7a8e5f6b9c1d3e0a4b7c8f2d6a9e"; + + try { + ApiClient client = SdkFactory.createApiClientWithBearerToken(bearerToken); + DocumentOrderCollection documentOrder = new DocumentOrderCollection(); + // this order prescribes how downloaded documents will be located in merged file + // the collection is allowed to be empty + documentOrder.add(documentId1); + documentOrder.add(documentId2); + DownloadDocumentGroupPostRequest request = new DownloadDocumentGroupPostRequest("zip", + "no", + documentOrder); + request.withDocumentGroupId(documentGroupId); + DownloadDocumentGroupPostResponse response = (DownloadDocumentGroupPostResponse) client.send(request).getResponse(); + File downloadedFile = response.getFile(); + System.out.println(downloadedFile.getAbsolutePath()); + } catch (SignNowApiException e) { + System.out.println("ERROR: " + e.getMessage()); + } + } +} diff --git a/examples/EmbeddedEditorDocumentExample.java b/examples/EmbeddedEditorDocumentExample.java index 22ac431..4281036 100644 --- a/examples/EmbeddedEditorDocumentExample.java +++ b/examples/EmbeddedEditorDocumentExample.java @@ -1,3 +1,5 @@ +import java.io.File; + import com.signnow.api.document.request.DocumentPostRequest; import com.signnow.api.document.response.DocumentPostResponse; import com.signnow.api.embeddededitor.request.DocumentEmbeddedEditorLinkPostRequest; @@ -5,11 +7,9 @@ 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 class EmbeddedEditorDocumentExample { public static void main(String[] args) { - // Set your actual input data here // Note: following values are dummy, just for example // ---------------------------------------------------- diff --git a/examples/EmbeddedEditorDocumentGroupExample.java b/examples/EmbeddedEditorDocumentGroupExample.java index 675bed0..2bf62bb 100644 --- a/examples/EmbeddedEditorDocumentGroupExample.java +++ b/examples/EmbeddedEditorDocumentGroupExample.java @@ -1,3 +1,5 @@ +import java.io.File; + import com.signnow.api.document.request.DocumentPostRequest; import com.signnow.api.document.response.DocumentPostResponse; import com.signnow.api.documentgroup.request.DocumentGroupPostRequest; @@ -8,9 +10,8 @@ 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 class EmbeddedEditorDocumentGroupExample { public static void main(String[] args) { // Set your actual input data here diff --git a/examples/EmbeddedSendingDocumentExample.java b/examples/EmbeddedSendingDocumentExample.java new file mode 100644 index 0000000..d08bf30 --- /dev/null +++ b/examples/EmbeddedSendingDocumentExample.java @@ -0,0 +1,44 @@ +import java.io.File; + +import com.signnow.api.document.request.DocumentPostRequest; +import com.signnow.api.document.response.DocumentPostResponse; +import com.signnow.api.embeddedsending.request.DocumentEmbeddedSendingLinkPostRequest; +import com.signnow.api.embeddedsending.response.DocumentEmbeddedSendingLinkPostResponse; +import com.signnow.core.ApiClient; +import com.signnow.core.exception.SignNowApiException; +import com.signnow.core.factory.SdkFactory; + +public class EmbeddedSendingDocumentExample { + public static void main(String[] args) { + + /** + * Important: + * - The following variables are dummy, for example purposes only. Please provide actual data. + * - If you do not specify a Bearer token, it will be generated automatically. + */ + String bearerToken = ""; + String pathToDocument = "/your/path/to/document.pdf"; + + try { + ApiClient client = SdkFactory.createApiClientWithBearerToken(bearerToken); + + DocumentPostRequest request = new DocumentPostRequest(new File(pathToDocument)); + DocumentPostResponse response = (DocumentPostResponse) client.send(request).getResponse(); + + /** Create an embedded sending link for the uploaded document. */ + DocumentEmbeddedSendingLinkPostRequest embeddedSendingRequest = + new DocumentEmbeddedSendingLinkPostRequest( + "document", "https://example.com", 15, "blank"); + embeddedSendingRequest.withDocumentId(response.getId()); + + DocumentEmbeddedSendingLinkPostResponse embeddedSendingResponse = + (DocumentEmbeddedSendingLinkPostResponse) + client.send(embeddedSendingRequest).getResponse(); + + System.out.println( + "Link for embedded sending: " + embeddedSendingResponse.getData().getUrl()); + } catch (SignNowApiException e) { + System.out.println("ERROR: " + e.getMessage()); + } + } +} diff --git a/examples/EmbeddedSendingDocumentGroupExample.java b/examples/EmbeddedSendingDocumentGroupExample.java new file mode 100644 index 0000000..ab20a90 --- /dev/null +++ b/examples/EmbeddedSendingDocumentGroupExample.java @@ -0,0 +1,64 @@ +import java.io.File; + +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.embeddedsending.request.DocumentGroupEmbeddedSendingLinkPostRequest; +import com.signnow.api.embeddedsending.response.DocumentGroupEmbeddedSendingLinkPostResponse; +import com.signnow.core.ApiClient; +import com.signnow.core.exception.SignNowApiException; +import com.signnow.core.factory.SdkFactory; + +public class EmbeddedSendingDocumentGroupExample { + public static void main(String[] args) { + + /** + * Important: + * - The following variables are dummy, for example purposes only. Please provide actual data. + * - If you do not specify a Bearer token, it will be generated automatically. + */ + String bearerToken = ""; + String groupName = "Test Document Group"; + String pathToDocument = "/your/path/to/file.pdf"; + + try { + ApiClient client = SdkFactory.createApiClientWithBearerToken(bearerToken); + + /** Upload documents to create a document group, specify the paths to the files. */ + DocumentPostRequest request = new DocumentPostRequest(new File(pathToDocument)); + DocumentPostResponse response = (DocumentPostResponse) client.send(request).getResponse(); + String documentId1 = response.getId(); + + DocumentPostRequest request2 = new DocumentPostRequest(new File(pathToDocument)); + DocumentPostResponse response2 = (DocumentPostResponse) client.send(request2).getResponse(); + String documentId2 = response2.getId(); + + /** + * Create a document group by specifying its name + * and the IDs of the documents it will consist of. + */ + 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 an embedded sending link for the created document group. */ + DocumentGroupEmbeddedSendingLinkPostRequest embeddedSendingRequest = + new DocumentGroupEmbeddedSendingLinkPostRequest("https://example.com", 15, "blank"); + embeddedSendingRequest.withDocumentGroupId(groupId); + DocumentGroupEmbeddedSendingLinkPostResponse embeddedSendingResponse = + (DocumentGroupEmbeddedSendingLinkPostResponse) + client.send(embeddedSendingRequest).getResponse(); + + System.out.println( + "Link for embedded sending: " + embeddedSendingResponse.getData().getUrl()); + } catch (SignNowApiException e) { + System.out.println("ERROR: " + e.getMessage()); + } + } +} diff --git a/src/main/java/com/signnow/api/document/request/DocumentDownloadGetRequest.java b/src/main/java/com/signnow/api/document/request/DocumentDownloadGetRequest.java index a136fd8..d75021b 100644 --- a/src/main/java/com/signnow/api/document/request/DocumentDownloadGetRequest.java +++ b/src/main/java/com/signnow/api/document/request/DocumentDownloadGetRequest.java @@ -17,8 +17,8 @@ import org.jetbrains.annotations.NotNull; /** - * This class represents a request to download a document. - * It implements the RequestInterface with a String type parameter. + * This class represents a request to download a document. It implements the RequestInterface with a + * String type parameter. */ @ApiEndpoint( name = "downloadDocument", @@ -30,10 +30,31 @@ type = "application/pdf") public final class DocumentDownloadGetRequest implements RequestInterface { + /** A map to hold URI parameters for the request. */ + private final HashMap uriParams = new HashMap<>(); + + /** A map to hold query parameters for the request. */ + private final HashMap queryParams = new HashMap<>(); + /** - * A map to hold URI parameters for the request. + * Specifies file type to download: collapsed|zip|email + * + * @return this DocumentDownloadGetRequest instance */ - private final HashMap uriParams = new HashMap<>(); + public DocumentDownloadGetRequest withType(String type) { + this.queryParams.put("type", type); + return this; + } + + /** + * The value "yes" allows to include a table containing the document's history into a document. + * + * @return this DocumentDownloadGetRequest instance + */ + public DocumentDownloadGetRequest withHistory(String withHistory) { + this.queryParams.put("with_history", withHistory); + return this; + } /** * Adds a document ID to the URI parameters. @@ -58,6 +79,16 @@ public HashMap uriParams() { return new HashMap<>(this.uriParams); } + /** + * Returns a map as the query parameters for this request. + * + * @return an empty map + */ + @NotNull + public Map queryParams() { + return new HashMap<>(this.queryParams); + } + /** * Returns an empty map as the payload for this request. * @@ -68,4 +99,4 @@ public HashMap uriParams() { public Map payload() { return new HashMap<>(); } -} \ No newline at end of file +} diff --git a/src/main/java/com/signnow/api/document/response/DocumentDownloadGetResponse.java b/src/main/java/com/signnow/api/document/response/DocumentDownloadGetResponse.java index 6f380d5..4481534 100644 --- a/src/main/java/com/signnow/api/document/response/DocumentDownloadGetResponse.java +++ b/src/main/java/com/signnow/api/document/response/DocumentDownloadGetResponse.java @@ -10,12 +10,34 @@ package com.signnow.api.document.response; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import java.io.File; /** * This class represents the response received after a document download request. - * It is annotated with JsonIgnoreProperties to ignore any unknown properties when deserializing JSON. */ -@JsonIgnoreProperties(ignoreUnknown = true) public class DocumentDownloadGetResponse { - // No public properties, constructors, or methods to comment on. -} \ No newline at end of file + + /** + * The file downloaded as part of the response. This file is created from the response content and + * stored locally. + */ + private final File file; + + /** + * Creates a new DocumentDownloadGetResponse with the specified file. + * + * @param file The downloaded file + */ + public DocumentDownloadGetResponse(File file) { + this.file = file; + } + + /** + * Gets the downloaded file. + * + * @return The File object representing the downloaded file + */ + public File getFile() { + return file; + } +} diff --git a/src/main/java/com/signnow/api/document/response/data/EnumerationOption.java b/src/main/java/com/signnow/api/document/response/data/EnumerationOption.java index 57c010c..a6ae277 100644 --- a/src/main/java/com/signnow/api/document/response/data/EnumerationOption.java +++ b/src/main/java/com/signnow/api/document/response/data/EnumerationOption.java @@ -17,46 +17,35 @@ import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; -/** - * This class represents an EnumerationOption which extends ApiData. - */ +/** This class represents an EnumerationOption which extends ApiData. */ public final class EnumerationOption extends ApiData { - /** - * The id of the EnumerationOption. - */ + /** The id of the EnumerationOption. */ @JsonProperty("id") private final String id; - /** - * The enumeration id of the EnumerationOption. - */ + /** The enumeration id of the EnumerationOption. */ @JsonProperty("enumeration_id") private final String enumerationId; - /** - * The data of the EnumerationOption. - */ + /** The data of the EnumerationOption. */ @JsonProperty("data") private final String data; - /** - * The created timestamp of the EnumerationOption. - */ + /** The created timestamp of the EnumerationOption. */ @JsonProperty("created") private final String created; - /** - * The updated timestamp of the EnumerationOption. - */ + /** The updated timestamp of the EnumerationOption. */ @JsonProperty("updated") private final String updated; /** - * The json attributes of the EnumerationOption. + * The json attributes of the EnumerationOption. Can be either a String or a JsonAttribute + * instance. */ @JsonProperty("json_attributes") - private final JsonAttribute jsonAttributes; + private final Object jsonAttributes; /** * Constructor for EnumerationOption. @@ -75,7 +64,7 @@ public EnumerationOption( @JsonProperty("data") String data, @JsonProperty("created") String created, @JsonProperty("updated") String updated, - @JsonProperty("json_attributes") JsonAttribute jsonAttributes) { + @JsonProperty("json_attributes") Object jsonAttributes) { this.id = id; this.enumerationId = enumerationId; this.data = data; @@ -122,10 +111,37 @@ public String getUpdated() { /** * @return The json attributes of the EnumerationOption. */ - public JsonAttribute getJsonAttributes() { + public Object getJsonAttributes() { return this.jsonAttributes; } + /** + * Checks if json_attributes is a String. + * + * @return true if json_attributes is a String, false otherwise. + */ + public boolean isJsonAttributesString() { + return jsonAttributes instanceof String; + } + + /** + * Get the json attributes as a JsonAttribute if possible. + * + * @return The JsonAttribute or null if not applicable. + */ + public JsonAttribute getJsonAttributesAsObject() { + return (jsonAttributes instanceof JsonAttribute) ? (JsonAttribute) jsonAttributes : null; + } + + /** + * Get the json attributes as a String if possible. + * + * @return The String representation or null if not applicable. + */ + public String getJsonAttributesAsString() { + return (jsonAttributes instanceof String) ? (String) jsonAttributes : null; + } + /** * Converts the EnumerationOption to a Map. * @@ -159,6 +175,6 @@ public static EnumerationOption fromMap(@NotNull Map data) { (String) data.get("data"), (String) data.get("created"), (String) data.get("updated"), - (JsonAttribute) data.get("json_attributes")); + data.get("json_attributes")); } -} \ No newline at end of file +} diff --git a/src/main/java/com/signnow/api/document/response/data/JsonAttribute.java b/src/main/java/com/signnow/api/document/response/data/JsonAttribute.java index 404e47d..98bc92e 100644 --- a/src/main/java/com/signnow/api/document/response/data/JsonAttribute.java +++ b/src/main/java/com/signnow/api/document/response/data/JsonAttribute.java @@ -18,97 +18,168 @@ import org.jetbrains.annotations.NotNull; /** - * This class represents a JSON attribute. + * This class represents a JSON attribute associated with a document field. + * It should be treated as a metadata attribute of the field itself. */ public final class JsonAttribute extends ApiData { /** - * The page number of the attribute. + * The field’s page number. */ @JsonProperty("page_number") private final int pageNumber; /** - * The x-coordinate of the attribute. + * The field’s x-coordinate on the page. */ @JsonProperty("x") private final int x; /** - * The y-coordinate of the attribute. + * The field’s y-coordinate on the page. */ @JsonProperty("y") private final int y; /** - * The width of the attribute. + * The width of the field. */ @JsonProperty("width") private final int width; /** - * The height of the attribute. + * The height of the field. */ @JsonProperty("height") private final int height; /** - * Whether the attribute is required or not. + * Whether the field is required or not. */ @JsonProperty("required") private final boolean required; /** - * The name of the attribute. + * The name of the field. */ @JsonProperty("name") private final String name; /** - * The label of the attribute. + * The label of the field. */ @JsonProperty("label") private final String label; /** - * Whether the attribute is bold or not. + * The color of the field. + */ + @JsonProperty("color") + private final String color; + + /** + * Whether the field is bold or not. */ @JsonProperty("bold") private final boolean bold; /** - * Whether the attribute is underlined or not. + * Whether the field is italic or not. + */ + @JsonProperty("italic") + private final boolean italic; + + /** + * Whether the field is underlined or not. */ @JsonProperty("underline") private final boolean underline; /** - * The maximum number of lines for the attribute. + * Horizontal alignment of the field. + */ + @JsonProperty("align") + private final String align; + + /** + * Vertical alignment of the field. + */ + @JsonProperty("valign") + private final String valign; + + /** + * The font name of the field. + */ + @JsonProperty("font") + private final String font; + + /** + * The font size of the field. + */ + @JsonProperty("font_size") + private final int fontSize; + + /** + * The size of the field. + */ + @JsonProperty("size") + private final int size; + + /** + * The arrangement of the field relative to other elements. + */ + @JsonProperty("arrangement") + private final String arrangement; + + /** + * The maximum number of lines for the field. */ @JsonProperty("max_lines") private final int maxLines; /** - * The validator ID of the attribute. + * The maximum number of chars for the field. + */ + @JsonProperty("max_chars") + private final int maxChars; + + /** + * The validator ID of the field. */ @JsonProperty("validator_id") private final String validatorId; + /** + * The text value used to prefill the field, if specified. + */ + @JsonProperty("prefilled_text") + private final String prefilledText; + /** * Constructor for JsonAttribute. * - * @param pageNumber the page number of the attribute - * @param x the x-coordinate of the attribute - * @param y the y-coordinate of the attribute - * @param width the width of the attribute - * @param height the height of the attribute - * @param required whether the attribute is required or not - * @param name the name of the attribute - * @param label the label of the attribute - * @param bold whether the attribute is bold or not - * @param underline whether the attribute is underlined or not - * @param maxLines the maximum number of lines for the attribute - * @param validatorId the validator ID of the attribute + * @param pageNumber the page number of the field + * @param x the x-coordinate of the field + * @param y the y-coordinate of the field + * @param width the width of the field + * @param height the height of the field + * @param required whether the field is required or not + * @param name the name of the field + * @param label the label of the field + * @param color the color of the field + * @param bold whether the field is bold or not + * @param italic whether the field is italic or not + * @param underline whether the field is underlined or not + * @param align the horizontal alignment + * @param valign the vertical alignment + * @param font font name + * @param fontSize font size + * @param size size + * @param arrangement arrangement of the field relative to other elements + * @param maxLines the maximum number of lines for the field + * @param maxChars the maximum number of chars for the field + * @param validatorId the validator ID of the field + * @param prefilledText text value used to prefill the field */ @JsonCreator public JsonAttribute( @@ -120,10 +191,20 @@ public JsonAttribute( @JsonProperty("required") boolean required, @JsonProperty("name") String name, @JsonProperty("label") String label, + @JsonProperty("color") String color, @JsonProperty("bold") boolean bold, + @JsonProperty("italic") boolean italic, @JsonProperty("underline") boolean underline, + @JsonProperty("align") String align, + @JsonProperty("valign") String valign, + @JsonProperty("font") String font, + @JsonProperty("font_size") int fontSize, + @JsonProperty("size") int size, + @JsonProperty("arrangement") String arrangement, @JsonProperty("max_lines") int maxLines, - @JsonProperty("validator_id") String validatorId) { + @JsonProperty("max_chars") int maxChars, + @JsonProperty("validator_id") String validatorId, + @JsonProperty("prefilled_text") String prefilledText) { this.pageNumber = pageNumber; this.x = x; this.y = y; @@ -132,14 +213,24 @@ public JsonAttribute( this.required = required; this.name = name; this.label = label; + this.color = color; this.bold = bold; + this.italic = italic; this.underline = underline; + this.align = align; + this.valign = valign; + this.font = font; + this.fontSize = fontSize; + this.size = size; + this.arrangement = arrangement; this.maxLines = maxLines; + this.maxChars = maxChars; this.validatorId = validatorId; + this.prefilledText = prefilledText; } /** - * Returns the page number of the attribute. + * Returns the page number of the field. * * @return the page number */ @@ -148,7 +239,7 @@ public int getPageNumber() { } /** - * Returns the x-coordinate of the attribute. + * Returns the x-coordinate of the field. * * @return the x-coordinate */ @@ -157,7 +248,7 @@ public int getX() { } /** - * Returns the y-coordinate of the attribute. + * Returns the y-coordinate of the field. * * @return the y-coordinate */ @@ -166,7 +257,7 @@ public int getY() { } /** - * Returns the width of the attribute. + * Returns the width of the field. * * @return the width */ @@ -175,7 +266,7 @@ public int getWidth() { } /** - * Returns the height of the attribute. + * Returns the height of the field. * * @return the height */ @@ -184,16 +275,16 @@ public int getHeight() { } /** - * Returns whether the attribute is required or not. + * Returns whether the field is required or not. * - * @return true if the attribute is required, false otherwise + * @return true if the field is required, false otherwise */ public boolean isRequired() { return this.required; } /** - * Returns the name of the attribute. + * Returns the name of the field. * * @return the name */ @@ -202,7 +293,7 @@ public String getName() { } /** - * Returns the label of the attribute. + * Returns the label of the field. * * @return the label */ @@ -211,25 +302,106 @@ public String getLabel() { } /** - * Returns whether the attribute is bold or not. + * Returns the color of the field. * - * @return true if the attribute is bold, false otherwise + * @return the color + */ + public String getColor() { + return this.color; + } + + /** + * Returns whether the field is bold or not. + * + * @return true if the field is bold, false otherwise */ public boolean isBold() { return this.bold; } /** - * Returns whether the attribute is underlined or not. + * Returns whether the field is italic or not. + * + * @return true if the field is italic, false otherwise + */ + public boolean isItalic() { + return this.italic; + } + + /** + * Returns whether the field is underlined or not. * - * @return true if the attribute is underlined, false otherwise + * @return true if the field is underlined, false otherwise */ public boolean isUnderline() { return this.underline; } /** - * Returns the maximum number of lines for the attribute. + * Returns horizontal align of the field. + * + * @return align + */ + public String getAlign() { + return this.align; + } + + /** + * Returns vertical align of the field. + * + * @return vertical align + */ + public String getValign() { + return this.valign; + } + + /** + * Returns font name. + * + * @return font + */ + public String getFont() { + return this.font; + } + + /** + * Returns font size. + * + * @return font size + */ + public int getFontSize() { + return this.fontSize; + } + + /** + * Returns size. + * + * @return size + */ + public int getSize() { + return this.size; + } + + /** + * Returns arrangement of the field relative to other elements. + * + * @return arrangement + */ + public String getArrangement() { + return arrangement; + } + + /** + * Returns the maximum number of chars for the field. + * + * @return the maximum number of chars + */ + public int getMaxChars() { + return maxChars; + } + + /** + * Returns the maximum number of lines for the field. * * @return the maximum number of lines */ @@ -238,7 +410,7 @@ public int getMaxLines() { } /** - * Returns the validator ID of the attribute. + * Returns the validator ID of the field. * * @return the validator ID */ @@ -247,9 +419,18 @@ public String getValidatorId() { } /** - * Converts the attribute to a map. + * Returns text value used to prefill the field. + * + * @return the value to prefill the field + */ + public String getPrefilledText() { + return prefilledText; + } + + /** + * Converts the field to a map. * - * @return a map representation of the attribute + * @return a map representation of the field */ @NotNull @Override @@ -263,10 +444,20 @@ public Map toMap() { map.put("required", this.isRequired()); map.put("name", this.getName()); map.put("label", this.getLabel()); + map.put("color", this.getColor()); map.put("bold", this.isBold()); + map.put("italic", this.isItalic()); map.put("underline", this.isUnderline()); + map.put("align", this.getAlign()); + map.put("valign", this.getValign()); + map.put("font", this.getFont()); + map.put("font_size", this.getFontSize()); + map.put("size", this.getSize()); + map.put("arrangement", this.getArrangement()); map.put("max_lines", this.getMaxLines()); + map.put("max_chars", this.getMaxChars()); map.put("validator_id", this.getValidatorId()); + map.put("prefilled_text", this.getPrefilledText()); return map; } @@ -288,9 +479,19 @@ public static JsonAttribute fromMap(@NotNull Map data) { (boolean) data.getOrDefault("required", false), (String) data.getOrDefault("name", ""), (String) data.getOrDefault("label", ""), + (String) data.getOrDefault("color", null), (boolean) data.getOrDefault("bold", false), + (boolean) data.getOrDefault("italic", false), (boolean) data.getOrDefault("underline", false), + (String) data.getOrDefault("align", ""), + (String) data.getOrDefault("valign", ""), + (String) data.getOrDefault("font", ""), + (int) data.getOrDefault("font_size", 0), + (int) data.getOrDefault("size", 0), + (String) data.getOrDefault("arrangement", ""), (int) data.getOrDefault("max_lines", 0), - (String) data.getOrDefault("validator_id", "")); + (int) data.getOrDefault("max_chars", 0), + (String) data.getOrDefault("validator_id", ""), + (String) data.getOrDefault("prefilled_text", "")); } } \ No newline at end of file diff --git a/src/main/java/com/signnow/api/document/response/data/ShareInfo.java b/src/main/java/com/signnow/api/document/response/data/ShareInfo.java index 09f6947..fe59f6d 100644 --- a/src/main/java/com/signnow/api/document/response/data/ShareInfo.java +++ b/src/main/java/com/signnow/api/document/response/data/ShareInfo.java @@ -17,25 +17,34 @@ import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; -/** - * This class represents the share information of a document. - */ +/** This class represents the share information of a document. */ public final class ShareInfo extends ApiData { - /** - * A boolean value indicating whether the document is shared with the team. - */ + /** A boolean value indicating whether the document is shared with the team. */ @JsonProperty("is_team_shared") private final boolean isTeamShared; + /** A string role assigned for a shared document */ + @JsonProperty("role") + private final String role; + + /** A boolean value indicating whether the document is personally shared with other users. */ + @JsonProperty("is_personally_shared_to_others") + private final boolean isPersonallySharedToOthers; + /** * Constructs a new ShareInfo object with the specified share status. * * @param isTeamShared a boolean value indicating whether the document is shared with the team. */ @JsonCreator - public ShareInfo(@JsonProperty("is_team_shared") boolean isTeamShared) { + public ShareInfo( + @JsonProperty("is_team_shared") boolean isTeamShared, + @JsonProperty("role") String role, + @JsonProperty("is_personally_shared_to_others") boolean isPersonallySharedToOthers) { this.isTeamShared = isTeamShared; + this.role = role; + this.isPersonallySharedToOthers = isPersonallySharedToOthers; } /** @@ -47,6 +56,26 @@ public boolean isTeamShared() { return this.isTeamShared; } + /** + * Returns true if the template has been personally shared with other users (via the Share + * button). The attribute is visible to the template owner and users with access rights. + * + * @return a boolean value indicating whether the document is personally shared with other users. + */ + public boolean isPersonallySharedToOthers() { + return isPersonallySharedToOthers; + } + + /** + * Returns the shared role, indicating the user's access level for shared document Allowed values + * are "sender", "viewer", "editor" or "owner" + * + * @return a string value specifying shared role + */ + public String getRole() { + return role; + } + /** * Converts this ShareInfo object to a Map. * @@ -57,6 +86,8 @@ public boolean isTeamShared() { public Map toMap() { Map map = new LinkedHashMap<>(); map.put("is_team_shared", this.isTeamShared()); + map.put("is_personally_shared_to_others", this.isPersonallySharedToOthers()); + map.put("role", this.getRole()); return map; } @@ -69,6 +100,9 @@ public Map toMap() { @NotNull @Contract("_ -> new") public static ShareInfo fromMap(@NotNull Map data) { - return new ShareInfo((boolean) data.getOrDefault("is_team_shared", false)); + return new ShareInfo( + (boolean) data.getOrDefault("is_team_shared", false), + (String) data.getOrDefault("role", ""), + (boolean) data.getOrDefault("is_personally_shared_to_others", false)); } -} \ No newline at end of file +} diff --git a/src/main/java/com/signnow/api/documentgroup/response/DownloadDocumentGroupPostResponse.java b/src/main/java/com/signnow/api/documentgroup/response/DownloadDocumentGroupPostResponse.java index 71b508a..7415bec 100644 --- a/src/main/java/com/signnow/api/documentgroup/response/DownloadDocumentGroupPostResponse.java +++ b/src/main/java/com/signnow/api/documentgroup/response/DownloadDocumentGroupPostResponse.java @@ -10,12 +10,35 @@ package com.signnow.api.documentgroup.response; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import java.io.File; /** - * This class represents the response received after a request to download a document group. - * It is annotated to ignore unknown properties when parsing JSON. + * This class represents the response received after a request to download a document group. It is + * annotated to ignore unknown properties when parsing JSON. */ -@JsonIgnoreProperties(ignoreUnknown = true) public class DownloadDocumentGroupPostResponse { - // No public properties, constructors, or methods to comment on. -} \ No newline at end of file + + /** + * The file downloaded as part of the response. This file is created from the response content and + * stored locally. + */ + private final File file; + + /** + * Creates a new DownloadDocumentGroupPostResponse with the specified file. + * + * @param file The downloaded file + */ + public DownloadDocumentGroupPostResponse(File file) { + this.file = file; + } + + /** + * Gets the downloaded file. + * + * @return The File object representing the downloaded file + */ + public File getFile() { + return file; + } +} diff --git a/src/main/java/com/signnow/api/documentgroupinvite/response/PendingInviteGetResponse.java b/src/main/java/com/signnow/api/documentgroupinvite/response/PendingInviteGetResponse.java index c0b098b..6a89cac 100644 --- a/src/main/java/com/signnow/api/documentgroupinvite/response/PendingInviteGetResponse.java +++ b/src/main/java/com/signnow/api/documentgroupinvite/response/PendingInviteGetResponse.java @@ -32,17 +32,35 @@ public class PendingInviteGetResponse { @JsonProperty("invites") private final InviteCollection invites; + /** + * Should be signed as a single document + */ + @JsonProperty("sign_as_merged") + private final boolean signAsMerged; + + /** + * The owner organization id + */ + @JsonProperty("owner_organization_id") + private final String ownerOrganizationId; + /** * Constructs a new PendingInviteGetResponse with the specified document group name and invites. * * @param documentGroupName the name of the document group * @param invites the collection of invites + * @param signAsMerged should be signed as a single document + * @param ownerOrganizationId owner organization id */ public PendingInviteGetResponse( @JsonProperty("document_group_name") String documentGroupName, - @JsonProperty("invites") InviteCollection invites) { + @JsonProperty("invites") InviteCollection invites, + @JsonProperty("sign_as_merged") boolean signAsMerged, + @JsonProperty("owner_organization_id") String ownerOrganizationId) { this.documentGroupName = documentGroupName; this.invites = invites; + this.signAsMerged = signAsMerged; + this.ownerOrganizationId = ownerOrganizationId; } /** @@ -62,4 +80,22 @@ public String getDocumentGroupName() { public InviteCollection getInvites() { return this.invites; } + + /** + * Return owner organization id + * + * @return owner organization id + */ + public String getOwnerOrganizationId() { + return this.ownerOrganizationId; + } + + /** + * Return should be signed as a single document + * + * @return should be signed as a single document + */ + public boolean isSignAsMerged() { + return this.signAsMerged; + } } \ No newline at end of file diff --git a/src/main/java/com/signnow/api/embeddedsending/request/DocumentEmbeddedSendingLinkPostRequest.java b/src/main/java/com/signnow/api/embeddedsending/request/DocumentEmbeddedSendingLinkPostRequest.java new file mode 100644 index 0000000..7607a3b --- /dev/null +++ b/src/main/java/com/signnow/api/embeddedsending/request/DocumentEmbeddedSendingLinkPostRequest.java @@ -0,0 +1,138 @@ +/* + * 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.embeddedsending.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 sending link. It implements the + * RequestInterface with an Object type. + */ +@ApiEndpoint( + name = "createDocumentEmbeddedSendingLink", + url = "/v2/documents/{document_id}/embedded-sending", + method = "post", + auth = "bearer", + namespace = "embeddedSending", + entity = "documentEmbeddedSendingLink", + type = "application/json") +public final class DocumentEmbeddedSendingLinkPostRequest implements RequestInterface { + + /** The type of the request. */ + private final String type; + + /** The redirect URI of the request. */ + private final String redirectUri; + + /** The link expiration time of the request. */ + private final int linkExpiration; + + /** The redirect target of the request. */ + private final String redirectTarget; + + /** The URI parameters of the request. */ + private final HashMap uriParams = new HashMap<>(); + + /** + * Constructs a new DocumentEmbeddedSendingLinkPostRequest with the specified type, redirect URI, + * link expiration, and redirect target. + * + * @param type the type of the request + * @param redirectUri the redirect URI of the request + * @param linkExpiration the link expiration time of the request + * @param redirectTarget the redirect target of the request + */ + public DocumentEmbeddedSendingLinkPostRequest( + String type, String redirectUri, int linkExpiration, String redirectTarget) { + this.type = type; + this.redirectUri = redirectUri; + this.linkExpiration = linkExpiration; + this.redirectTarget = redirectTarget; + } + + /** + * Returns the type of the request. + * + * @return the type of the request + */ + public String getType() { + return this.type; + } + + /** + * Returns the redirect URI of the request. + * + * @return the redirect URI of the request + */ + public String getRedirectUri() { + return this.redirectUri; + } + + /** + * Returns the link expiration time of the request. + * + * @return the link expiration time of the request + */ + public int getLinkExpiration() { + return this.linkExpiration; + } + + /** + * Returns the redirect target of the request. + * + * @return the redirect target of the request + */ + public String getRedirectTarget() { + return this.redirectTarget; + } + + /** + * Adds the document ID to the URI parameters and returns the current instance. + * + * @param documentId the document ID to be added + * @return the current instance with the updated URI parameters + */ + public DocumentEmbeddedSendingLinkPostRequest withDocumentId(String documentId) { + this.uriParams.put("document_id", documentId); + return this; + } + + /** + * Returns the URI parameters of 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("type", this.getType()); + map.put("redirect_uri", this.getRedirectUri()); + map.put("link_expiration", this.getLinkExpiration()); + map.put("redirect_target", this.getRedirectTarget()); + return map; + } +} diff --git a/src/main/java/com/signnow/api/embeddedsending/request/DocumentGroupEmbeddedSendingLinkPostRequest.java b/src/main/java/com/signnow/api/embeddedsending/request/DocumentGroupEmbeddedSendingLinkPostRequest.java new file mode 100644 index 0000000..b584395 --- /dev/null +++ b/src/main/java/com/signnow/api/embeddedsending/request/DocumentGroupEmbeddedSendingLinkPostRequest.java @@ -0,0 +1,123 @@ +/* + * 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.embeddedsending.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 group embedded sending link. It implements + * the RequestInterface with an Object type. + */ +@ApiEndpoint( + name = "createDocumentGroupEmbeddedSendingLink", + url = "/v2/document-groups/{document_group_id}/embedded-sending", + method = "post", + auth = "bearer", + namespace = "embeddedSending", + entity = "documentGroupEmbeddedSendingLink", + type = "application/json") +public final class DocumentGroupEmbeddedSendingLinkPostRequest implements RequestInterface { + + /** The redirect URI for the request. */ + private final String redirectUri; + + /** The link expiration time for the request. */ + private final int linkExpiration; + + /** The redirect target for the request. */ + private final String redirectTarget; + + /** The URI parameters for the request. */ + private final HashMap uriParams = new HashMap<>(); + + /** + * Constructs a new DocumentGroupEmbeddedSendingLinkPostRequest with the specified redirect URI, + * link expiration, and redirect target. + * + * @param redirectUri the redirect URI for the request + * @param linkExpiration the link expiration time for the request + * @param redirectTarget the redirect target for the request + */ + public DocumentGroupEmbeddedSendingLinkPostRequest( + String redirectUri, int linkExpiration, String redirectTarget) { + this.redirectUri = redirectUri; + this.linkExpiration = linkExpiration; + this.redirectTarget = redirectTarget; + } + + /** + * Returns the redirect URI for the request. + * + * @return the redirect URI for the request + */ + public String getRedirectUri() { + return this.redirectUri; + } + + /** + * Returns the link expiration time for the request. + * + * @return the link expiration time for the request + */ + public int getLinkExpiration() { + return this.linkExpiration; + } + + /** + * Returns the redirect target for the request. + * + * @return the redirect target for the request + */ + public String getRedirectTarget() { + return this.redirectTarget; + } + + /** + * Adds the document group ID to the URI parameters. + * + * @param documentGroupId the document group ID to add + * @return the current instance of DocumentGroupEmbeddedSendingLinkPostRequest + */ + public DocumentGroupEmbeddedSendingLinkPostRequest withDocumentGroupId(String documentGroupId) { + this.uriParams.put("document_group_id", documentGroupId); + 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("link_expiration", this.getLinkExpiration()); + map.put("redirect_target", this.getRedirectTarget()); + return map; + } +} diff --git a/src/main/java/com/signnow/api/embeddedsending/response/DocumentEmbeddedSendingLinkPostResponse.java b/src/main/java/com/signnow/api/embeddedsending/response/DocumentEmbeddedSendingLinkPostResponse.java new file mode 100644 index 0000000..c748058 --- /dev/null +++ b/src/main/java/com/signnow/api/embeddedsending/response/DocumentEmbeddedSendingLinkPostResponse.java @@ -0,0 +1,44 @@ +/* + * 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.embeddedsending.response; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.signnow.api.embeddedsending.response.data.DataUrl; + +/** + * This class represents the response containing the embedded sending link for a document. It + * ignores unknown properties in the JSON response. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class DocumentEmbeddedSendingLinkPostResponse { + + /** The data URL associated with the embedded sending link. */ + @JsonProperty("data") + private final DataUrl data; + + /** + * Constructs a new DocumentEmbeddedSendingLinkPostResponse with the specified data URL. + * + * @param data the data URL associated with the embedded sending link. + */ + public DocumentEmbeddedSendingLinkPostResponse(@JsonProperty("data") DataUrl data) { + this.data = data; + } + + /** + * Returns the data URL associated with the embedded sending link. + * + * @return the data URL associated with the embedded sending link. + */ + public DataUrl getData() { + return this.data; + } +} diff --git a/src/main/java/com/signnow/api/embeddedsending/response/DocumentGroupEmbeddedSendingLinkPostResponse.java b/src/main/java/com/signnow/api/embeddedsending/response/DocumentGroupEmbeddedSendingLinkPostResponse.java new file mode 100644 index 0000000..06e2dd7 --- /dev/null +++ b/src/main/java/com/signnow/api/embeddedsending/response/DocumentGroupEmbeddedSendingLinkPostResponse.java @@ -0,0 +1,44 @@ +/* + * 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.embeddedsending.response; + +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.signnow.api.embeddedsending.response.data.DataUrl; + +/** + * This class represents the response for the Document Group Embedded Sending Link Post request. It + * contains the data URL associated with the response. + */ +@JsonIgnoreProperties(ignoreUnknown = true) +public class DocumentGroupEmbeddedSendingLinkPostResponse { + + /** The data URL associated with the response. */ + @JsonProperty("data") + private final DataUrl data; + + /** + * Constructs a new DocumentGroupEmbeddedSendingLinkPostResponse with the specified data URL. + * + * @param data the data URL associated with the response. + */ + public DocumentGroupEmbeddedSendingLinkPostResponse(@JsonProperty("data") DataUrl data) { + this.data = data; + } + + /** + * Returns the data URL associated with the response. + * + * @return the data URL associated with the response. + */ + public DataUrl getData() { + return this.data; + } +} diff --git a/src/main/java/com/signnow/api/embeddedsending/response/data/DataUrl.java b/src/main/java/com/signnow/api/embeddedsending/response/data/DataUrl.java new file mode 100644 index 0000000..3674db6 --- /dev/null +++ b/src/main/java/com/signnow/api/embeddedsending/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.embeddedsending.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 as a string. + */ + @JsonCreator + public DataUrl(@JsonProperty("url") String url) { + this.url = url; + } + + /** + * Retrieves the URL. + * + * @return the URL as a 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. + * + * @param data a 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/main/java/com/signnow/api/folder/response/FolderGetResponse.java b/src/main/java/com/signnow/api/folder/response/FolderGetResponse.java index 9b0bf6f..9456237 100644 --- a/src/main/java/com/signnow/api/folder/response/FolderGetResponse.java +++ b/src/main/java/com/signnow/api/folder/response/FolderGetResponse.java @@ -31,7 +31,7 @@ public class FolderGetResponse { * The timestamp when the folder was created. */ @JsonProperty("created") - private final int created; + private final String created; /** * The name of the folder. @@ -119,7 +119,7 @@ public class FolderGetResponse { @JsonCreator public FolderGetResponse( @JsonProperty("id") String id, - @JsonProperty("created") int created, + @JsonProperty("created") String created, @JsonProperty("name") String name, @JsonProperty("user_id") String userId, @JsonProperty("system_folder") boolean systemFolder, @@ -160,7 +160,7 @@ public String getId() { * * @return the timestamp when the folder was created */ - public int getCreated() { + public String getCreated() { return this.created; } diff --git a/src/main/java/com/signnow/api/proxy/response/ProxyFileResponse.java b/src/main/java/com/signnow/api/proxy/response/ProxyFileResponse.java new file mode 100644 index 0000000..931dab7 --- /dev/null +++ b/src/main/java/com/signnow/api/proxy/response/ProxyFileResponse.java @@ -0,0 +1,42 @@ +/* + * 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.proxy.response; + +import java.io.File; + +/** + * This class represents the response received after a request to proxy any unimplemented endpoint + * that returns a file. + */ +public class ProxyFileResponse { + /** + * The file downloaded as part of the response. This file is created from the response content and + * stored locally. + */ + private final File file; + + /** + * Creates a new ProxyFileResponse with the specified file. + * + * @param file The downloaded file + */ + public ProxyFileResponse(File file) { + this.file = file; + } + + /** + * Gets the downloaded file. + * + * @return The File object representing the downloaded file + */ + public File getFile() { + return file; + } +} diff --git a/src/main/java/com/signnow/api/proxy/response/ProxyJsonResponse.java b/src/main/java/com/signnow/api/proxy/response/ProxyJsonResponse.java new file mode 100644 index 0000000..8ac8c00 --- /dev/null +++ b/src/main/java/com/signnow/api/proxy/response/ProxyJsonResponse.java @@ -0,0 +1,51 @@ +/* + * 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.proxy.response; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.databind.JsonNode; + +/** + * This class represents the response received after a request to proxy any unimplemented endpoint + * that returns JSON data. + */ +public class ProxyJsonResponse { + /** The raw JSON content returned from the proxied endpoint. */ + private final JsonNode rawJson; + + /** + * Constructs a new ProxyJsonResponse with the specified raw JSON. + * + * @param rawJson the raw JSON content returned from the proxied endpoint + */ + @JsonCreator + public ProxyJsonResponse(JsonNode rawJson) { + this.rawJson = rawJson; + } + + /** + * Returns the raw JSON content returned from the proxied endpoint. + * + * @return the raw JSON content + */ + public JsonNode getRawJson() { + return rawJson; + } + + /** + * Returns the string representation of the raw JSON in pretty-print format. + * + * @return the pretty-printed JSON string + */ + @Override + public String toString() { + return rawJson.toPrettyString(); + } +} diff --git a/src/main/java/com/signnow/api/template/request/data/routingdetail/InviteAction.java b/src/main/java/com/signnow/api/template/request/data/routingdetail/InviteAction.java index 2ac053d..0a4507c 100644 --- a/src/main/java/com/signnow/api/template/request/data/routingdetail/InviteAction.java +++ b/src/main/java/com/signnow/api/template/request/data/routingdetail/InviteAction.java @@ -17,50 +17,34 @@ import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; -/** - * This class represents an invite action in the signNow API. - */ +/** This class represents an invitation action in the signNow API. */ public final class InviteAction extends ApiData { - /** - * The email of the invitee. - */ + /** The email of the invitee. */ @JsonProperty("email") private final String email; - /** - * The role name of the invitee. - */ + /** The role name of the invitee. */ @JsonProperty("role_name") private final String roleName; - /** - * The action to be performed. - */ + /** The action to be performed. */ @JsonProperty("action") private final String action; - /** - * The ID of the document. - */ + /** The ID of the document. */ @JsonProperty("document_id") private final String documentId; - /** - * The name of the document. - */ + /** The name of the document. */ @JsonProperty("document_name") private final String documentName; - /** - * Flag to allow reassignment of the invite. - */ + /** Flag to allow reassignment of the invite. */ @JsonProperty("allow_reassign") private final String allowReassign; - /** - * Flag to allow decline by signature. - */ + /** Flag to allow decline by signature. */ @JsonProperty("decline_by_signature") private final String declineBySignature; @@ -195,12 +179,12 @@ public Map toMap() { @Contract("_ -> new") public static InviteAction fromMap(@NotNull Map data) { return new InviteAction( - (String) data.get("email"), - (String) data.get("role_name"), - (String) data.get("action"), - (String) data.get("document_id"), - (String) data.get("document_name"), - (String) data.getOrDefault("allow_reassign", ""), - (String) data.getOrDefault("decline_by_signature", "")); + (String) data.get("email"), + (String) data.get("role_name"), + (String) data.get("action"), + (String) data.get("document_id"), + (String) data.get("document_name"), + (String) data.getOrDefault("allow_reassign", ""), + (String) data.getOrDefault("decline_by_signature", "")); } -} \ No newline at end of file +} diff --git a/src/main/java/com/signnow/api/template/request/data/routingdetail/InviteActionCollection.java b/src/main/java/com/signnow/api/template/request/data/routingdetail/InviteActionCollection.java index 2da293d..d93c31b 100644 --- a/src/main/java/com/signnow/api/template/request/data/routingdetail/InviteActionCollection.java +++ b/src/main/java/com/signnow/api/template/request/data/routingdetail/InviteActionCollection.java @@ -12,20 +12,20 @@ import com.signnow.core.collection.TypedCollection; /** - * This class represents a collection of InviteAction objects. - * It extends the TypedCollection class, specifying InviteAction as the type parameter. - * This means that this collection will only accept InviteAction objects. - * + * This class represents a collection of InviteAction objects. It extends the TypedCollection class, + * specifying InviteAction as the type parameter. This means that this collection will only accept + * InviteAction objects. + * * @see com.signnow.core.collection.TypedCollection * @see com.signnow.api.template.request.data.routingdetail.InviteAction */ public class InviteActionCollection extends TypedCollection { - /** - * Default constructor for InviteActionCollection. - * It calls the constructor of the superclass TypedCollection. - */ - public InviteActionCollection() { - super(); - } -} \ No newline at end of file + /** + * Default constructor for InviteActionCollection. It calls the constructor of the superclass + * TypedCollection. + */ + public InviteActionCollection() { + super(); + } +} diff --git a/src/main/java/com/signnow/api/template/request/data/routingdetail/InviteEmail.java b/src/main/java/com/signnow/api/template/request/data/routingdetail/InviteEmail.java index ab7d3f7..d488bf6 100644 --- a/src/main/java/com/signnow/api/template/request/data/routingdetail/InviteEmail.java +++ b/src/main/java/com/signnow/api/template/request/data/routingdetail/InviteEmail.java @@ -17,44 +17,30 @@ import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; -/** - * This class represents an invitation email. - */ +/** This class represents an invitation email. */ public final class InviteEmail extends ApiData { - /** - * The email address to which the invitation is sent. - */ + /** The email address to which the invitation is sent. */ @JsonProperty("email") private final String email; - /** - * The subject of the invitation email. - */ + /** The subject of the invitation email. */ @JsonProperty("subject") private final String subject; - /** - * The message content of the invitation email. - */ + /** The message content of the invitation email. */ @JsonProperty("message") private final String message; - /** - * The permission to reassign the invitation. - */ + /** The permission to reassign the invitation. */ @JsonProperty("allow_reassign") private final String allowReassign; - /** - * The number of days before the invitation expires. - */ + /** The number of days before the invitation expires. */ @JsonProperty("expiration_days") private final int expirationDays; - /** - * The reminder setting for the invitation. - */ + /** The reminder setting for the invitation. */ @JsonProperty("reminder") private final int reminder; diff --git a/src/main/java/com/signnow/api/template/request/data/routingdetail/InviteEmailCollection.java b/src/main/java/com/signnow/api/template/request/data/routingdetail/InviteEmailCollection.java index 39e85bf..92546ec 100644 --- a/src/main/java/com/signnow/api/template/request/data/routingdetail/InviteEmailCollection.java +++ b/src/main/java/com/signnow/api/template/request/data/routingdetail/InviteEmailCollection.java @@ -12,14 +12,12 @@ import com.signnow.core.collection.TypedCollection; /** - * This class represents a collection of InviteEmail objects. - * It extends the TypedCollection class, specifying InviteEmail as the type parameter. + * This class represents a collection of InviteEmail objects. It extends the TypedCollection class, + * specifying InviteEmail as the type parameter. */ public class InviteEmailCollection extends TypedCollection { - /** - * Default constructor {@code InviteEmailCollection}. - */ - public InviteEmailCollection() { - super(); - } + /** Default constructor {@code InviteEmailCollection}. */ + public InviteEmailCollection() { + super(); + } } diff --git a/src/main/java/com/signnow/api/template/request/data/routingdetail/InviteStep.java b/src/main/java/com/signnow/api/template/request/data/routingdetail/InviteStep.java index 33d4ef7..07ab12e 100644 --- a/src/main/java/com/signnow/api/template/request/data/routingdetail/InviteStep.java +++ b/src/main/java/com/signnow/api/template/request/data/routingdetail/InviteStep.java @@ -17,26 +17,18 @@ import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; -/** - * This class represents an invite step in the signNow API. - */ +/** This class represents an invite step in the signNow API. */ public final class InviteStep extends ApiData { - /** - * The order of the invite step. - */ + /** The order of the invite step. */ @JsonProperty("order") private final int order; - /** - * The actions associated with the invite step. - */ + /** The actions associated with the invite step. */ @JsonProperty("invite_actions") private final InviteActionCollection inviteActions; - /** - * The emails associated with the invite step. - */ + /** The emails associated with the invite step. */ @JsonProperty("invite_emails") private final InviteEmailCollection inviteEmails; diff --git a/src/main/java/com/signnow/api/template/request/data/routingdetail/InviteStepCollection.java b/src/main/java/com/signnow/api/template/request/data/routingdetail/InviteStepCollection.java index 2ce7ab2..910c69c 100644 --- a/src/main/java/com/signnow/api/template/request/data/routingdetail/InviteStepCollection.java +++ b/src/main/java/com/signnow/api/template/request/data/routingdetail/InviteStepCollection.java @@ -12,14 +12,12 @@ import com.signnow.core.collection.TypedCollection; /** - * This class represents a collection of InviteStep objects. - * It extends the TypedCollection class, which provides methods for managing collections of a specific type. + * This class represents a collection of InviteStep objects. It extends the TypedCollection class, + * which provides methods for managing collections of a specific type. */ public class InviteStepCollection extends TypedCollection { - /** - * Default constructor {@code InviteStepCollection}. - */ - public InviteStepCollection() { - super(); - } + /** Default constructor {@code InviteStepCollection}. */ + public InviteStepCollection() { + super(); + } } diff --git a/src/main/java/com/signnow/api/template/request/data/routingdetail/RoutingDetail.java b/src/main/java/com/signnow/api/template/request/data/routingdetail/RoutingDetail.java index a3974b2..391b7f4 100644 --- a/src/main/java/com/signnow/api/template/request/data/routingdetail/RoutingDetail.java +++ b/src/main/java/com/signnow/api/template/request/data/routingdetail/RoutingDetail.java @@ -17,20 +17,14 @@ import org.jetbrains.annotations.Contract; import org.jetbrains.annotations.NotNull; -/** - * This class represents the routing details of a request. - */ +/** This class represents the routing details of a request. */ public final class RoutingDetail extends ApiData { - /** - * Collection of invite steps. - */ + /** Collection of invite steps. */ @JsonProperty("invite_steps") private final InviteStepCollection inviteSteps; - /** - * Flag to include email attachments. - */ + /** Flag to include email attachments. */ @JsonProperty("include_email_attachments") private final int includeEmailAttachments; diff --git a/src/main/java/com/signnow/api/template/response/GroupTemplateGetResponse.java b/src/main/java/com/signnow/api/template/response/GroupTemplateGetResponse.java index d27bf6a..78f0958 100644 --- a/src/main/java/com/signnow/api/template/response/GroupTemplateGetResponse.java +++ b/src/main/java/com/signnow/api/template/response/GroupTemplateGetResponse.java @@ -9,145 +9,312 @@ package com.signnow.api.template.response; +import com.fasterxml.jackson.annotation.JsonCreator; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; +import com.signnow.api.template.response.data.ShareInfo; +import com.signnow.api.template.response.data.routingdetail.RoutingDetail; +import com.signnow.api.template.response.data.template.TemplateCollection; /** - * This class represents the response from the GroupTemplateGet API. + * Represents a group template with various details. */ @JsonIgnoreProperties(ignoreUnknown = true) -public class GroupTemplateGetResponse { +public final class GroupTemplateGetResponse { /** - * The unique identifier of the group template. + * The unique ID of the group template. */ @JsonProperty("id") private final String id; /** - * The name of the group template. + * Identifier of the user who owns the document group. */ - @JsonProperty("name") - private final String name; + @JsonProperty("user_id") + private final String userId; /** - * The filename of the group template. + * Name of the group. */ - @JsonProperty("filename") - private final String filename; + @JsonProperty("group_name") + private final String groupName; /** - * The page count of the group template. + * Identifier of the folder containing this document group. */ - @JsonProperty("page_count") - private final int pageCount; + @JsonProperty("folder_id") + private final String folderId; /** - * The creation timestamp of the group template. + * Routing details related to this document group. + */ + @JsonProperty("routing_details") + private final RoutingDetail routingDetails; + + /** + * Templates associated with the document group. + */ + @JsonProperty("templates") + private final TemplateCollection templates; + + /** + * Indicates whether the document group is shared (1) or not (0). + */ + @JsonProperty("shared") + private final int shared; + + /** + * Email of the owner who created the document group template. + */ + @JsonProperty("document_group_template_owner_email") + private final String documentGroupTemplateOwnerEmail; + + /** + * Identifier of the team with which the document group is shared. + */ + @JsonProperty("shared_team_id") + private final String sharedTeamId; + + /** + * Indicates if the document group should be owned as merged. + */ + @JsonProperty("own_as_merged") + private final boolean ownAsMerged; + + /** + * Action to be taken via email after the completion of a workflow. + */ + @JsonProperty("email_action_on_complete") + private final String emailActionOnComplete; + + /** + * Timestamp when the document group was created (Unix epoch). */ @JsonProperty("created") private final int created; /** - * The last updated timestamp of the group template. + * Timestamp when the document group was last updated (Unix epoch). */ @JsonProperty("updated") private final int updated; /** - * The editor link of the group template. + * Indicates if the document group was recently used (1 = yes, 0 = no). + */ + @JsonProperty("recently_used") + private final int recentlyUsed; + + /** + * Indicates if the document group is pinned for easy access. + */ + @JsonProperty("pinned") + private final boolean pinned; + + /** + * Information about sharing settings and permissions. */ - @JsonProperty("editor_link") - private final String editorLink; + @JsonProperty("share_info") + private final ShareInfo shareInfo; /** - * Constructs a new GroupTemplateGetResponse with the specified values. + * Constructs a new GroupTemplateGet instance. * - * @param id the unique identifier of the group template - * @param name the name of the group template - * @param filename the filename of the group template - * @param pageCount the page count of the group template - * @param created the creation timestamp of the group template - * @param updated the last updated timestamp of the group template - * @param editorLink the editor link of the group template + * @param id The ID of the group template. + * @param userId The user ID associated with the group template. + * @param groupName The name of the group. + * @param folderId The folder ID where the template is stored. + * @param routingDetails The routing details of the template. + * @param templates The collection of templates. + * @param shared The shared status of the template. + * @param documentGroupTemplateOwnerEmail The email of the document group template owner. + * @param sharedTeamId The ID of the shared team. + * @param ownAsMerged Whether the template is owned as merged. + * @param emailActionOnComplete The email action on completion. + * @param created The creation timestamp. + * @param updated The update timestamp. + * @param recentlyUsed The recently used status. + * @param pinned Whether the template is pinned. + * @param shareInfo The share information. */ + @JsonCreator public GroupTemplateGetResponse( @JsonProperty("id") String id, - @JsonProperty("name") String name, - @JsonProperty("filename") String filename, - @JsonProperty("page_count") int pageCount, + @JsonProperty("userId") String userId, + @JsonProperty("groupName") String groupName, + @JsonProperty("folderId") String folderId, + @JsonProperty("routingDetails") RoutingDetail routingDetails, + @JsonProperty("templates") TemplateCollection templates, + @JsonProperty("shared") int shared, + @JsonProperty("documentGroupTemplateOwnerEmail") String documentGroupTemplateOwnerEmail, + @JsonProperty("sharedTeamId") String sharedTeamId, + @JsonProperty("ownAsMerged") boolean ownAsMerged, + @JsonProperty("emailActionOnComplete") String emailActionOnComplete, @JsonProperty("created") int created, @JsonProperty("updated") int updated, - @JsonProperty("editor_link") String editorLink) { + @JsonProperty("recentlyUsed") int recentlyUsed, + @JsonProperty("pinned") boolean pinned, + @JsonProperty("shareInfo") ShareInfo shareInfo) { this.id = id; - this.name = name; - this.filename = filename; - this.pageCount = pageCount; + this.userId = userId; + this.groupName = groupName; + this.folderId = folderId; + this.routingDetails = routingDetails; + this.templates = templates; + this.shared = shared; + this.documentGroupTemplateOwnerEmail = documentGroupTemplateOwnerEmail; + this.sharedTeamId = sharedTeamId; + this.ownAsMerged = ownAsMerged; + this.emailActionOnComplete = emailActionOnComplete; this.created = created; this.updated = updated; - this.editorLink = editorLink; + this.recentlyUsed = recentlyUsed; + this.pinned = pinned; + this.shareInfo = shareInfo; } /** - * Returns the unique identifier of the group template. + * Gets the ID of the group template. * - * @return the unique identifier of the group template + * @return The ID of the group template. */ public String getId() { return this.id; } /** - * Returns the name of the group template. + * Gets the user ID associated with the group template. + * + * @return The user ID. + */ + public String getUserId() { + return this.userId; + } + + /** + * Gets the name of the group. + * + * @return The group name. + */ + public String getGroupName() { + return this.groupName; + } + + /** + * Gets the folder ID where the template is stored. + * + * @return The folder ID. + */ + public String getFolderId() { + return this.folderId; + } + + /** + * Gets the routing details of the template. + * + * @return The routing details. + */ + public RoutingDetail getRoutingDetails() { + return this.routingDetails; + } + + /** + * Gets the collection of templates. + * + * @return The template collection. + */ + public TemplateCollection getTemplates() { + return this.templates; + } + + /** + * Gets the shared status of the template. + * + * @return The shared status. + */ + public int getShared() { + return this.shared; + } + + /** + * Gets the email of the document group template owner. + * + * @return The owner's email. + */ + public String getDocumentGroupTemplateOwnerEmail() { + return this.documentGroupTemplateOwnerEmail; + } + + /** + * Gets the ID of the shared team. + * + * @return The shared team ID. + */ + public String getSharedTeamId() { + return this.sharedTeamId; + } + + /** + * Gets the share information. * - * @return the name of the group template + * @return The share information. */ - public String getName() { - return this.name; + public ShareInfo getShareInfo() { + return this.shareInfo; } /** - * Returns the filename of the group template. + * Checks if the template is owned as merged. * - * @return the filename of the group template + * @return True if owned as merged, otherwise false. */ - public String getFilename() { - return this.filename; + public boolean isOwnAsMerged() { + return this.ownAsMerged; } /** - * Returns the page count of the group template. + * Gets the email action on completion. * - * @return the page count of the group template + * @return The email action on completion. */ - public int getPageCount() { - return this.pageCount; + public String getEmailActionOnComplete() { + return this.emailActionOnComplete; } /** - * Returns the creation timestamp of the group template. + * Gets the creation timestamp. * - * @return the creation timestamp of the group template + * @return The creation timestamp. */ public int getCreated() { return this.created; } /** - * Returns the last updated timestamp of the group template. + * Gets the update timestamp. * - * @return the last updated timestamp of the group template + * @return The update timestamp. */ public int getUpdated() { return this.updated; } /** - * Returns the editor link of the group template. + * Gets the recently used status. + * + * @return The recently used status. + */ + public int getRecentlyUsed() { + return this.recentlyUsed; + } + + /** + * Checks if the template is pinned. * - * @return the editor link of the group template + * @return True if pinned, otherwise false. */ - public String getEditorLink() { - return this.editorLink; + public boolean isPinned() { + return this.pinned; } -} \ No newline at end of file +} diff --git a/src/main/java/com/signnow/api/template/response/RoutingDetailsGetResponse.java b/src/main/java/com/signnow/api/template/response/RoutingDetailsGetResponse.java index 154794f..6ff31a6 100644 --- a/src/main/java/com/signnow/api/template/response/RoutingDetailsGetResponse.java +++ b/src/main/java/com/signnow/api/template/response/RoutingDetailsGetResponse.java @@ -11,12 +11,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; -import com.signnow.api.template.response.data.ApproverGetCollection; -import com.signnow.api.template.response.data.CcGetCollection; -import com.signnow.api.template.response.data.CcStepGetCollection; -import com.signnow.api.template.response.data.InviteLinkInstructionGetCollection; -import com.signnow.api.template.response.data.RoutingDetailGetCollection; -import com.signnow.api.template.response.data.ViewerGetCollection; +import com.signnow.api.template.response.data.*; /** * This class represents the response for getting routing details. @@ -49,11 +44,17 @@ public class RoutingDetailsGetResponse { private final ViewerGetCollection viewers; /** - * Collection of approvers. + * Collection of persons who approve the signing. */ @JsonProperty("approvers") private final ApproverGetCollection approvers; + /** + * Attributes. + */ + @JsonProperty("attributes") + private final AttributeGet attributes; + /** * Collection of invite link instructions. */ @@ -67,7 +68,7 @@ public class RoutingDetailsGetResponse { * @param cc Collection of CCs. * @param ccStep Collection of CC steps. * @param viewers Collection of viewers. - * @param approvers Collection of approvers. + * @param approvers Collection of persons who approve the signing. * @param inviteLinkInstructions Collection of invite link instructions. */ public RoutingDetailsGetResponse( @@ -76,6 +77,7 @@ public RoutingDetailsGetResponse( @JsonProperty("cc_step") CcStepGetCollection ccStep, @JsonProperty("viewers") ViewerGetCollection viewers, @JsonProperty("approvers") ApproverGetCollection approvers, + @JsonProperty("attributes") AttributeGet attributes, @JsonProperty("invite_link_instructions") InviteLinkInstructionGetCollection inviteLinkInstructions) { this.routingDetails = routingDetails; @@ -83,6 +85,7 @@ public RoutingDetailsGetResponse( this.ccStep = ccStep; this.viewers = viewers; this.approvers = approvers; + this.attributes = attributes; this.inviteLinkInstructions = inviteLinkInstructions; } @@ -131,6 +134,15 @@ public ApproverGetCollection getApprovers() { return this.approvers; } + /** + * Returns the attributes. + * + * @return attributes. + */ + public AttributeGet getAttributes() { + return this.attributes; + } + /** * Returns the collection of invite link instructions. * diff --git a/src/main/java/com/signnow/api/template/response/data/AttributeGet.java b/src/main/java/com/signnow/api/template/response/data/AttributeGet.java new file mode 100644 index 0000000..fb10765 --- /dev/null +++ b/src/main/java/com/signnow/api/template/response/data/AttributeGet.java @@ -0,0 +1,116 @@ +/* + * 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.template.response.data; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.LinkedHashMap; +import java.util.Map; + +import com.signnow.core.data.ApiData; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; + +/** + * Represents the attributes for getting a template. + */ +public final class AttributeGet extends ApiData { + + /** + * Identifier of the associated brand. + */ + @JsonProperty("brand_id") + private final String brandId; + + /** + * URI to redirect the user to after completing an action. + */ + @JsonProperty("redirect_uri") + private final String redirectUri; + + /** + * Optional callback or action to perform when the process is complete. + */ + @JsonProperty("on_complete") + private final String onComplete; + + /** + * Constructs an instance of {@code AttributeGet}. + * + * @param brandId the brand ID + * @param redirectUri the redirect URI + * @param onComplete the on complete action + */ + @JsonCreator + public AttributeGet( + @JsonProperty("brand_id") String brandId, + @JsonProperty("redirect_uri") String redirectUri, + @JsonProperty("on_complete") String onComplete) { + this.brandId = brandId; + this.redirectUri = redirectUri; + this.onComplete = onComplete; + } + + /** + * Gets the brand ID. + * + * @return the brand ID + */ + public String getBrandId() { + return this.brandId; + } + + /** + * Gets the redirect URI. + * + * @return the redirect URI + */ + public String getRedirectUri() { + return this.redirectUri; + } + + /** + * Gets the on complete action. + * + * @return the on complete action + */ + public String getOnComplete() { + return this.onComplete; + } + + /** + * Converts the attributes to a map. + * + * @return a map representation of the attributes + */ + @NotNull + public Map toMap() { + Map map = new LinkedHashMap<>(); + map.put("brand_id", this.getBrandId()); + map.put("redirect_uri", this.getRedirectUri()); + map.put("on_complete", this.getOnComplete()); + return map; + } + + /** + * Creates an instance of {@code AttributeGet} from a map. + * + * @param data the map containing attribute data + * @return a new instance of {@code AttributeGet} + */ + @NotNull + @Contract("_ -> new") + public static AttributeGet fromMap(@NotNull Map data) { + return new AttributeGet( + (String) data.get("brand_id"), + (String) data.get("redirect_uri"), + (String) data.get("on_complete")); + } +} diff --git a/src/main/java/com/signnow/api/template/response/data/RoutingDetailGet.java b/src/main/java/com/signnow/api/template/response/data/RoutingDetailGet.java index 33688a4..b440060 100644 --- a/src/main/java/com/signnow/api/template/response/data/RoutingDetailGet.java +++ b/src/main/java/com/signnow/api/template/response/data/RoutingDetailGet.java @@ -22,12 +22,6 @@ */ public final class RoutingDetailGet extends ApiData { - /** - * Represents the role of the inviter. - */ - @JsonProperty("inviter_role") - private final boolean inviterRole; - /** * Represents the name of the user. */ @@ -40,18 +34,24 @@ public final class RoutingDetailGet extends ApiData { @JsonProperty("role_id") private final String roleId; - /** - * Represents the order of signing. - */ - @JsonProperty("signing_order") - private final int signingOrder; - /** * Represents the default email of the user. */ @JsonProperty("default_email") private final String defaultEmail; + /** + * Represents the role of the inviter. + */ + @JsonProperty("inviter_role") + private final boolean inviterRole; + + /** + * Represents the order of signing. + */ + @JsonProperty("signing_order") + private final int signingOrder; + /** * Represents if the signature can be declined. */ @@ -67,28 +67,28 @@ public final class RoutingDetailGet extends ApiData { /** * Constructor for the RoutingDetailGet class. * - * @param inviterRole The role of the inviter. * @param name The name of the user. * @param roleId The ID of the role. - * @param signingOrder The order of signing. * @param defaultEmail The default email of the user. + * @param inviterRole The role of the inviter. + * @param signingOrder The order of signing. * @param declineBySignature If the signature can be declined. * @param deliveryType The type of delivery. */ @JsonCreator public RoutingDetailGet( - @JsonProperty("inviter_role") boolean inviterRole, @JsonProperty("name") String name, @JsonProperty("role_id") String roleId, - @JsonProperty("signing_order") int signingOrder, @JsonProperty("default_email") String defaultEmail, + @JsonProperty("inviter_role") boolean inviterRole, + @JsonProperty("signing_order") int signingOrder, @JsonProperty("decline_by_signature") boolean declineBySignature, @JsonProperty("delivery_type") String deliveryType) { - this.inviterRole = inviterRole; this.name = name; this.roleId = roleId; - this.signingOrder = signingOrder; this.defaultEmail = defaultEmail; + this.inviterRole = inviterRole; + this.signingOrder = signingOrder; this.declineBySignature = declineBySignature; this.deliveryType = deliveryType; } @@ -151,11 +151,11 @@ public String getDeliveryType() { @Override public Map toMap() { Map map = new LinkedHashMap<>(); - map.put("inviter_role", this.isInviterRole()); map.put("name", this.getName()); map.put("role_id", this.getRoleId()); - map.put("signing_order", this.getSigningOrder()); map.put("default_email", this.getDefaultEmail()); + map.put("inviter_role", this.isInviterRole()); + map.put("signing_order", this.getSigningOrder()); map.put("decline_by_signature", this.isDeclineBySignature()); map.put("delivery_type", this.getDeliveryType()); return map; @@ -171,11 +171,11 @@ public Map toMap() { @Contract("_ -> new") public static RoutingDetailGet fromMap(@NotNull Map data) { return new RoutingDetailGet( - (boolean) data.getOrDefault("inviter_role", false), (String) data.get("name"), (String) data.get("role_id"), - (int) data.get("signing_order"), (String) data.getOrDefault("default_email", ""), + (boolean) data.getOrDefault("inviter_role", false), + (int) data.get("signing_order"), (boolean) data.getOrDefault("decline_by_signature", false), (String) data.get("delivery_type")); } diff --git a/src/main/java/com/signnow/api/template/response/data/ShareInfo.java b/src/main/java/com/signnow/api/template/response/data/ShareInfo.java new file mode 100644 index 0000000..77426eb --- /dev/null +++ b/src/main/java/com/signnow/api/template/response/data/ShareInfo.java @@ -0,0 +1,116 @@ +/* + * 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.template.response.data; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.LinkedHashMap; +import java.util.Map; + +import com.signnow.core.data.ApiData; +import org.jetbrains.annotations.Contract; +import org.jetbrains.annotations.NotNull; + +/** + * Represents the sharing information of a template. + */ +public final class ShareInfo extends ApiData { + + /** + * Indicates whether the document is shared with a team. + */ + @JsonProperty("is_team_shared") + private final boolean isTeamShared; + + /** + * The role assigned to the user for the document or resource. + */ + @JsonProperty("role") + private final String role; + + /** + * Indicates whether the document is personally shared with others by the user. + */ + @JsonProperty("is_personally_shared_to_others") + private final boolean isPersonallySharedToOthers; + + /** + * Constructs a new ShareInfo instance. + * + * @param isTeamShared Indicates if the template is shared with a team. + * @param role The role associated with the shared template. + * @param isPersonallySharedToOthers Indicates if the template is personally shared with others. + */ + @JsonCreator + public ShareInfo( + @JsonProperty("is_team_shared") boolean isTeamShared, + @JsonProperty("role") String role, + @JsonProperty("is_personally_shared_to_others") boolean isPersonallySharedToOthers) { + this.isTeamShared = isTeamShared; + this.role = role; + this.isPersonallySharedToOthers = isPersonallySharedToOthers; + } + + /** + * Checks if the template is shared with a team. + * + * @return true if the template is team shared, false otherwise. + */ + public boolean isTeamShared() { + return this.isTeamShared; + } + + /** + * Gets the role associated with the shared template. + * + * @return The role as a string. + */ + public String getRole() { + return this.role; + } + + /** + * Checks if the template is personally shared with others. + * + * @return true if the template is personally shared, false otherwise. + */ + public boolean isPersonallySharedToOthers() { + return this.isPersonallySharedToOthers; + } + + /** + * Converts the ShareInfo object to a map representation. + * + * @return A map containing the share information. + */ + @NotNull + public Map toMap() { + Map map = new LinkedHashMap<>(); + map.put("is_team_shared", this.isTeamShared()); + map.put("role", this.getRole()); + map.put("is_personally_shared_to_others", this.isPersonallySharedToOthers()); + return map; + } + + /** + * Creates a ShareInfo instance from a map. + * + * @param data The map containing share information. + * @return A new ShareInfo instance. + */ + @NotNull + @Contract("_ -> new") + public static ShareInfo fromMap(@NotNull Map data) { + return new ShareInfo( + (Boolean) data.getOrDefault("is_team_shared", false), + (String) data.getOrDefault("role", ""), + (Boolean) data.getOrDefault("is_personally_shared_to_others", false)); + } +} diff --git a/src/main/java/com/signnow/api/template/response/data/routingdetail/Authentication.java b/src/main/java/com/signnow/api/template/response/data/routingdetail/Authentication.java new file mode 100644 index 0000000..aa9d4e2 --- /dev/null +++ b/src/main/java/com/signnow/api/template/response/data/routingdetail/Authentication.java @@ -0,0 +1,73 @@ +/* + * 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.template.response.data.routingdetail; + +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 the authentication details in the routing process. + */ +public final class Authentication extends ApiData { + + /** + * Authentication type. + */ + @JsonProperty("type") + private final String type; + + /** + * Constructs an Authentication instance. + * + * @param type the type of authentication, can be null. + */ + @JsonCreator + public Authentication(@JsonProperty("type") String type) { + this.type = type; + } + + /** + * Gets the type of authentication. + * + * @return the type of authentication, can be null. + */ + public String getType() { + return this.type; + } + + /** + * Converts the authentication details to a map. + * + * @return a map representation of the authentication details. + */ + @NotNull + public Map toMap() { + Map map = new LinkedHashMap<>(); + map.put("type", this.getType()); + return map; + } + + /** + * Creates an Authentication instance from a map. + * + * @param data the map containing authentication details. + * @return a new Authentication instance. + */ + @NotNull + @Contract("_ -> new") + public static Authentication fromMap(@NotNull Map data) { + return new Authentication((String) data.getOrDefault("type", null)); + } +} diff --git a/src/main/java/com/signnow/api/template/response/data/routingdetail/InviteAction.java b/src/main/java/com/signnow/api/template/response/data/routingdetail/InviteAction.java new file mode 100644 index 0000000..6e2ef01 --- /dev/null +++ b/src/main/java/com/signnow/api/template/response/data/routingdetail/InviteAction.java @@ -0,0 +1,239 @@ +/* + * 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.template.response.data.routingdetail; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.signnow.core.data.ApiData; +import com.signnow.core.util.Cast; +import java.util.LinkedHashMap; +import java.util.Map; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Represents an invitation with details such as email, document information, and permissions. + */ +public final class InviteAction extends ApiData { + + /** + * Email address of the recipient or user. + */ + @JsonProperty("email") + private final String email; + + /** + * Identifier of the associated document. + */ + @JsonProperty("document_id") + private final String documentId; + + /** + * Name of the associated document. + */ + @JsonProperty("document_name") + private final String documentName; + + /** + * Indicates if reassignment is allowed (1 = allowed, 0 = not allowed). + */ + @JsonProperty("allow_reassign") + private final int allowReassign; + + /** + * Indicates if the document can be declined by signature (1 = yes, 0 = no). + */ + @JsonProperty("decline_by_signature") + private final int declineBySignature; + + /** + * Indicates whether the document is locked. + */ + @JsonProperty("lock") + private final boolean lock; + + /** + * Action assigned to the user (e.g., "sign", "view"). + */ + @JsonProperty("action") + private final String action; + + /** + * Name of the role assigned to the user in the document workflow. + */ + @JsonProperty("role_name") + private final String roleName; + + /** + * Authentication method required for accessing or signing the document. + */ + @JsonProperty("authentication") + private final Authentication authentication; + + /** + * Constructs an InviteAction with the specified details. + * + * @param email the email address associated with the invite + * @param documentId the ID of the document + * @param documentName the name of the document + * @param allowReassign the reassign permission + * @param declineBySignature the decline by signature permission + * @param lock the lock status + * @param action the action to be performed + * @param roleName the role name associated with the invite + * @param authentication the authentication details, if any + */ + @JsonCreator + public InviteAction( + @JsonProperty("email") String email, + @JsonProperty("document_id") String documentId, + @JsonProperty("document_name") String documentName, + @JsonProperty("allow_reassign") int allowReassign, + @JsonProperty("decline_by_signature") int declineBySignature, + @JsonProperty("lock") boolean lock, + @JsonProperty("action") String action, + @JsonProperty("role_name") String roleName, + @JsonProperty("authentication") @Nullable Authentication authentication) { + this.email = email; + this.documentId = documentId; + this.documentName = documentName; + this.allowReassign = allowReassign; + this.declineBySignature = declineBySignature; + this.lock = lock; + this.action = action; + this.roleName = roleName; + this.authentication = authentication; + } + + /** + * Gets the email address associated with the invite. + * + * @return the email address + */ + public String getEmail() { + return email; + } + + /** + * Gets the ID of the document. + * + * @return the document ID + */ + public String getDocumentId() { + return documentId; + } + + /** + * Gets the name of the document. + * + * @return the document name + */ + public String getDocumentName() { + return documentName; + } + + /** + * Gets the authentication details, if any. + * + * @return the authentication details or null if not present + */ + @Nullable + public Authentication getAuthentication() { + return this.authentication; + } + + /** + * Gets the reassign permission. + * + * @return the reassign permission + */ + public int getAllowReassign() { + return this.allowReassign; + } + + /** + * Gets the decline by signature permission. + * + * @return the decline by signature permission + */ + public int getDeclineBySignature() { + return this.declineBySignature; + } + + /** + * Checks if the invite is locked. + * + * @return true if locked, false otherwise + */ + public boolean isLock() { + return this.lock; + } + + /** + * Gets the action to be performed. + * + * @return the action + */ + public String getAction() { + return this.action; + } + + /** + * Gets the role name associated with the invite. + * + * @return the role name + */ + public String getRoleName() { + return this.roleName; + } + + /** + * Converts the invite action details to a map. + * + * @return a map representation of the invite action + */ + @NotNull + public Map toMap() { + Map map = new LinkedHashMap<>(); + map.put("email", this.getEmail()); + map.put("document_id", this.getDocumentId()); + map.put("document_name", this.getDocumentName()); + map.put("authentication", this.getAuthentication()); + map.put("allow_reassign", this.getAllowReassign()); + map.put("decline_by_signature", this.getDeclineBySignature()); + map.put("lock", this.isLock()); + map.put("action", this.getAction()); + map.put("role_name", this.getRoleName()); + return map; + } + + /** + * Creates an InviteAction from a map of data. + * + * @param data the map containing invite action details + * @return a new InviteAction instance + */ + @NotNull + public static InviteAction fromMap(@NotNull Map data) { + return new InviteAction( + (String) data.get("email"), + (String) data.get("document_id"), + (String) data.get("document_name"), + (int) data.get("allow_reassign"), + (int) data.get("decline_by_signature"), + (boolean) data.get("lock"), + (String) data.get("action"), + (String) data.get("role_name"), + data.containsKey("authentication") + ? Authentication.fromMap( + Cast.safeToMap(data.get("authentication"), String.class, Object.class)) + : null); + } +} diff --git a/src/main/java/com/signnow/api/template/response/data/routingdetail/InviteActionCollection.java b/src/main/java/com/signnow/api/template/response/data/routingdetail/InviteActionCollection.java new file mode 100644 index 0000000..4ffa24f --- /dev/null +++ b/src/main/java/com/signnow/api/template/response/data/routingdetail/InviteActionCollection.java @@ -0,0 +1,24 @@ +/* + * 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.template.response.data.routingdetail; + +import com.signnow.core.collection.TypedCollection; + +/** + * This class extends the TypedCollection class and is used to store a collection of InviteAction + * objects. It provides all the methods inherited from the TypedCollection class to manipulate the + * collection. + */ +public class InviteActionCollection extends TypedCollection { + /** Default constructor {@code InviteActionCollection}. */ + public InviteActionCollection() { + super(); + } +} diff --git a/src/main/java/com/signnow/api/template/response/data/routingdetail/InviteEmail.java b/src/main/java/com/signnow/api/template/response/data/routingdetail/InviteEmail.java new file mode 100644 index 0000000..1038cc4 --- /dev/null +++ b/src/main/java/com/signnow/api/template/response/data/routingdetail/InviteEmail.java @@ -0,0 +1,179 @@ +/* + * 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.template.response.data.routingdetail; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.signnow.core.data.ApiData; +import com.signnow.core.util.Cast; +import java.util.LinkedHashMap; +import java.util.Map; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * Represents an invitation email with details such as email, subject, message, expiration days, + * sign actions, and reminder. + */ +public final class InviteEmail extends ApiData { + + /** + * Email address of the recipient. + */ + @JsonProperty("email") + private final String email; + + /** + * Subject line of the message or notification. + */ + @JsonProperty("subject") + private final String subject; + + /** + * Body text of the message or custom note. + */ + @JsonProperty("message") + private final String message; + + /** + * Number of days before the document expires. + */ + @JsonProperty("expiration_days") + private final int expirationDays; + + /** + * Indicates whether the document has sign actions. + */ + @JsonProperty("has_sign_actions") + private final boolean hasSignActions; + + /** + * Reminder settings for the document or action. + */ + @JsonProperty("reminder") + private final Reminder reminder; + + /** + * Constructs an InviteEmail instance with the specified details. + * + * @param email the email address + * @param subject the subject of the email + * @param message the message content + * @param expirationDays the number of days until expiration + * @param hasSignActions whether the email has sign actions + * @param reminder the reminder details, can be null + */ + @JsonCreator + public InviteEmail( + @JsonProperty("email") String email, + @JsonProperty("subject") String subject, + @JsonProperty("message") String message, + @JsonProperty("expiration_days") int expirationDays, + @JsonProperty("has_sign_actions") boolean hasSignActions, + @JsonProperty("reminder") @Nullable Reminder reminder) { + this.email = email; + this.subject = subject; + this.message = message; + this.expirationDays = expirationDays; + this.hasSignActions = hasSignActions; + this.reminder = reminder; + } + + /** + * Gets the email address. + * + * @return the email address + */ + public String getEmail() { + return this.email; + } + + /** + * Gets the subject of the email. + * + * @return the subject + */ + public String getSubject() { + return this.subject; + } + + /** + * Gets the message content. + * + * @return the message + */ + public String getMessage() { + return this.message; + } + + /** + * Gets the reminder details. + * + * @return the reminder, can be null + */ + @Nullable + public Reminder getReminder() { + return this.reminder; + } + + /** + * Gets the number of days until expiration. + * + * @return the expiration days + */ + public int getExpirationDays() { + return this.expirationDays; + } + + /** + * Checks if the email has sign actions. + * + * @return true if it has sign actions, false otherwise + */ + public boolean hasSignActions() { + return this.hasSignActions; + } + + /** + * Converts the invite email details to a map representation. + * + * @return a map containing the invite email details + */ + @NotNull + public Map toMap() { + Map map = new LinkedHashMap<>(); + map.put("email", this.getEmail()); + map.put("subject", this.getSubject()); + map.put("message", this.getMessage()); + map.put("reminder", reminder != null ? reminder.toMap() : null); + map.put("expiration_days", this.getExpirationDays()); + map.put("has_sign_actions", this.hasSignActions()); + return map; + } + + /** + * Creates an InviteEmail instance from a map representation. + * + * @param data the map containing invite email details + * @return an InviteEmail instance + */ + @NotNull + public static InviteEmail fromMap(@NotNull Map data) { + return new InviteEmail( + (String) data.get("email"), + (String) data.get("subject"), + (String) data.get("message"), + (int) data.get("expiration_days"), + (boolean) data.get("has_sign_actions"), + data.containsKey("reminder") + ? Reminder.fromMap(Cast.safeToMap(data.get("reminder"), String.class, Integer.class)) + : null); + } +} diff --git a/src/main/java/com/signnow/api/template/response/data/routingdetail/InviteEmailCollection.java b/src/main/java/com/signnow/api/template/response/data/routingdetail/InviteEmailCollection.java new file mode 100644 index 0000000..7b558cf --- /dev/null +++ b/src/main/java/com/signnow/api/template/response/data/routingdetail/InviteEmailCollection.java @@ -0,0 +1,24 @@ +/* + * 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.template.response.data.routingdetail; + +import com.signnow.core.collection.TypedCollection; + +/** + * A collection of InviteEmail objects. Extends the TypedCollection class to provide type safety for + * InviteEmail objects. + */ +public class InviteEmailCollection extends TypedCollection { + + /** Constructs an InviteEmailCollection. */ + public InviteEmailCollection() { + super(); + } +} diff --git a/src/main/java/com/signnow/api/template/response/data/routingdetail/InviteStep.java b/src/main/java/com/signnow/api/template/response/data/routingdetail/InviteStep.java new file mode 100644 index 0000000..1d623ac --- /dev/null +++ b/src/main/java/com/signnow/api/template/response/data/routingdetail/InviteStep.java @@ -0,0 +1,113 @@ +/* + * 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.template.response.data.routingdetail; + +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 an invitation step in the routing detail. */ +public final class InviteStep extends ApiData { + + /** + * The order or sequence number of the invitation step. + */ + @JsonProperty("order") + private final int order; + + /** + * Collection of actions assigned to the invitees. + */ + @JsonProperty("invite_actions") + private final InviteActionCollection inviteActions; + + /** + * Collection of emails to be invited. + */ + @JsonProperty("invite_emails") + private final InviteEmailCollection inviteEmails; + + /** + * Constructs an InviteStep with the specified order, invite actions, and invite emails. + * + * @param order the order of the invite step + * @param inviteActions the collection of invite actions + * @param inviteEmails the collection of invite emails + */ + @JsonCreator + public InviteStep( + @JsonProperty("order") int order, + @JsonProperty("invite_actions") InviteActionCollection inviteActions, + @JsonProperty("invite_emails") InviteEmailCollection inviteEmails) { + this.order = order; + this.inviteActions = inviteActions; + this.inviteEmails = inviteEmails; + } + + /** + * Returns the order of the invite step. + * + * @return the order + */ + public int getOrder() { + return order; + } + + /** + * Returns the collection of invite emails. + * + * @return the invite emails + */ + public InviteEmailCollection getInviteEmails() { + return inviteEmails; + } + + /** + * Returns the collection of invite actions. + * + * @return the invite actions + */ + public InviteActionCollection getInviteActions() { + return inviteActions; + } + + /** + * Converts the invite step to a map representation. + * + * @return a map containing the invite step data + */ + @NotNull + public Map toMap() { + Map map = new LinkedHashMap<>(); + map.put("order", this.getOrder()); + map.put("invite_emails", this.getInviteEmails()); + map.put("invite_actions", this.getInviteActions()); + return map; + } + + /** + * Creates an InviteStep from a map representation. + * + * @param data the map containing the invite step data + * @return a new InviteStep instance + */ + @NotNull + @Contract("_ -> new") + public static InviteStep fromMap(@NotNull Map data) { + return new InviteStep( + (int) data.get("order"), + (InviteActionCollection) data.get("invite_actions"), + (InviteEmailCollection) data.get("invite_emails")); + } +} diff --git a/src/main/java/com/signnow/api/template/response/data/routingdetail/InviteStepCollection.java b/src/main/java/com/signnow/api/template/response/data/routingdetail/InviteStepCollection.java new file mode 100644 index 0000000..05e9121 --- /dev/null +++ b/src/main/java/com/signnow/api/template/response/data/routingdetail/InviteStepCollection.java @@ -0,0 +1,24 @@ +/* + * 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.template.response.data.routingdetail; + +import com.signnow.core.collection.TypedCollection; + +/** + * Represents a collection of InviteStep elements. This class extends TypedCollection with + * InviteStep as the generic type. + */ +public class InviteStepCollection extends TypedCollection { + + /** Constructs an InviteStepCollection. */ + public InviteStepCollection() { + super(); + } +} diff --git a/src/main/java/com/signnow/api/template/response/data/routingdetail/Reminder.java b/src/main/java/com/signnow/api/template/response/data/routingdetail/Reminder.java new file mode 100644 index 0000000..a5c950e --- /dev/null +++ b/src/main/java/com/signnow/api/template/response/data/routingdetail/Reminder.java @@ -0,0 +1,113 @@ +/* + * 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.template.response.data.routingdetail; + +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 reminder with specific timing details. */ +public final class Reminder extends ApiData { + + /** + * Number of days after the invite, a recipient gets a reminder email. + */ + @JsonProperty("remind_after") + private final int remindAfter; + + /** + * Number of days before the invite, a recipient gets a reminder email. + */ + @JsonProperty("remind_before") + private final int remindBefore; + + /** + * Number of days recipient gets repetitive a reminder email after the invite is sent. + */ + @JsonProperty("remind_repeat") + private final int remindRepeat; + + /** + * Constructs a Reminder with specified timing details. + * + * @param remindAfter the time after which to remind + * @param remindBefore the time before which to remind + * @param remindRepeat the repeat interval for reminders + */ + @JsonCreator + public Reminder( + @JsonProperty("remind_after") int remindAfter, + @JsonProperty("remind_before") int remindBefore, + @JsonProperty("remind_repeat") int remindRepeat) { + this.remindAfter = remindAfter; + this.remindBefore = remindBefore; + this.remindRepeat = remindRepeat; + } + + /** + * Gets the time after which to remind. + * + * @return the reminder after time + */ + public int getRemindAfter() { + return remindAfter; + } + + /** + * Gets the time before which to remind. + * + * @return the reminder before time + */ + public int getRemindBefore() { + return remindBefore; + } + + /** + * Gets the repeat interval for reminders. + * + * @return the reminder repeat interval + */ + public int getRemindRepeat() { + return remindRepeat; + } + + /** + * Converts the reminder details to a map. + * + * @return a map representation of the reminder + */ + @NotNull + public Map toMap() { + Map map = new LinkedHashMap<>(); + map.put("remind_after", getRemindAfter()); + map.put("remind_before", getRemindBefore()); + map.put("remind_repeat", getRemindRepeat()); + return map; + } + + /** + * Creates a Reminder from a map of data. + * + * @param data the map containing reminder details + * @return a new Reminder instance + */ + @NotNull + @Contract("_ -> new") + public static Reminder fromMap(@NotNull Map data) { + return new Reminder( + data.getOrDefault("remind_after", 0), + data.getOrDefault("remind_before", 0), + data.getOrDefault("remind_repeat", 0)); + } +} diff --git a/src/main/java/com/signnow/api/template/response/data/routingdetail/RoutingDetail.java b/src/main/java/com/signnow/api/template/response/data/routingdetail/RoutingDetail.java new file mode 100644 index 0000000..104fcbc --- /dev/null +++ b/src/main/java/com/signnow/api/template/response/data/routingdetail/RoutingDetail.java @@ -0,0 +1,104 @@ +/* + * 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.template.response.data.routingdetail; + +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 the routing detail for a template. */ +public final class RoutingDetail extends ApiData { + + @JsonProperty("sign_as_merged") + private final boolean signAsMerged; + + @JsonProperty("invite_steps") + private final InviteStepCollection inviteSteps; + + @JsonProperty("include_email_attachments") + private final String includeEmailAttachments; + + /** + * Constructs a new RoutingDetail instance. + * + * @param signAsMerged Indicates if the sign is merged. + * @param inviteSteps The collection of invite steps. + * @param includeEmailAttachments Optional email attachments to include. + */ + @JsonCreator + public RoutingDetail( + @JsonProperty("sign_as_merged") boolean signAsMerged, + @JsonProperty("invite_steps") InviteStepCollection inviteSteps, + @JsonProperty("include_email_attachments") String includeEmailAttachments) { + this.signAsMerged = signAsMerged; + this.inviteSteps = inviteSteps; + this.includeEmailAttachments = includeEmailAttachments; + } + + /** + * Checks if the sign is merged. + * + * @return true if the sign is merged, false otherwise. + */ + public boolean isSignAsMerged() { + return this.signAsMerged; + } + + /** + * Gets the email attachments to include. + * + * @return The email attachments, or null if not set. + */ + public String getIncludeEmailAttachments() { + return this.includeEmailAttachments; + } + + /** + * Gets the collection of invite steps. + * + * @return The invite steps collection. + */ + public InviteStepCollection getInviteSteps() { + return this.inviteSteps; + } + + /** + * Converts the routing detail to a map representation. + * + * @return A map containing the routing detail data. + */ + @NotNull + public Map toMap() { + Map map = new LinkedHashMap<>(); + map.put("sign_as_merged", this.isSignAsMerged()); + map.put("include_email_attachments", this.getIncludeEmailAttachments()); + map.put("invite_steps", this.getInviteSteps().toMap()); + return map; + } + + /** + * Creates a RoutingDetail instance from a map. + * + * @param data The map containing routing detail data. + * @return A new RoutingDetail instance. + */ + @NotNull + @Contract("_ -> new") + public static RoutingDetail fromMap(@NotNull Map data) { + return new RoutingDetail( + (Boolean) data.get("sign_as_merged"), + (InviteStepCollection) data.get("invite_steps"), + (String) data.get("include_email_attachments")); + } +} diff --git a/src/main/java/com/signnow/api/template/response/data/template/RoleCollection.java b/src/main/java/com/signnow/api/template/response/data/template/RoleCollection.java new file mode 100644 index 0000000..af8ed45 --- /dev/null +++ b/src/main/java/com/signnow/api/template/response/data/template/RoleCollection.java @@ -0,0 +1,18 @@ +/* + * 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.template.response.data.template; + +import com.signnow.core.collection.StringCollection; + +/** + * Represents a collection of roles. + * Extends the functionality of {@link StringCollection}. + */ +public class RoleCollection extends StringCollection {} diff --git a/src/main/java/com/signnow/api/template/response/data/template/Template.java b/src/main/java/com/signnow/api/template/response/data/template/Template.java new file mode 100644 index 0000000..9bad3e6 --- /dev/null +++ b/src/main/java/com/signnow/api/template/response/data/template/Template.java @@ -0,0 +1,174 @@ +/* + * 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.template.response.data.template; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.signnow.core.data.ApiData; +import com.signnow.core.util.Cast; +import java.util.LinkedHashMap; +import java.util.Map; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** Represents a Template with roles, name, id, owner email, thumbnail, and readability status. */ +public final class Template extends ApiData { + + /** + * Collection of roles defined in the template. + */ + @JsonProperty("roles") + private final RoleCollection roles; + + /** + * Name of the template. + */ + @JsonProperty("template_name") + private final String templateName; + + /** + * Unique identifier of the template. + */ + @JsonProperty("id") + private final String id; + + /** + * Email address of the template owner. + */ + @JsonProperty("owner_email") + private final String ownerEmail; + + /** + * Thumbnail image representing the template. + */ + @JsonProperty("thumbnail") + private final Thumbnail thumbnail; + + /** + * Indicates whether the current user has read access to the template. + */ + @JsonProperty("readable") + private final Boolean readable; + + /** + * Constructs a new Template instance. + * + * @param roles the collection of roles associated with the template + * @param templateName the name of the template + * @param id the unique identifier of the template + * @param ownerEmail the email of the template owner + * @param thumbnail the thumbnail associated with the template + * @param readable the readability status of the template + */ + @JsonCreator + public Template( + @JsonProperty("roles") RoleCollection roles, + @JsonProperty("template_name") String templateName, + @JsonProperty("id") String id, + @JsonProperty("owner_email") String ownerEmail, + @JsonProperty("thumbnail") Thumbnail thumbnail, + @JsonProperty("readable") @Nullable Boolean readable) { + this.roles = roles; + this.templateName = templateName; + this.id = id; + this.ownerEmail = ownerEmail; + this.thumbnail = thumbnail; + this.readable = readable; + } + + /** + * Gets the roles associated with the template. + * + * @return the roles + */ + public RoleCollection getRoles() { + return this.roles; + } + + /** + * Gets the name of the template. + * + * @return the template name + */ + public String getTemplateName() { + return this.templateName; + } + + /** + * Gets the unique identifier of the template. + * + * @return the template id + */ + public String getId() { + return this.id; + } + + /** + * Gets the email of the template owner. + * + * @return the owner email + */ + public String getOwnerEmail() { + return this.ownerEmail; + } + + /** + * Gets the thumbnail associated with the template. + * + * @return the thumbnail + */ + public Thumbnail getThumbnail() { + return this.thumbnail; + } + + /** + * Checks if the template is readable. + * + * @return the readability status + */ + @Nullable + public Boolean isReadable() { + return this.readable; + } + + /** + * Converts the template to a map representation. + * + * @return a map containing the template data + */ + @NotNull + public Map toMap() { + Map map = new LinkedHashMap<>(); + map.put("roles", this.getRoles()); + map.put("template_name", this.getTemplateName()); + map.put("id", this.getId()); + map.put("owner_email", this.getOwnerEmail()); + map.put("thumbnail", this.getThumbnail().toMap()); + map.put("readable", this.isReadable()); + return map; + } + + /** + * Creates a Template instance from a map representation. + * + * @param data the map containing the template data + * @return a new Template instance + */ + @NotNull + public static Template fromMap(@NotNull Map data) { + return new Template( + (RoleCollection) data.get("roles"), + (String) data.get("template_name"), + (String) data.get("id"), + (String) data.get("owner_email"), + Thumbnail.fromMap(Cast.safeToMap(data.get("thumbnail"), String.class, Object.class)), + (Boolean) data.getOrDefault("readable", null)); + } +} diff --git a/src/main/java/com/signnow/api/template/response/data/template/TemplateCollection.java b/src/main/java/com/signnow/api/template/response/data/template/TemplateCollection.java new file mode 100644 index 0000000..4bf1fd5 --- /dev/null +++ b/src/main/java/com/signnow/api/template/response/data/template/TemplateCollection.java @@ -0,0 +1,24 @@ +/* + * 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.template.response.data.template; + +import com.signnow.core.collection.TypedCollection; + +/** + * Represents a collection of Template objects. This class extends TypedCollection with Template as + * the generic type. + */ +public class TemplateCollection extends TypedCollection