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