001package com.box.sdkgen.schemas.signrequest;
002
003import com.box.sdkgen.internal.Nullable;
004import com.box.sdkgen.internal.utils.DateTimeUtils;
005import com.box.sdkgen.schemas.filebase.FileBase;
006import com.box.sdkgen.schemas.filemini.FileMini;
007import com.box.sdkgen.schemas.foldermini.FolderMini;
008import com.box.sdkgen.schemas.signrequestbase.SignRequestBase;
009import com.box.sdkgen.schemas.signrequestprefilltag.SignRequestPrefillTag;
010import com.box.sdkgen.schemas.signrequestsigner.SignRequestSigner;
011import com.box.sdkgen.serialization.json.EnumWrapper;
012import com.fasterxml.jackson.annotation.JsonFilter;
013import com.fasterxml.jackson.annotation.JsonProperty;
014import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
015import com.fasterxml.jackson.databind.annotation.JsonSerialize;
016import java.time.OffsetDateTime;
017import java.util.List;
018import java.util.Objects;
019
020/** A Box Sign request object. */
021@JsonFilter("nullablePropertyFilter")
022public class SignRequest extends SignRequestBase {
023
024  /** The value will always be `sign-request`. */
025  @JsonDeserialize(using = SignRequestTypeField.SignRequestTypeFieldDeserializer.class)
026  @JsonSerialize(using = SignRequestTypeField.SignRequestTypeFieldSerializer.class)
027  protected EnumWrapper<SignRequestTypeField> type;
028
029  /**
030   * List of files to create a signing document from. This is currently limited to ten files. Only
031   * the ID and type fields are required for each file.
032   */
033  @JsonProperty("source_files")
034  protected List<FileBase> sourceFiles;
035
036  /** Array of signers for the signature request. */
037  protected List<SignRequestSigner> signers;
038
039  /** Force a specific color for the signature (blue, black, or red). */
040  @JsonProperty("signature_color")
041  @Nullable
042  protected String signatureColor;
043
044  /** Box Sign request ID. */
045  protected String id;
046
047  /**
048   * This URL is returned if `is_document_preparation_needed` is set to `true` in the request. The
049   * parameter is used to prepare the signature request using the UI. The signature request is not
050   * sent until the preparation phase is complete.
051   */
052  @JsonProperty("prepare_url")
053  @Nullable
054  protected String prepareUrl;
055
056  @JsonProperty("signing_log")
057  protected FileMini signingLog;
058
059  /** Describes the status of the signature request. */
060  @JsonDeserialize(using = SignRequestStatusField.SignRequestStatusFieldDeserializer.class)
061  @JsonSerialize(using = SignRequestStatusField.SignRequestStatusFieldSerializer.class)
062  protected EnumWrapper<SignRequestStatusField> status;
063
064  /**
065   * List of files that will be signed, which are copies of the original source files. A new version
066   * of these files are created as signers sign and can be downloaded at any point in the signing
067   * process.
068   */
069  @JsonProperty("sign_files")
070  protected SignRequestSignFilesField signFiles;
071
072  /**
073   * Uses `days_valid` to calculate the date and time, in GMT, the sign request will expire if
074   * unsigned.
075   */
076  @JsonProperty("auto_expire_at")
077  @JsonSerialize(using = DateTimeUtils.DateTimeSerializer.class)
078  @JsonDeserialize(using = DateTimeUtils.DateTimeDeserializer.class)
079  @Nullable
080  protected OffsetDateTime autoExpireAt;
081
082  @JsonProperty("parent_folder")
083  protected FolderMini parentFolder;
084
085  /**
086   * The collaborator level of the user to the sign request. Values can include "owner", "editor",
087   * and "viewer".
088   */
089  @JsonProperty("collaborator_level")
090  @Nullable
091  protected String collaboratorLevel;
092
093  /** Short identifier for the sign request. */
094  @JsonProperty("short_id")
095  protected String shortId;
096
097  /** Timestamp marking when the sign request was created. */
098  @JsonProperty("created_at")
099  @JsonSerialize(using = DateTimeUtils.DateTimeSerializer.class)
100  @JsonDeserialize(using = DateTimeUtils.DateTimeDeserializer.class)
101  protected OffsetDateTime createdAt;
102
103  /** Timestamp indicating when all signing actions completed. */
104  @JsonProperty("finished_at")
105  @JsonSerialize(using = DateTimeUtils.DateTimeSerializer.class)
106  @JsonDeserialize(using = DateTimeUtils.DateTimeDeserializer.class)
107  @Nullable
108  protected OffsetDateTime finishedAt;
109
110  /**
111   * When the sign request is in an error state, identifies the specific reason. Null when no error
112   * code applies.
113   */
114  @JsonProperty("error_code")
115  @Nullable
116  protected String errorCode;
117
118  /** The email address of the sender of the sign request. */
119  @JsonProperty("sender_email")
120  @Nullable
121  protected String senderEmail;
122
123  /** The user ID of the sender of the sign request. */
124  @JsonProperty("sender_id")
125  @Nullable
126  protected Long senderId;
127
128  public SignRequest() {
129    super();
130  }
131
132  protected SignRequest(Builder builder) {
133    super(builder);
134    this.type = builder.type;
135    this.sourceFiles = builder.sourceFiles;
136    this.signers = builder.signers;
137    this.signatureColor = builder.signatureColor;
138    this.id = builder.id;
139    this.prepareUrl = builder.prepareUrl;
140    this.signingLog = builder.signingLog;
141    this.status = builder.status;
142    this.signFiles = builder.signFiles;
143    this.autoExpireAt = builder.autoExpireAt;
144    this.parentFolder = builder.parentFolder;
145    this.collaboratorLevel = builder.collaboratorLevel;
146    this.shortId = builder.shortId;
147    this.createdAt = builder.createdAt;
148    this.finishedAt = builder.finishedAt;
149    this.errorCode = builder.errorCode;
150    this.senderEmail = builder.senderEmail;
151    this.senderId = builder.senderId;
152    markNullableFieldsAsSet(builder.getExplicitlySetNullableFields());
153  }
154
155  public EnumWrapper<SignRequestTypeField> getType() {
156    return type;
157  }
158
159  public List<FileBase> getSourceFiles() {
160    return sourceFiles;
161  }
162
163  public List<SignRequestSigner> getSigners() {
164    return signers;
165  }
166
167  public String getSignatureColor() {
168    return signatureColor;
169  }
170
171  public String getId() {
172    return id;
173  }
174
175  public String getPrepareUrl() {
176    return prepareUrl;
177  }
178
179  public FileMini getSigningLog() {
180    return signingLog;
181  }
182
183  public EnumWrapper<SignRequestStatusField> getStatus() {
184    return status;
185  }
186
187  public SignRequestSignFilesField getSignFiles() {
188    return signFiles;
189  }
190
191  public OffsetDateTime getAutoExpireAt() {
192    return autoExpireAt;
193  }
194
195  public FolderMini getParentFolder() {
196    return parentFolder;
197  }
198
199  public String getCollaboratorLevel() {
200    return collaboratorLevel;
201  }
202
203  public String getShortId() {
204    return shortId;
205  }
206
207  public OffsetDateTime getCreatedAt() {
208    return createdAt;
209  }
210
211  public OffsetDateTime getFinishedAt() {
212    return finishedAt;
213  }
214
215  public String getErrorCode() {
216    return errorCode;
217  }
218
219  public String getSenderEmail() {
220    return senderEmail;
221  }
222
223  public Long getSenderId() {
224    return senderId;
225  }
226
227  @Override
228  public boolean equals(Object o) {
229    if (this == o) {
230      return true;
231    }
232    if (o == null || getClass() != o.getClass()) {
233      return false;
234    }
235    SignRequest casted = (SignRequest) o;
236    return Objects.equals(isDocumentPreparationNeeded, casted.isDocumentPreparationNeeded)
237        && Objects.equals(redirectUrl, casted.redirectUrl)
238        && Objects.equals(declinedRedirectUrl, casted.declinedRedirectUrl)
239        && Objects.equals(areTextSignaturesEnabled, casted.areTextSignaturesEnabled)
240        && Objects.equals(emailSubject, casted.emailSubject)
241        && Objects.equals(emailMessage, casted.emailMessage)
242        && Objects.equals(areRemindersEnabled, casted.areRemindersEnabled)
243        && Objects.equals(name, casted.name)
244        && Objects.equals(prefillTags, casted.prefillTags)
245        && Objects.equals(daysValid, casted.daysValid)
246        && Objects.equals(externalId, casted.externalId)
247        && Objects.equals(templateId, casted.templateId)
248        && Objects.equals(externalSystemName, casted.externalSystemName)
249        && Objects.equals(requestFlow, casted.requestFlow)
250        && Objects.equals(type, casted.type)
251        && Objects.equals(sourceFiles, casted.sourceFiles)
252        && Objects.equals(signers, casted.signers)
253        && Objects.equals(signatureColor, casted.signatureColor)
254        && Objects.equals(id, casted.id)
255        && Objects.equals(prepareUrl, casted.prepareUrl)
256        && Objects.equals(signingLog, casted.signingLog)
257        && Objects.equals(status, casted.status)
258        && Objects.equals(signFiles, casted.signFiles)
259        && Objects.equals(autoExpireAt, casted.autoExpireAt)
260        && Objects.equals(parentFolder, casted.parentFolder)
261        && Objects.equals(collaboratorLevel, casted.collaboratorLevel)
262        && Objects.equals(shortId, casted.shortId)
263        && Objects.equals(createdAt, casted.createdAt)
264        && Objects.equals(finishedAt, casted.finishedAt)
265        && Objects.equals(errorCode, casted.errorCode)
266        && Objects.equals(senderEmail, casted.senderEmail)
267        && Objects.equals(senderId, casted.senderId);
268  }
269
270  @Override
271  public int hashCode() {
272    return Objects.hash(
273        isDocumentPreparationNeeded,
274        redirectUrl,
275        declinedRedirectUrl,
276        areTextSignaturesEnabled,
277        emailSubject,
278        emailMessage,
279        areRemindersEnabled,
280        name,
281        prefillTags,
282        daysValid,
283        externalId,
284        templateId,
285        externalSystemName,
286        requestFlow,
287        type,
288        sourceFiles,
289        signers,
290        signatureColor,
291        id,
292        prepareUrl,
293        signingLog,
294        status,
295        signFiles,
296        autoExpireAt,
297        parentFolder,
298        collaboratorLevel,
299        shortId,
300        createdAt,
301        finishedAt,
302        errorCode,
303        senderEmail,
304        senderId);
305  }
306
307  @Override
308  public String toString() {
309    return "SignRequest{"
310        + "isDocumentPreparationNeeded='"
311        + isDocumentPreparationNeeded
312        + '\''
313        + ", "
314        + "redirectUrl='"
315        + redirectUrl
316        + '\''
317        + ", "
318        + "declinedRedirectUrl='"
319        + declinedRedirectUrl
320        + '\''
321        + ", "
322        + "areTextSignaturesEnabled='"
323        + areTextSignaturesEnabled
324        + '\''
325        + ", "
326        + "emailSubject='"
327        + emailSubject
328        + '\''
329        + ", "
330        + "emailMessage='"
331        + emailMessage
332        + '\''
333        + ", "
334        + "areRemindersEnabled='"
335        + areRemindersEnabled
336        + '\''
337        + ", "
338        + "name='"
339        + name
340        + '\''
341        + ", "
342        + "prefillTags='"
343        + prefillTags
344        + '\''
345        + ", "
346        + "daysValid='"
347        + daysValid
348        + '\''
349        + ", "
350        + "externalId='"
351        + externalId
352        + '\''
353        + ", "
354        + "templateId='"
355        + templateId
356        + '\''
357        + ", "
358        + "externalSystemName='"
359        + externalSystemName
360        + '\''
361        + ", "
362        + "requestFlow='"
363        + requestFlow
364        + '\''
365        + ", "
366        + "type='"
367        + type
368        + '\''
369        + ", "
370        + "sourceFiles='"
371        + sourceFiles
372        + '\''
373        + ", "
374        + "signers='"
375        + signers
376        + '\''
377        + ", "
378        + "signatureColor='"
379        + signatureColor
380        + '\''
381        + ", "
382        + "id='"
383        + id
384        + '\''
385        + ", "
386        + "prepareUrl='"
387        + prepareUrl
388        + '\''
389        + ", "
390        + "signingLog='"
391        + signingLog
392        + '\''
393        + ", "
394        + "status='"
395        + status
396        + '\''
397        + ", "
398        + "signFiles='"
399        + signFiles
400        + '\''
401        + ", "
402        + "autoExpireAt='"
403        + autoExpireAt
404        + '\''
405        + ", "
406        + "parentFolder='"
407        + parentFolder
408        + '\''
409        + ", "
410        + "collaboratorLevel='"
411        + collaboratorLevel
412        + '\''
413        + ", "
414        + "shortId='"
415        + shortId
416        + '\''
417        + ", "
418        + "createdAt='"
419        + createdAt
420        + '\''
421        + ", "
422        + "finishedAt='"
423        + finishedAt
424        + '\''
425        + ", "
426        + "errorCode='"
427        + errorCode
428        + '\''
429        + ", "
430        + "senderEmail='"
431        + senderEmail
432        + '\''
433        + ", "
434        + "senderId='"
435        + senderId
436        + '\''
437        + "}";
438  }
439
440  public static class Builder extends SignRequestBase.Builder {
441
442    protected EnumWrapper<SignRequestTypeField> type;
443
444    protected List<FileBase> sourceFiles;
445
446    protected List<SignRequestSigner> signers;
447
448    protected String signatureColor;
449
450    protected String id;
451
452    protected String prepareUrl;
453
454    protected FileMini signingLog;
455
456    protected EnumWrapper<SignRequestStatusField> status;
457
458    protected SignRequestSignFilesField signFiles;
459
460    protected OffsetDateTime autoExpireAt;
461
462    protected FolderMini parentFolder;
463
464    protected String collaboratorLevel;
465
466    protected String shortId;
467
468    protected OffsetDateTime createdAt;
469
470    protected OffsetDateTime finishedAt;
471
472    protected String errorCode;
473
474    protected String senderEmail;
475
476    protected Long senderId;
477
478    public Builder type(SignRequestTypeField type) {
479      this.type = new EnumWrapper<SignRequestTypeField>(type);
480      return this;
481    }
482
483    public Builder type(EnumWrapper<SignRequestTypeField> type) {
484      this.type = type;
485      return this;
486    }
487
488    public Builder sourceFiles(List<FileBase> sourceFiles) {
489      this.sourceFiles = sourceFiles;
490      return this;
491    }
492
493    public Builder signers(List<SignRequestSigner> signers) {
494      this.signers = signers;
495      return this;
496    }
497
498    public Builder signatureColor(String signatureColor) {
499      this.signatureColor = signatureColor;
500      this.markNullableFieldAsSet("signature_color");
501      return this;
502    }
503
504    public Builder id(String id) {
505      this.id = id;
506      return this;
507    }
508
509    public Builder prepareUrl(String prepareUrl) {
510      this.prepareUrl = prepareUrl;
511      this.markNullableFieldAsSet("prepare_url");
512      return this;
513    }
514
515    public Builder signingLog(FileMini signingLog) {
516      this.signingLog = signingLog;
517      return this;
518    }
519
520    public Builder status(SignRequestStatusField status) {
521      this.status = new EnumWrapper<SignRequestStatusField>(status);
522      return this;
523    }
524
525    public Builder status(EnumWrapper<SignRequestStatusField> status) {
526      this.status = status;
527      return this;
528    }
529
530    public Builder signFiles(SignRequestSignFilesField signFiles) {
531      this.signFiles = signFiles;
532      return this;
533    }
534
535    public Builder autoExpireAt(OffsetDateTime autoExpireAt) {
536      this.autoExpireAt = autoExpireAt;
537      this.markNullableFieldAsSet("auto_expire_at");
538      return this;
539    }
540
541    public Builder parentFolder(FolderMini parentFolder) {
542      this.parentFolder = parentFolder;
543      return this;
544    }
545
546    public Builder collaboratorLevel(String collaboratorLevel) {
547      this.collaboratorLevel = collaboratorLevel;
548      this.markNullableFieldAsSet("collaborator_level");
549      return this;
550    }
551
552    public Builder shortId(String shortId) {
553      this.shortId = shortId;
554      return this;
555    }
556
557    public Builder createdAt(OffsetDateTime createdAt) {
558      this.createdAt = createdAt;
559      return this;
560    }
561
562    public Builder finishedAt(OffsetDateTime finishedAt) {
563      this.finishedAt = finishedAt;
564      this.markNullableFieldAsSet("finished_at");
565      return this;
566    }
567
568    public Builder errorCode(String errorCode) {
569      this.errorCode = errorCode;
570      this.markNullableFieldAsSet("error_code");
571      return this;
572    }
573
574    public Builder senderEmail(String senderEmail) {
575      this.senderEmail = senderEmail;
576      this.markNullableFieldAsSet("sender_email");
577      return this;
578    }
579
580    public Builder senderId(Long senderId) {
581      this.senderId = senderId;
582      this.markNullableFieldAsSet("sender_id");
583      return this;
584    }
585
586    @Override
587    public Builder isDocumentPreparationNeeded(Boolean isDocumentPreparationNeeded) {
588      this.isDocumentPreparationNeeded = isDocumentPreparationNeeded;
589      return this;
590    }
591
592    @Override
593    public Builder redirectUrl(String redirectUrl) {
594      this.redirectUrl = redirectUrl;
595      this.markNullableFieldAsSet("redirect_url");
596      return this;
597    }
598
599    @Override
600    public Builder declinedRedirectUrl(String declinedRedirectUrl) {
601      this.declinedRedirectUrl = declinedRedirectUrl;
602      this.markNullableFieldAsSet("declined_redirect_url");
603      return this;
604    }
605
606    @Override
607    public Builder areTextSignaturesEnabled(Boolean areTextSignaturesEnabled) {
608      this.areTextSignaturesEnabled = areTextSignaturesEnabled;
609      return this;
610    }
611
612    @Override
613    public Builder emailSubject(String emailSubject) {
614      this.emailSubject = emailSubject;
615      this.markNullableFieldAsSet("email_subject");
616      return this;
617    }
618
619    @Override
620    public Builder emailMessage(String emailMessage) {
621      this.emailMessage = emailMessage;
622      this.markNullableFieldAsSet("email_message");
623      return this;
624    }
625
626    @Override
627    public Builder areRemindersEnabled(Boolean areRemindersEnabled) {
628      this.areRemindersEnabled = areRemindersEnabled;
629      return this;
630    }
631
632    @Override
633    public Builder name(String name) {
634      this.name = name;
635      return this;
636    }
637
638    @Override
639    public Builder prefillTags(List<SignRequestPrefillTag> prefillTags) {
640      this.prefillTags = prefillTags;
641      return this;
642    }
643
644    @Override
645    public Builder daysValid(Long daysValid) {
646      this.daysValid = daysValid;
647      this.markNullableFieldAsSet("days_valid");
648      return this;
649    }
650
651    @Override
652    public Builder externalId(String externalId) {
653      this.externalId = externalId;
654      this.markNullableFieldAsSet("external_id");
655      return this;
656    }
657
658    @Override
659    public Builder templateId(String templateId) {
660      this.templateId = templateId;
661      this.markNullableFieldAsSet("template_id");
662      return this;
663    }
664
665    @Override
666    public Builder externalSystemName(String externalSystemName) {
667      this.externalSystemName = externalSystemName;
668      this.markNullableFieldAsSet("external_system_name");
669      return this;
670    }
671
672    @Override
673    public Builder requestFlow(String requestFlow) {
674      this.requestFlow = requestFlow;
675      this.markNullableFieldAsSet("request_flow");
676      return this;
677    }
678
679    public SignRequest build() {
680      return new SignRequest(this);
681    }
682  }
683}