|
| 1 | +/* |
| 2 | + * This file is a part of signNow SDK API client. |
| 3 | + * |
| 4 | + * (с) Copyright © 2011-present airSlate Inc. (https://www.signnow.com) |
| 5 | + * |
| 6 | + * For more details on copyright, see LICENSE.md file |
| 7 | + * that was distributed with this source code. |
| 8 | + */ |
| 9 | + |
| 10 | +package com.signnow.api.embeddededitor.request; |
| 11 | + |
| 12 | +import com.signnow.core.request.ApiEndpoint; |
| 13 | +import com.signnow.core.request.RequestInterface; |
| 14 | +import java.util.HashMap; |
| 15 | +import java.util.Map; |
| 16 | +import org.jetbrains.annotations.Contract; |
| 17 | +import org.jetbrains.annotations.NotNull; |
| 18 | + |
| 19 | +/** |
| 20 | + * This class represents a request to create a link to embedded document group editor. It implements |
| 21 | + * the RequestInterface with Object as the type parameter. |
| 22 | + */ |
| 23 | +@ApiEndpoint( |
| 24 | + name = "createDocumentGroupEmbeddedEditorLink", |
| 25 | + url = "/v2/document-groups/{document_group_id}/embedded-editor", |
| 26 | + method = "post", |
| 27 | + auth = "bearer", |
| 28 | + namespace = "embeddedEditor", |
| 29 | + entity = "documentGroupEmbeddedEditorLink", |
| 30 | + type = "application/json") |
| 31 | +public final class DocumentGroupEmbeddedEditorLinkPostRequest implements RequestInterface<Object> { |
| 32 | + |
| 33 | + /** Optional: link that opens after the user has completed editing the document group. */ |
| 34 | + private final String redirectUri; |
| 35 | + |
| 36 | + /** |
| 37 | + * Determines whether to open the redirect link in the new tab in the browser, or in the same tab |
| 38 | + * after the signing session. Possible values: blank - opens the link in the new tab, self - opens |
| 39 | + * the link in the same tab, default value. |
| 40 | + */ |
| 41 | + private final String redirectTarget; |
| 42 | + |
| 43 | + /** |
| 44 | + * Link expiration time in minutes. By default, 15 minutes. Can be set max to 43200 minutes by a |
| 45 | + * user with Admin level of access. |
| 46 | + */ |
| 47 | + private final int linkExpiration; |
| 48 | + |
| 49 | + /** A HashMap to store the URI parameters for the request. */ |
| 50 | + private final HashMap<String, String> uriParams = new HashMap<>(); |
| 51 | + |
| 52 | + /** |
| 53 | + * Constructor for DocumentEmbeddedEditorLinkRequest. |
| 54 | + * |
| 55 | + * @param redirectUri Link that opens after the user has completed editing the document group. |
| 56 | + * @param redirectTarget Determines on what browser's tab should be opened the redirectUri. |
| 57 | + * @param linkExpiration Link expiration time in minutes. |
| 58 | + */ |
| 59 | + public DocumentGroupEmbeddedEditorLinkPostRequest( |
| 60 | + String redirectUri, String redirectTarget, int linkExpiration) { |
| 61 | + this.redirectUri = redirectUri; |
| 62 | + this.redirectTarget = redirectTarget; |
| 63 | + this.linkExpiration = linkExpiration; |
| 64 | + } |
| 65 | + |
| 66 | + /** |
| 67 | + * Link that opens after the user has completed editing the document group. |
| 68 | + * |
| 69 | + * @return String Link that opens after the user has completed editing the document group. |
| 70 | + */ |
| 71 | + public String getRedirectUri() { |
| 72 | + return this.redirectUri; |
| 73 | + } |
| 74 | + |
| 75 | + /** |
| 76 | + * Determines on what browser's tab should be opened the redirectUri. |
| 77 | + * |
| 78 | + * @return String Determines on what browser's tab should be opened the redirectUri. |
| 79 | + */ |
| 80 | + public String getRedirectTarget() { |
| 81 | + return this.redirectTarget; |
| 82 | + } |
| 83 | + |
| 84 | + /** |
| 85 | + * Link expiration time in minutes. |
| 86 | + * |
| 87 | + * @return int Link expiration time in minutes. |
| 88 | + */ |
| 89 | + public int getLinkExpiration() { |
| 90 | + return this.linkExpiration; |
| 91 | + } |
| 92 | + |
| 93 | + /** |
| 94 | + * Method to add a document group ID to the URI parameters. |
| 95 | + * |
| 96 | + * @param documentGroupId The ID of the document group to be edited as embedded one. |
| 97 | + * @return The current DocumentGroupEmbeddedEditorLinkPostRequest instance. |
| 98 | + */ |
| 99 | + public DocumentGroupEmbeddedEditorLinkPostRequest withDocumentGroupId(String documentGroupId) { |
| 100 | + this.uriParams.put("document_group_id", documentGroupId); |
| 101 | + return this; |
| 102 | + } |
| 103 | + |
| 104 | + /** |
| 105 | + * This method is used to get the URI parameters for the request. |
| 106 | + * |
| 107 | + * @return a new HashMap containing URI parameters |
| 108 | + */ |
| 109 | + @NotNull |
| 110 | + @Contract(value = " -> new", pure = true) |
| 111 | + @Override |
| 112 | + public HashMap<String, String> uriParams() { |
| 113 | + return new HashMap<>(this.uriParams); |
| 114 | + } |
| 115 | + |
| 116 | + /** |
| 117 | + * Returns a Map containing the payload for the request. |
| 118 | + * |
| 119 | + * @return a Map containing the payload for the request |
| 120 | + */ |
| 121 | + @NotNull |
| 122 | + public Map<String, Object> payload() { |
| 123 | + Map<String, Object> map = new HashMap<>(); |
| 124 | + map.put("redirect_uri", this.getRedirectUri()); |
| 125 | + map.put("redirect_target", this.getRedirectTarget()); |
| 126 | + map.put("link_expiration", this.getLinkExpiration()); |
| 127 | + return map; |
| 128 | + } |
| 129 | +} |
0 commit comments