001package com.box.sdkgen.schemas.zipdownload;
002
003import com.box.sdkgen.internal.NullableFieldTracker;
004import com.box.sdkgen.internal.SerializableObject;
005import com.box.sdkgen.internal.utils.DateTimeUtils;
006import com.fasterxml.jackson.annotation.JsonFilter;
007import com.fasterxml.jackson.annotation.JsonProperty;
008import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
009import com.fasterxml.jackson.databind.annotation.JsonSerialize;
010import java.time.OffsetDateTime;
011import java.util.List;
012import java.util.Objects;
013
014/** Represents a successful request to create a `zip` archive of a list of files and folders. */
015@JsonFilter("nullablePropertyFilter")
016public class ZipDownload extends SerializableObject {
017
018  /**
019   * The URL that can be used to download the `zip` archive. A `Get` request to this URL will start
020   * streaming the items requested. By default, this URL is only valid for a few seconds, until the
021   * `expires_at` time, unless a download is started after which it is valid for the duration of the
022   * download.
023   *
024   * <p>It is important to note that the domain and path of this URL might change between API calls,
025   * and therefore it's important to use this URL as-is.
026   */
027  @JsonProperty("download_url")
028  protected String downloadUrl;
029
030  /**
031   * The URL that can be used to get the status of the `zip` archive being downloaded. A `Get`
032   * request to this URL will return the number of files in the archive as well as the number of
033   * items already downloaded or skipped. By default, this URL is only valid for a few seconds,
034   * until the `expires_at` time, unless a download is started after which the URL is valid for 12
035   * hours from the start of the download.
036   *
037   * <p>It is important to note that the domain and path of this URL might change between API calls,
038   * and therefore it's important to use this URL as-is.
039   */
040  @JsonProperty("status_url")
041  protected String statusUrl;
042
043  /**
044   * The time and date when this archive will expire. After this time the `status_url` and
045   * `download_url` will return an error.
046   *
047   * <p>By default, these URLs are only valid for a few seconds, unless a download is started after
048   * which the `download_url` is valid for the duration of the download, and the `status_url` is
049   * valid for 12 hours from the start of the download.
050   */
051  @JsonProperty("expires_at")
052  @JsonSerialize(using = DateTimeUtils.DateTimeSerializer.class)
053  @JsonDeserialize(using = DateTimeUtils.DateTimeDeserializer.class)
054  protected OffsetDateTime expiresAt;
055
056  /**
057   * A list of conflicts that occurred when trying to create the archive. This would occur when
058   * multiple items have been requested with the same name.
059   *
060   * <p>To solve these conflicts, the API will automatically rename an item and return a mapping
061   * between the original item's name and its new name.
062   *
063   * <p>For every conflict, both files will be renamed and therefore this list will always be a
064   * multiple of 2.
065   */
066  @JsonProperty("name_conflicts")
067  protected List<List<ZipDownloadNameConflictsField>> nameConflicts;
068
069  public ZipDownload() {
070    super();
071  }
072
073  protected ZipDownload(Builder builder) {
074    super();
075    this.downloadUrl = builder.downloadUrl;
076    this.statusUrl = builder.statusUrl;
077    this.expiresAt = builder.expiresAt;
078    this.nameConflicts = builder.nameConflicts;
079    markNullableFieldsAsSet(builder.getExplicitlySetNullableFields());
080  }
081
082  public String getDownloadUrl() {
083    return downloadUrl;
084  }
085
086  public String getStatusUrl() {
087    return statusUrl;
088  }
089
090  public OffsetDateTime getExpiresAt() {
091    return expiresAt;
092  }
093
094  public List<List<ZipDownloadNameConflictsField>> getNameConflicts() {
095    return nameConflicts;
096  }
097
098  @Override
099  public boolean equals(Object o) {
100    if (this == o) {
101      return true;
102    }
103    if (o == null || getClass() != o.getClass()) {
104      return false;
105    }
106    ZipDownload casted = (ZipDownload) o;
107    return Objects.equals(downloadUrl, casted.downloadUrl)
108        && Objects.equals(statusUrl, casted.statusUrl)
109        && Objects.equals(expiresAt, casted.expiresAt)
110        && Objects.equals(nameConflicts, casted.nameConflicts);
111  }
112
113  @Override
114  public int hashCode() {
115    return Objects.hash(downloadUrl, statusUrl, expiresAt, nameConflicts);
116  }
117
118  @Override
119  public String toString() {
120    return "ZipDownload{"
121        + "downloadUrl='"
122        + downloadUrl
123        + '\''
124        + ", "
125        + "statusUrl='"
126        + statusUrl
127        + '\''
128        + ", "
129        + "expiresAt='"
130        + expiresAt
131        + '\''
132        + ", "
133        + "nameConflicts='"
134        + nameConflicts
135        + '\''
136        + "}";
137  }
138
139  public static class Builder extends NullableFieldTracker {
140
141    protected String downloadUrl;
142
143    protected String statusUrl;
144
145    protected OffsetDateTime expiresAt;
146
147    protected List<List<ZipDownloadNameConflictsField>> nameConflicts;
148
149    public Builder downloadUrl(String downloadUrl) {
150      this.downloadUrl = downloadUrl;
151      return this;
152    }
153
154    public Builder statusUrl(String statusUrl) {
155      this.statusUrl = statusUrl;
156      return this;
157    }
158
159    public Builder expiresAt(OffsetDateTime expiresAt) {
160      this.expiresAt = expiresAt;
161      return this;
162    }
163
164    public Builder nameConflicts(List<List<ZipDownloadNameConflictsField>> nameConflicts) {
165      this.nameConflicts = nameConflicts;
166      return this;
167    }
168
169    public ZipDownload build() {
170      return new ZipDownload(this);
171    }
172  }
173}