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  private String redirectUrl;
027  private String declinedRedirectUrl;
028  private String templateId;
029
030  /**
031   * Gets the flag indicating if the sender should be taken into the builder flow to prepare the
032   * document.
033   *
034   * @return true if document preparation is needed, otherwise false.
035   */
036  public boolean getIsDocumentPreparationNeeded() {
037    return this.isDocumentPreparationNeeded;
038  }
039
040  /**
041   * Sets the flag indicating if the sender should be taken into the builder flow to prepare the
042   * document.
043   *
044   * @param isDocumentPreparationNeeded whether or not sender should be taken into the builder flow
045   *     to prepare the document.
046   * @return this BoxSignRequestCreateParams object for chaining.
047   */
048  public BoxSignRequestCreateParams setIsDocumentPreparationNeeded(
049      boolean isDocumentPreparationNeeded) {
050    this.isDocumentPreparationNeeded = isDocumentPreparationNeeded;
051    return this;
052  }
053
054  /**
055   * Gets the flag indicating if usage of signatures generated by typing (text) is enabled. Default
056   * is true.
057   *
058   * @return true if text signatures are enabled, otherwise false.
059   */
060  public boolean getAreTextSignaturesEnabled() {
061    return this.areTextSignaturesEnabled;
062  }
063
064  /**
065   * Sets the flag indicating if usage of signatures generated by typing (text) is enabled. Default
066   * is true.
067   *
068   * @param areTextSignaturesEnabled indicating if text signatures are enabled for signers.
069   * @return this BoxSignRequestCreateParams object for chaining.
070   */
071  public BoxSignRequestCreateParams setAreTextSignaturesEnabled(boolean areTextSignaturesEnabled) {
072    this.areTextSignaturesEnabled = areTextSignaturesEnabled;
073    return this;
074  }
075
076  /**
077   * Gets the flag indicating if ability for signer to add dates is enabled. Default is true.
078   *
079   * @return true if ability for signer to add dates is enabled, otherwise false.
080   */
081  public boolean getAreDatesEnabled() {
082    return this.areDatesEnabled;
083  }
084
085  /**
086   * Sets the flag indicating if ability for signer to add dates is enabled. Default is true.
087   *
088   * @param areDatesEnabled indicating if ability for signer to add dates is enabled.
089   * @return this BoxSignRequestCreateParams object for chaining.
090   */
091  public BoxSignRequestCreateParams setAreDatesEnabled(boolean areDatesEnabled) {
092    this.areDatesEnabled = areDatesEnabled;
093    return this;
094  }
095
096  /**
097   * Gets the forced, specific color for the signature.
098   *
099   * @return signature color (blue, black, red).
100   */
101  public BoxSignRequestSignatureColor getSignatureColor() {
102    return this.signatureColor;
103  }
104
105  /**
106   * Sets the forced, specific color for the signature.
107   *
108   * @param signatureColor blue, black or red.
109   * @return this BoxSignRequestCreateParams object for chaining.
110   */
111  public BoxSignRequestCreateParams setSignatureColor(BoxSignRequestSignatureColor signatureColor) {
112    this.signatureColor = signatureColor;
113    return this;
114  }
115
116  /**
117   * Gets the subject of sign request email.
118   *
119   * @return subject of sign request email.
120   */
121  public String getEmailSubject() {
122    return this.emailSubject;
123  }
124
125  /**
126   * Sets the subject of sign request email. This is cleaned by sign request.
127   *
128   * @param emailSubject included in sign request email.
129   * @return this BoxSignRequestCreateParams object for chaining.
130   */
131  public BoxSignRequestCreateParams setEmailSubject(String emailSubject) {
132    this.emailSubject = emailSubject;
133    return this;
134  }
135
136  /**
137   * Gets the message to include in sign request email.
138   *
139   * @return message of sign request email.
140   */
141  public String getEmailMessage() {
142    return this.emailMessage;
143  }
144
145  /**
146   * Sets the message to include in sign request email. This is cleaned,but some html tags are
147   * allowed. Links included in the message are also converted to actual links in the email. The
148   * message may contain the following html tags: a, abbr, acronym, b, blockquote, code, em, i, ul,
149   * li, ol, and strong. Be aware that when the text to html ratio is too high, the email may end up
150   * in spam filters. Custom styles on these tags are not allowed.
151   *
152   * @param emailMessage included in sign request email.
153   * @return this BoxSignRequestCreateParams object for chaining.
154   */
155  public BoxSignRequestCreateParams setEmailMessage(String emailMessage) {
156    this.emailMessage = emailMessage;
157    return this;
158  }
159
160  /**
161   * Gets the flag indicating if remind for signers to sign a document on day 3, 8, 13 and 18 (or
162   * less if the document has been digitally signed already) is enabled.
163   *
164   * @return true if reminders are enabled, otherwise false.
165   */
166  public boolean getAreRemindersEnabled() {
167    return this.areRemindersEnabled;
168  }
169
170  /**
171   * Sets the flag indicating if remind for signers to sign a document on day 3, 8, 13 and 18 (or
172   * less if the document has been digitally signed already) is enabled.
173   *
174   * @param areRemindersEnabled indicating if reminders are enabled.
175   * @return this BoxSignRequestCreateParams object for chaining.
176   */
177  public BoxSignRequestCreateParams setAreRemindersEnabled(boolean areRemindersEnabled) {
178    this.areRemindersEnabled = areRemindersEnabled;
179    return this;
180  }
181
182  /**
183   * Gets the name of this sign request.
184   *
185   * @return name of this sign request.
186   */
187  public String getName() {
188    return this.name;
189  }
190
191  /**
192   * Sets the name of this sign request.
193   *
194   * @param name of this sign request.
195   * @return this BoxSignRequestCreateParams object for chaining.
196   */
197  public BoxSignRequestCreateParams setName(String name) {
198    this.name = name;
199    return this;
200  }
201
202  /**
203   * Gets the number of days after which this request will automatically expire if not completed.
204   *
205   * @return number of days after which this request will automatically expire if not completed.
206   */
207  public int getDaysValid() {
208    return this.daysValid;
209  }
210
211  /**
212   * Sets the number of days after which this request will automatically expire if not completed.
213   *
214   * @param daysValid of this sign request.
215   * @return this BoxSignRequestCreateParams object for chaining.
216   */
217  public BoxSignRequestCreateParams setDaysValid(int daysValid) {
218    this.daysValid = daysValid;
219    return this;
220  }
221
222  /**
223   * Gets an ID that serve as reference in an external system that the sign request is related to.
224   *
225   * @return external id.
226   */
227  public String getExternalId() {
228    return this.externalId;
229  }
230
231  /**
232   * Sets the reference id in an external system that this sign request is related to.
233   *
234   * @param externalId of this sign request.
235   * @return this BoxSignRequestCreateParams object for chaining.
236   */
237  public BoxSignRequestCreateParams setExternalId(String externalId) {
238    this.externalId = externalId;
239    return this;
240  }
241
242  /**
243   * Gets the list of prefill tags.
244   *
245   * @return list of prefill tags.
246   */
247  public List<BoxSignRequestPrefillTag> getPrefillTags() {
248    return this.prefillTags;
249  }
250
251  /**
252   * Sets the list of prefill tags. When a document contains sign related tags in the content, you
253   * can prefill them using this prefillTags by referencing the 'id' of the tag as the externalId
254   * field of the prefill tag.
255   *
256   * @param prefillTags list for this sign request.
257   * @return this BoxSignRequestCreateParams object for chaining.
258   */
259  public BoxSignRequestCreateParams setPrefillTags(List<BoxSignRequestPrefillTag> prefillTags) {
260    this.prefillTags = prefillTags;
261    return this;
262  }
263
264  /**
265   * Gets the redirect URL that a signer will be redirected to after signing a document.
266   *
267   * @return redirect url.
268   */
269  public String getRedirectUrl() {
270    return this.redirectUrl;
271  }
272
273  /**
274   * Sets the redirect URL that a signer will be redirected to after signing a document.
275   *
276   * @param redirectUrl of this sign request.
277   * @return this BoxSignRequestCreateParams object for chaining.
278   */
279  public BoxSignRequestCreateParams setRedirectUrl(String redirectUrl) {
280    this.redirectUrl = redirectUrl;
281    return this;
282  }
283
284  /**
285   * Gets the URL that a signer will be redirected to after declining to sign a document.
286   *
287   * @return decline redirect url.
288   */
289  public String getDeclinedRedirectUrl() {
290    return this.declinedRedirectUrl;
291  }
292
293  /**
294   * Sets the URL that a signer will be redirected to after declining to sign a document.
295   *
296   * @param declinedRedirectUrl of this sign request.
297   * @return this BoxSignRequestCreateParams object for chaining.
298   */
299  public BoxSignRequestCreateParams setDeclinedRedirectUrl(String declinedRedirectUrl) {
300    this.declinedRedirectUrl = declinedRedirectUrl;
301    return this;
302  }
303
304  /**
305   * Gets the Sign Template ID of the Sign Request.
306   *
307   * @return template id.
308   */
309  public String getTemplateId() {
310    return this.templateId;
311  }
312
313  /**
314   * Sets the Sign Template ID will be use to create the sign request.
315   *
316   * @param templateId for this sign request.
317   * @return this BoxSignRequestCreateParams object for chaining.
318   */
319  public BoxSignRequestCreateParams setTemplateId(String templateId) {
320    this.templateId = templateId;
321    return this;
322  }
323
324  /**
325   * Used to append BoxSignRequestCreateParams to request.
326   *
327   * @param requestJSON request in json to append data to.
328   */
329  public void appendParamsAsJson(JsonObject requestJSON) {
330    JsonUtils.addIfNotNull(
331        requestJSON, "is_document_preparation_needed", this.isDocumentPreparationNeeded);
332    JsonUtils.addIfNotNull(
333        requestJSON, "are_text_signatures_enabled", this.areTextSignaturesEnabled);
334    JsonUtils.addIfNotNull(requestJSON, "are_dates_enabled", this.areDatesEnabled);
335    JsonUtils.addIfNotNull(requestJSON, "signature_color", this.signatureColor);
336    JsonUtils.addIfNotNull(requestJSON, "email_subject", this.emailSubject);
337    JsonUtils.addIfNotNull(requestJSON, "email_message", this.emailMessage);
338    JsonUtils.addIfNotNull(requestJSON, "are_reminders_enabled", this.areRemindersEnabled);
339    JsonUtils.addIfNotNull(requestJSON, "name", this.name);
340    JsonUtils.addIfNotNull(requestJSON, "days_valid", this.daysValid);
341    JsonUtils.addIfNotNull(requestJSON, "external_id", this.externalId);
342    JsonUtils.addIfNotNull(requestJSON, "redirect_url", this.redirectUrl);
343    JsonUtils.addIfNotNull(requestJSON, "declined_redirect_url", this.declinedRedirectUrl);
344    JsonUtils.addIfNotNull(requestJSON, "template_id", this.templateId);
345
346    if (this.prefillTags != null) {
347      JsonArray prefillTagsJSON = new JsonArray();
348      for (BoxSignRequestPrefillTag prefillTag : this.prefillTags) {
349        prefillTagsJSON.add(prefillTag.getJSONObject());
350      }
351      requestJSON.add("prefill_tags", prefillTagsJSON);
352    }
353
354    return;
355  }
356}