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