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