001package com.box.sdkgen.schemas.filerequest;
002
003import com.box.sdkgen.internal.Nullable;
004import com.box.sdkgen.internal.NullableFieldTracker;
005import com.box.sdkgen.internal.SerializableObject;
006import com.box.sdkgen.internal.utils.DateTimeUtils;
007import com.box.sdkgen.schemas.foldermini.FolderMini;
008import com.box.sdkgen.schemas.usermini.UserMini;
009import com.box.sdkgen.serialization.json.EnumWrapper;
010import com.fasterxml.jackson.annotation.JsonFilter;
011import com.fasterxml.jackson.annotation.JsonProperty;
012import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
013import com.fasterxml.jackson.databind.annotation.JsonSerialize;
014import java.time.OffsetDateTime;
015import java.util.Objects;
016
017/**
018 * A standard representation of a file request, as returned from any file request API endpoints by
019 * default.
020 */
021@JsonFilter("nullablePropertyFilter")
022public class FileRequest extends SerializableObject {
023
024  /** The unique identifier for this file request. */
025  protected final String id;
026
027  /** The value will always be `file_request`. */
028  @JsonDeserialize(using = FileRequestTypeField.FileRequestTypeFieldDeserializer.class)
029  @JsonSerialize(using = FileRequestTypeField.FileRequestTypeFieldSerializer.class)
030  protected EnumWrapper<FileRequestTypeField> type;
031
032  /**
033   * The title of file request. This is shown in the Box UI to users uploading files.
034   *
035   * <p>This defaults to title of the file request that was copied to create this file request.
036   */
037  protected String title;
038
039  /**
040   * The optional description of this file request. This is shown in the Box UI to users uploading
041   * files.
042   *
043   * <p>This defaults to description of the file request that was copied to create this file
044   * request.
045   */
046  @Nullable protected String description;
047
048  /**
049   * The status of the file request. This defaults to `active`.
050   *
051   * <p>When the status is set to `inactive`, the file request will no longer accept new
052   * submissions, and any visitor to the file request URL will receive a `HTTP 404` status code.
053   *
054   * <p>This defaults to status of file request that was copied to create this file request.
055   */
056  @JsonDeserialize(using = FileRequestStatusField.FileRequestStatusFieldDeserializer.class)
057  @JsonSerialize(using = FileRequestStatusField.FileRequestStatusFieldSerializer.class)
058  protected EnumWrapper<FileRequestStatusField> status;
059
060  /**
061   * Whether a file request submitter is required to provide their email address.
062   *
063   * <p>When this setting is set to true, the Box UI will show an email field on the file request
064   * form.
065   *
066   * <p>This defaults to setting of file request that was copied to create this file request.
067   */
068  @JsonProperty("is_email_required")
069  protected Boolean isEmailRequired;
070
071  /**
072   * Whether a file request submitter is required to provide a description of the files they are
073   * submitting.
074   *
075   * <p>When this setting is set to true, the Box UI will show a description field on the file
076   * request form.
077   *
078   * <p>This defaults to setting of file request that was copied to create this file request.
079   */
080  @JsonProperty("is_description_required")
081  protected Boolean isDescriptionRequired;
082
083  /**
084   * The date after which a file request will no longer accept new submissions.
085   *
086   * <p>After this date, the `status` will automatically be set to `inactive`.
087   */
088  @JsonProperty("expires_at")
089  @JsonSerialize(using = DateTimeUtils.DateTimeSerializer.class)
090  @JsonDeserialize(using = DateTimeUtils.DateTimeDeserializer.class)
091  protected OffsetDateTime expiresAt;
092
093  protected final FolderMini folder;
094
095  /**
096   * The generated URL for this file request. This URL can be shared with users to let them upload
097   * files to the associated folder.
098   */
099  protected String url;
100
101  /**
102   * The HTTP `etag` of this file. This can be used in combination with the `If-Match` header when
103   * updating a file request. By providing that header, a change will only be performed on the file
104   * request if the `etag` on the file request still matches the `etag` provided in the `If-Match`
105   * header.
106   */
107  @Nullable protected String etag;
108
109  @JsonProperty("created_by")
110  protected UserMini createdBy;
111
112  /** The date and time when the file request was created. */
113  @JsonProperty("created_at")
114  @JsonSerialize(using = DateTimeUtils.DateTimeSerializer.class)
115  @JsonDeserialize(using = DateTimeUtils.DateTimeDeserializer.class)
116  protected final OffsetDateTime createdAt;
117
118  @JsonProperty("updated_by")
119  protected UserMini updatedBy;
120
121  /** The date and time when the file request was last updated. */
122  @JsonProperty("updated_at")
123  @JsonSerialize(using = DateTimeUtils.DateTimeSerializer.class)
124  @JsonDeserialize(using = DateTimeUtils.DateTimeDeserializer.class)
125  protected final OffsetDateTime updatedAt;
126
127  public FileRequest(
128      @JsonProperty("id") String id,
129      @JsonProperty("folder") FolderMini folder,
130      @JsonProperty("created_at") OffsetDateTime createdAt,
131      @JsonProperty("updated_at") OffsetDateTime updatedAt) {
132    super();
133    this.id = id;
134    this.folder = folder;
135    this.createdAt = createdAt;
136    this.updatedAt = updatedAt;
137    this.type = new EnumWrapper<FileRequestTypeField>(FileRequestTypeField.FILE_REQUEST);
138  }
139
140  protected FileRequest(Builder builder) {
141    super();
142    this.id = builder.id;
143    this.type = builder.type;
144    this.title = builder.title;
145    this.description = builder.description;
146    this.status = builder.status;
147    this.isEmailRequired = builder.isEmailRequired;
148    this.isDescriptionRequired = builder.isDescriptionRequired;
149    this.expiresAt = builder.expiresAt;
150    this.folder = builder.folder;
151    this.url = builder.url;
152    this.etag = builder.etag;
153    this.createdBy = builder.createdBy;
154    this.createdAt = builder.createdAt;
155    this.updatedBy = builder.updatedBy;
156    this.updatedAt = builder.updatedAt;
157    markNullableFieldsAsSet(builder.getExplicitlySetNullableFields());
158  }
159
160  public String getId() {
161    return id;
162  }
163
164  public EnumWrapper<FileRequestTypeField> getType() {
165    return type;
166  }
167
168  public String getTitle() {
169    return title;
170  }
171
172  public String getDescription() {
173    return description;
174  }
175
176  public EnumWrapper<FileRequestStatusField> getStatus() {
177    return status;
178  }
179
180  public Boolean getIsEmailRequired() {
181    return isEmailRequired;
182  }
183
184  public Boolean getIsDescriptionRequired() {
185    return isDescriptionRequired;
186  }
187
188  public OffsetDateTime getExpiresAt() {
189    return expiresAt;
190  }
191
192  public FolderMini getFolder() {
193    return folder;
194  }
195
196  public String getUrl() {
197    return url;
198  }
199
200  public String getEtag() {
201    return etag;
202  }
203
204  public UserMini getCreatedBy() {
205    return createdBy;
206  }
207
208  public OffsetDateTime getCreatedAt() {
209    return createdAt;
210  }
211
212  public UserMini getUpdatedBy() {
213    return updatedBy;
214  }
215
216  public OffsetDateTime getUpdatedAt() {
217    return updatedAt;
218  }
219
220  @Override
221  public boolean equals(Object o) {
222    if (this == o) {
223      return true;
224    }
225    if (o == null || getClass() != o.getClass()) {
226      return false;
227    }
228    FileRequest casted = (FileRequest) o;
229    return Objects.equals(id, casted.id)
230        && Objects.equals(type, casted.type)
231        && Objects.equals(title, casted.title)
232        && Objects.equals(description, casted.description)
233        && Objects.equals(status, casted.status)
234        && Objects.equals(isEmailRequired, casted.isEmailRequired)
235        && Objects.equals(isDescriptionRequired, casted.isDescriptionRequired)
236        && Objects.equals(expiresAt, casted.expiresAt)
237        && Objects.equals(folder, casted.folder)
238        && Objects.equals(url, casted.url)
239        && Objects.equals(etag, casted.etag)
240        && Objects.equals(createdBy, casted.createdBy)
241        && Objects.equals(createdAt, casted.createdAt)
242        && Objects.equals(updatedBy, casted.updatedBy)
243        && Objects.equals(updatedAt, casted.updatedAt);
244  }
245
246  @Override
247  public int hashCode() {
248    return Objects.hash(
249        id,
250        type,
251        title,
252        description,
253        status,
254        isEmailRequired,
255        isDescriptionRequired,
256        expiresAt,
257        folder,
258        url,
259        etag,
260        createdBy,
261        createdAt,
262        updatedBy,
263        updatedAt);
264  }
265
266  @Override
267  public String toString() {
268    return "FileRequest{"
269        + "id='"
270        + id
271        + '\''
272        + ", "
273        + "type='"
274        + type
275        + '\''
276        + ", "
277        + "title='"
278        + title
279        + '\''
280        + ", "
281        + "description='"
282        + description
283        + '\''
284        + ", "
285        + "status='"
286        + status
287        + '\''
288        + ", "
289        + "isEmailRequired='"
290        + isEmailRequired
291        + '\''
292        + ", "
293        + "isDescriptionRequired='"
294        + isDescriptionRequired
295        + '\''
296        + ", "
297        + "expiresAt='"
298        + expiresAt
299        + '\''
300        + ", "
301        + "folder='"
302        + folder
303        + '\''
304        + ", "
305        + "url='"
306        + url
307        + '\''
308        + ", "
309        + "etag='"
310        + etag
311        + '\''
312        + ", "
313        + "createdBy='"
314        + createdBy
315        + '\''
316        + ", "
317        + "createdAt='"
318        + createdAt
319        + '\''
320        + ", "
321        + "updatedBy='"
322        + updatedBy
323        + '\''
324        + ", "
325        + "updatedAt='"
326        + updatedAt
327        + '\''
328        + "}";
329  }
330
331  public static class Builder extends NullableFieldTracker {
332
333    protected final String id;
334
335    protected EnumWrapper<FileRequestTypeField> type;
336
337    protected String title;
338
339    protected String description;
340
341    protected EnumWrapper<FileRequestStatusField> status;
342
343    protected Boolean isEmailRequired;
344
345    protected Boolean isDescriptionRequired;
346
347    protected OffsetDateTime expiresAt;
348
349    protected final FolderMini folder;
350
351    protected String url;
352
353    protected String etag;
354
355    protected UserMini createdBy;
356
357    protected final OffsetDateTime createdAt;
358
359    protected UserMini updatedBy;
360
361    protected final OffsetDateTime updatedAt;
362
363    public Builder(
364        String id, FolderMini folder, OffsetDateTime createdAt, OffsetDateTime updatedAt) {
365      super();
366      this.id = id;
367      this.folder = folder;
368      this.createdAt = createdAt;
369      this.updatedAt = updatedAt;
370    }
371
372    public Builder type(FileRequestTypeField type) {
373      this.type = new EnumWrapper<FileRequestTypeField>(type);
374      return this;
375    }
376
377    public Builder type(EnumWrapper<FileRequestTypeField> type) {
378      this.type = type;
379      return this;
380    }
381
382    public Builder title(String title) {
383      this.title = title;
384      return this;
385    }
386
387    public Builder description(String description) {
388      this.description = description;
389      this.markNullableFieldAsSet("description");
390      return this;
391    }
392
393    public Builder status(FileRequestStatusField status) {
394      this.status = new EnumWrapper<FileRequestStatusField>(status);
395      return this;
396    }
397
398    public Builder status(EnumWrapper<FileRequestStatusField> status) {
399      this.status = status;
400      return this;
401    }
402
403    public Builder isEmailRequired(Boolean isEmailRequired) {
404      this.isEmailRequired = isEmailRequired;
405      return this;
406    }
407
408    public Builder isDescriptionRequired(Boolean isDescriptionRequired) {
409      this.isDescriptionRequired = isDescriptionRequired;
410      return this;
411    }
412
413    public Builder expiresAt(OffsetDateTime expiresAt) {
414      this.expiresAt = expiresAt;
415      return this;
416    }
417
418    public Builder url(String url) {
419      this.url = url;
420      return this;
421    }
422
423    public Builder etag(String etag) {
424      this.etag = etag;
425      this.markNullableFieldAsSet("etag");
426      return this;
427    }
428
429    public Builder createdBy(UserMini createdBy) {
430      this.createdBy = createdBy;
431      return this;
432    }
433
434    public Builder updatedBy(UserMini updatedBy) {
435      this.updatedBy = updatedBy;
436      return this;
437    }
438
439    public FileRequest build() {
440      if (this.type == null) {
441        this.type = new EnumWrapper<FileRequestTypeField>(FileRequestTypeField.FILE_REQUEST);
442      }
443      return new FileRequest(this);
444    }
445  }
446}