001package com.box.sdk; 002 003import com.box.sdk.internal.utils.JsonUtils; 004import com.eclipsesource.json.JsonArray; 005import com.eclipsesource.json.JsonObject; 006import java.util.List; 007 008/** 009 * Optional parameters for creating a Sign Request. 010 * 011 * @see BoxSignRequest 012 */ 013public class BoxSignRequestCreateParams { 014 015 private Boolean isDocumentPreparationNeeded; 016 private Boolean areTextSignaturesEnabled; 017 private Boolean areDatesEnabled; 018 private BoxSignRequestSignatureColor signatureColor; 019 private String emailSubject; 020 private String emailMessage; 021 private Boolean areRemindersEnabled; 022 private String name; 023 private List<BoxSignRequestPrefillTag> prefillTags; 024 private Integer daysValid; 025 private String externalId; 026 027 /** 028 * Gets the flag indicating if the sender should be taken into the builder flow to prepare the document. 029 * 030 * @return true if document preparation is needed, otherwise false. 031 */ 032 public boolean getIsDocumentPreparationNeeded() { 033 return this.isDocumentPreparationNeeded; 034 } 035 036 /** 037 * Sets the flag indicating if the sender should be taken into the builder flow to prepare the document. 038 * 039 * @param isDocumentPreparationNeeded whether or not sender should be taken 040 * into the builder flow to prepare the document. 041 * @return this BoxSignRequestCreateParams object for chaining. 042 */ 043 public BoxSignRequestCreateParams setIsDocumentPreparationNeeded(boolean isDocumentPreparationNeeded) { 044 this.isDocumentPreparationNeeded = isDocumentPreparationNeeded; 045 return this; 046 } 047 048 /** 049 * Gets the flag indicating if usage of signatures generated by typing (text) is enabled. Default is true. 050 * 051 * @return true if text signatures are enabled, otherwise false. 052 */ 053 public boolean getAreTextSignaturesEnabled() { 054 return this.areTextSignaturesEnabled; 055 } 056 057 /** 058 * Sets the flag indicating if usage of signatures generated by typing (text) is enabled. Default is true. 059 * 060 * @param areTextSignaturesEnabled indicating if text signatures are enabled for signers. 061 * @return this BoxSignRequestCreateParams object for chaining. 062 */ 063 public BoxSignRequestCreateParams setAreTextSignaturesEnabled(boolean areTextSignaturesEnabled) { 064 this.areTextSignaturesEnabled = areTextSignaturesEnabled; 065 return this; 066 } 067 068 /** 069 * Gets the flag indicating if ability for signer to add dates is enabled. Default is true. 070 * 071 * @return true if ability for signer to add dates is enabled, otherwise false. 072 */ 073 public boolean getAreDatesEnabled() { 074 return this.areDatesEnabled; 075 } 076 077 /** 078 * Sets the flag indicating if ability for signer to add dates is enabled. Default is true. 079 * 080 * @param areDatesEnabled indicating if ability for signer to add dates is enabled. 081 * @return this BoxSignRequestCreateParams object for chaining. 082 */ 083 public BoxSignRequestCreateParams setAreDatesEnabled(boolean areDatesEnabled) { 084 this.areDatesEnabled = areDatesEnabled; 085 return this; 086 } 087 088 /** 089 * Gets the forced, specific color for the signature. 090 * 091 * @return signature color (blue, black, red). 092 */ 093 public BoxSignRequestSignatureColor getSignatureColor() { 094 return this.signatureColor; 095 } 096 097 /** 098 * Sets the forced, specific color for the signature. 099 * 100 * @param signatureColor blue, black or red. 101 * @return this BoxSignRequestCreateParams object for chaining. 102 */ 103 public BoxSignRequestCreateParams setSignatureColor(BoxSignRequestSignatureColor signatureColor) { 104 this.signatureColor = signatureColor; 105 return this; 106 } 107 108 /** 109 * Gets the subject of sign request email. 110 * 111 * @return subject of sign request email. 112 */ 113 public String getEmailSubject() { 114 return this.emailSubject; 115 } 116 117 /** 118 * Sets the subject of sign request email. This is cleaned by sign request. 119 * 120 * @param emailSubject included in sign request email. 121 * @return this BoxSignRequestCreateParams object for chaining. 122 */ 123 public BoxSignRequestCreateParams setEmailSubject(String emailSubject) { 124 this.emailSubject = emailSubject; 125 return this; 126 } 127 128 /** 129 * Gets the message to include in sign request email. 130 * 131 * @return message of sign request email. 132 */ 133 public String getEmailMessage() { 134 return this.emailMessage; 135 } 136 137 /** 138 * Sets the message to include in sign request email. This is cleaned,but some html tags are allowed. 139 * Links included in the message are also converted to actual links in the email. 140 * The message may contain the following html tags: 141 * a, abbr, acronym, b, blockquote, code, em, i, ul, li, ol, and strong. 142 * Be aware that when the text to html ratio is too high, the email may end up in spam filters. 143 * Custom styles on these tags are not allowed. 144 * 145 * @param emailMessage included in sign request email. 146 * @return this BoxSignRequestCreateParams object for chaining. 147 */ 148 public BoxSignRequestCreateParams setEmailMessage(String emailMessage) { 149 this.emailMessage = emailMessage; 150 return this; 151 } 152 153 /** 154 * Gets the flag indicating if remind for signers to sign a document on day 3, 8, 13 and 18 155 * (or less if the document has been digitally signed already) is enabled. 156 * 157 * @return true if reminders are enabled, otherwise false. 158 */ 159 public boolean getAreRemindersEnabled() { 160 return this.areRemindersEnabled; 161 } 162 163 /** 164 * Sets the flag indicating if remind for signers to sign a document on day 3, 8, 13 and 18 165 * (or less if the document has been digitally signed already) is enabled. 166 * 167 * @param areRemindersEnabled indicating if reminders are enabled. 168 * @return this BoxSignRequestCreateParams object for chaining. 169 */ 170 public BoxSignRequestCreateParams setAreRemindersEnabled(boolean areRemindersEnabled) { 171 this.areRemindersEnabled = areRemindersEnabled; 172 return this; 173 } 174 175 /** 176 * Gets the name of this sign request. 177 * 178 * @return name of this sign request. 179 */ 180 public String getName() { 181 return this.name; 182 } 183 184 /** 185 * Sets the name of this sign request. 186 * 187 * @param name of this sign request. 188 * @return this BoxSignRequestCreateParams object for chaining. 189 */ 190 public BoxSignRequestCreateParams setName(String name) { 191 this.name = name; 192 return this; 193 } 194 195 /** 196 * Gets the number of days after which this request will automatically expire if not completed. 197 * 198 * @return number of days after which this request will automatically expire if not completed. 199 */ 200 public int getDaysValid() { 201 return this.daysValid; 202 } 203 204 /** 205 * Sets the number of days after which this request will automatically expire if not completed. 206 * 207 * @param daysValid of this sign request. 208 * @return this BoxSignRequestCreateParams object for chaining. 209 */ 210 public BoxSignRequestCreateParams setDaysValid(int daysValid) { 211 this.daysValid = daysValid; 212 return this; 213 } 214 215 /** 216 * Gets an ID that serve as reference in an external system that the sign request is related to. 217 * 218 * @return external id. 219 */ 220 public String getExternalId() { 221 return this.externalId; 222 } 223 224 /** 225 * Sets the reference id in an external system that this sign request is related to. 226 * 227 * @param externalId of this sign request. 228 * @return this BoxSignRequestCreateParams object for chaining. 229 */ 230 public BoxSignRequestCreateParams setExternalId(String externalId) { 231 this.externalId = externalId; 232 return this; 233 } 234 235 /** 236 * Gets the list of prefill tags. 237 * 238 * @return list of prefill tags. 239 */ 240 public List<BoxSignRequestPrefillTag> getPrefillTags() { 241 return this.prefillTags; 242 } 243 244 /** 245 * Sets the list of prefill tags. When a document contains sign related tags in the content, 246 * you can prefill them using this prefillTags by referencing 247 * the 'id' of the tag as the externalId field of the prefill tag. 248 * 249 * @param prefillTags list for this sign request. 250 * @return this BoxSignRequestCreateParams object for chaining. 251 */ 252 public BoxSignRequestCreateParams setPrefillTags(List<BoxSignRequestPrefillTag> prefillTags) { 253 this.prefillTags = prefillTags; 254 return this; 255 } 256 257 /** 258 * Used to append BoxSignRequestCreateParams to request. 259 * 260 * @param requestJSON request in json to append data to. 261 */ 262 public void appendParamsAsJson(JsonObject requestJSON) { 263 JsonUtils.addIfNotNull(requestJSON, "is_document_preparation_needed", 264 this.isDocumentPreparationNeeded); 265 JsonUtils.addIfNotNull(requestJSON, "are_text_signatures_enabled", this.areTextSignaturesEnabled); 266 JsonUtils.addIfNotNull(requestJSON, "are_dates_enabled", this.areDatesEnabled); 267 JsonUtils.addIfNotNull(requestJSON, "signature_color", this.signatureColor); 268 JsonUtils.addIfNotNull(requestJSON, "email_subject", this.emailSubject); 269 JsonUtils.addIfNotNull(requestJSON, "email_message", this.emailMessage); 270 JsonUtils.addIfNotNull(requestJSON, "are_reminders_enabled", this.areRemindersEnabled); 271 JsonUtils.addIfNotNull(requestJSON, "name", this.name); 272 JsonUtils.addIfNotNull(requestJSON, "days_valid", this.daysValid); 273 JsonUtils.addIfNotNull(requestJSON, "external_id", this.externalId); 274 275 if (this.prefillTags != null) { 276 JsonArray prefillTagsJSON = new JsonArray(); 277 for (BoxSignRequestPrefillTag prefillTag : this.prefillTags) { 278 prefillTagsJSON.add(prefillTag.getJSONObject()); 279 } 280 requestJSON.add("prefill_tags", prefillTagsJSON); 281 } 282 283 return; 284 } 285}