001package com.box.sdkgen.schemas.folder;
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.serialization.json.EnumWrapper;
008import com.fasterxml.jackson.annotation.JsonFilter;
009import com.fasterxml.jackson.annotation.JsonProperty;
010import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
011import com.fasterxml.jackson.databind.annotation.JsonSerialize;
012import java.time.OffsetDateTime;
013import java.util.Objects;
014
015@JsonFilter("nullablePropertyFilter")
016public class FolderSharedLinkField extends SerializableObject {
017
018  /**
019   * The URL that can be used to access the item on Box.
020   *
021   * <p>This URL will display the item in Box's preview UI where the file can be downloaded if
022   * allowed.
023   *
024   * <p>This URL will continue to work even when a custom `vanity_url` has been set for this shared
025   * link.
026   */
027  protected final String url;
028
029  /**
030   * A URL that can be used to download the file. This URL can be used in a browser to download the
031   * file. This URL includes the file extension so that the file will be saved with the right file
032   * type.
033   *
034   * <p>This property will be `null` for folders.
035   */
036  @JsonProperty("download_url")
037  @Nullable
038  protected String downloadUrl;
039
040  /**
041   * The "Custom URL" that can also be used to preview the item on Box. Custom URLs can only be
042   * created or modified in the Box Web application.
043   */
044  @JsonProperty("vanity_url")
045  @Nullable
046  protected String vanityUrl;
047
048  /** The custom name of a shared link, as used in the `vanity_url` field. */
049  @JsonProperty("vanity_name")
050  @Nullable
051  protected String vanityName;
052
053  /**
054   * The access level for this shared link.
055   *
056   * <p>* `open` - provides access to this item to anyone with this link * `company` - only provides
057   * access to this item to people the same company * `collaborators` - only provides access to this
058   * item to people who are collaborators on this item
059   *
060   * <p>If this field is omitted when creating the shared link, the access level will be set to the
061   * default access level specified by the enterprise admin.
062   */
063  @JsonDeserialize(
064      using = FolderSharedLinkAccessField.FolderSharedLinkAccessFieldDeserializer.class)
065  @JsonSerialize(using = FolderSharedLinkAccessField.FolderSharedLinkAccessFieldSerializer.class)
066  protected EnumWrapper<FolderSharedLinkAccessField> access;
067
068  /**
069   * The effective access level for the shared link. This can be a more restrictive access level
070   * than the value in the `access` field when the enterprise settings restrict the allowed access
071   * levels.
072   */
073  @JsonDeserialize(
074      using =
075          FolderSharedLinkEffectiveAccessField.FolderSharedLinkEffectiveAccessFieldDeserializer
076              .class)
077  @JsonSerialize(
078      using =
079          FolderSharedLinkEffectiveAccessField.FolderSharedLinkEffectiveAccessFieldSerializer.class)
080  @JsonProperty("effective_access")
081  protected final EnumWrapper<FolderSharedLinkEffectiveAccessField> effectiveAccess;
082
083  /**
084   * The effective permissions for this shared link. These result in the more restrictive
085   * combination of the share link permissions and the item permissions set by the administrator,
086   * the owner, and any ancestor item such as a folder.
087   */
088  @JsonDeserialize(
089      using =
090          FolderSharedLinkEffectivePermissionField
091              .FolderSharedLinkEffectivePermissionFieldDeserializer.class)
092  @JsonSerialize(
093      using =
094          FolderSharedLinkEffectivePermissionField
095              .FolderSharedLinkEffectivePermissionFieldSerializer.class)
096  @JsonProperty("effective_permission")
097  protected final EnumWrapper<FolderSharedLinkEffectivePermissionField> effectivePermission;
098
099  /**
100   * The date and time when this link will be unshared. This field can only be set by users with
101   * paid accounts.
102   */
103  @JsonProperty("unshared_at")
104  @JsonSerialize(using = DateTimeUtils.DateTimeSerializer.class)
105  @JsonDeserialize(using = DateTimeUtils.DateTimeDeserializer.class)
106  @Nullable
107  protected OffsetDateTime unsharedAt;
108
109  /** Defines if the shared link requires a password to access the item. */
110  @JsonProperty("is_password_enabled")
111  protected final boolean isPasswordEnabled;
112
113  /**
114   * Defines if this link allows a user to preview, edit, and download an item. These permissions
115   * refer to the shared link only and do not supersede permissions applied to the item itself.
116   */
117  protected FolderSharedLinkPermissionsField permissions;
118
119  /** The number of times this item has been downloaded. */
120  @JsonProperty("download_count")
121  protected final long downloadCount;
122
123  /** The number of times this item has been previewed. */
124  @JsonProperty("preview_count")
125  protected final long previewCount;
126
127  public FolderSharedLinkField(
128      String url,
129      FolderSharedLinkEffectiveAccessField effectiveAccess,
130      FolderSharedLinkEffectivePermissionField effectivePermission,
131      boolean isPasswordEnabled,
132      long downloadCount,
133      long previewCount) {
134    super();
135    this.url = url;
136    this.effectiveAccess = new EnumWrapper<FolderSharedLinkEffectiveAccessField>(effectiveAccess);
137    this.effectivePermission =
138        new EnumWrapper<FolderSharedLinkEffectivePermissionField>(effectivePermission);
139    this.isPasswordEnabled = isPasswordEnabled;
140    this.downloadCount = downloadCount;
141    this.previewCount = previewCount;
142  }
143
144  public FolderSharedLinkField(
145      String url,
146      FolderSharedLinkEffectiveAccessField effectiveAccess,
147      EnumWrapper<FolderSharedLinkEffectivePermissionField> effectivePermission,
148      boolean isPasswordEnabled,
149      long downloadCount,
150      long previewCount) {
151    super();
152    this.url = url;
153    this.effectiveAccess = new EnumWrapper<FolderSharedLinkEffectiveAccessField>(effectiveAccess);
154    this.effectivePermission = effectivePermission;
155    this.isPasswordEnabled = isPasswordEnabled;
156    this.downloadCount = downloadCount;
157    this.previewCount = previewCount;
158  }
159
160  public FolderSharedLinkField(
161      String url,
162      EnumWrapper<FolderSharedLinkEffectiveAccessField> effectiveAccess,
163      FolderSharedLinkEffectivePermissionField effectivePermission,
164      boolean isPasswordEnabled,
165      long downloadCount,
166      long previewCount) {
167    super();
168    this.url = url;
169    this.effectiveAccess = effectiveAccess;
170    this.effectivePermission =
171        new EnumWrapper<FolderSharedLinkEffectivePermissionField>(effectivePermission);
172    this.isPasswordEnabled = isPasswordEnabled;
173    this.downloadCount = downloadCount;
174    this.previewCount = previewCount;
175  }
176
177  public FolderSharedLinkField(
178      @JsonProperty("url") String url,
179      @JsonProperty("effective_access")
180          EnumWrapper<FolderSharedLinkEffectiveAccessField> effectiveAccess,
181      @JsonProperty("effective_permission")
182          EnumWrapper<FolderSharedLinkEffectivePermissionField> effectivePermission,
183      @JsonProperty("is_password_enabled") boolean isPasswordEnabled,
184      @JsonProperty("download_count") long downloadCount,
185      @JsonProperty("preview_count") long previewCount) {
186    super();
187    this.url = url;
188    this.effectiveAccess = effectiveAccess;
189    this.effectivePermission = effectivePermission;
190    this.isPasswordEnabled = isPasswordEnabled;
191    this.downloadCount = downloadCount;
192    this.previewCount = previewCount;
193  }
194
195  protected FolderSharedLinkField(Builder builder) {
196    super();
197    this.url = builder.url;
198    this.downloadUrl = builder.downloadUrl;
199    this.vanityUrl = builder.vanityUrl;
200    this.vanityName = builder.vanityName;
201    this.access = builder.access;
202    this.effectiveAccess = builder.effectiveAccess;
203    this.effectivePermission = builder.effectivePermission;
204    this.unsharedAt = builder.unsharedAt;
205    this.isPasswordEnabled = builder.isPasswordEnabled;
206    this.permissions = builder.permissions;
207    this.downloadCount = builder.downloadCount;
208    this.previewCount = builder.previewCount;
209    markNullableFieldsAsSet(builder.getExplicitlySetNullableFields());
210  }
211
212  public String getUrl() {
213    return url;
214  }
215
216  public String getDownloadUrl() {
217    return downloadUrl;
218  }
219
220  public String getVanityUrl() {
221    return vanityUrl;
222  }
223
224  public String getVanityName() {
225    return vanityName;
226  }
227
228  public EnumWrapper<FolderSharedLinkAccessField> getAccess() {
229    return access;
230  }
231
232  public EnumWrapper<FolderSharedLinkEffectiveAccessField> getEffectiveAccess() {
233    return effectiveAccess;
234  }
235
236  public EnumWrapper<FolderSharedLinkEffectivePermissionField> getEffectivePermission() {
237    return effectivePermission;
238  }
239
240  public OffsetDateTime getUnsharedAt() {
241    return unsharedAt;
242  }
243
244  public boolean getIsPasswordEnabled() {
245    return isPasswordEnabled;
246  }
247
248  public FolderSharedLinkPermissionsField getPermissions() {
249    return permissions;
250  }
251
252  public long getDownloadCount() {
253    return downloadCount;
254  }
255
256  public long getPreviewCount() {
257    return previewCount;
258  }
259
260  @Override
261  public boolean equals(Object o) {
262    if (this == o) {
263      return true;
264    }
265    if (o == null || getClass() != o.getClass()) {
266      return false;
267    }
268    FolderSharedLinkField casted = (FolderSharedLinkField) o;
269    return Objects.equals(url, casted.url)
270        && Objects.equals(downloadUrl, casted.downloadUrl)
271        && Objects.equals(vanityUrl, casted.vanityUrl)
272        && Objects.equals(vanityName, casted.vanityName)
273        && Objects.equals(access, casted.access)
274        && Objects.equals(effectiveAccess, casted.effectiveAccess)
275        && Objects.equals(effectivePermission, casted.effectivePermission)
276        && Objects.equals(unsharedAt, casted.unsharedAt)
277        && Objects.equals(isPasswordEnabled, casted.isPasswordEnabled)
278        && Objects.equals(permissions, casted.permissions)
279        && Objects.equals(downloadCount, casted.downloadCount)
280        && Objects.equals(previewCount, casted.previewCount);
281  }
282
283  @Override
284  public int hashCode() {
285    return Objects.hash(
286        url,
287        downloadUrl,
288        vanityUrl,
289        vanityName,
290        access,
291        effectiveAccess,
292        effectivePermission,
293        unsharedAt,
294        isPasswordEnabled,
295        permissions,
296        downloadCount,
297        previewCount);
298  }
299
300  @Override
301  public String toString() {
302    return "FolderSharedLinkField{"
303        + "url='"
304        + url
305        + '\''
306        + ", "
307        + "downloadUrl='"
308        + downloadUrl
309        + '\''
310        + ", "
311        + "vanityUrl='"
312        + vanityUrl
313        + '\''
314        + ", "
315        + "vanityName='"
316        + vanityName
317        + '\''
318        + ", "
319        + "access='"
320        + access
321        + '\''
322        + ", "
323        + "effectiveAccess='"
324        + effectiveAccess
325        + '\''
326        + ", "
327        + "effectivePermission='"
328        + effectivePermission
329        + '\''
330        + ", "
331        + "unsharedAt='"
332        + unsharedAt
333        + '\''
334        + ", "
335        + "isPasswordEnabled='"
336        + isPasswordEnabled
337        + '\''
338        + ", "
339        + "permissions='"
340        + permissions
341        + '\''
342        + ", "
343        + "downloadCount='"
344        + downloadCount
345        + '\''
346        + ", "
347        + "previewCount='"
348        + previewCount
349        + '\''
350        + "}";
351  }
352
353  public static class Builder extends NullableFieldTracker {
354
355    protected final String url;
356
357    protected String downloadUrl;
358
359    protected String vanityUrl;
360
361    protected String vanityName;
362
363    protected EnumWrapper<FolderSharedLinkAccessField> access;
364
365    protected final EnumWrapper<FolderSharedLinkEffectiveAccessField> effectiveAccess;
366
367    protected final EnumWrapper<FolderSharedLinkEffectivePermissionField> effectivePermission;
368
369    protected OffsetDateTime unsharedAt;
370
371    protected final boolean isPasswordEnabled;
372
373    protected FolderSharedLinkPermissionsField permissions;
374
375    protected final long downloadCount;
376
377    protected final long previewCount;
378
379    public Builder(
380        String url,
381        FolderSharedLinkEffectiveAccessField effectiveAccess,
382        FolderSharedLinkEffectivePermissionField effectivePermission,
383        boolean isPasswordEnabled,
384        long downloadCount,
385        long previewCount) {
386      super();
387      this.url = url;
388      this.effectiveAccess = new EnumWrapper<FolderSharedLinkEffectiveAccessField>(effectiveAccess);
389      this.effectivePermission =
390          new EnumWrapper<FolderSharedLinkEffectivePermissionField>(effectivePermission);
391      this.isPasswordEnabled = isPasswordEnabled;
392      this.downloadCount = downloadCount;
393      this.previewCount = previewCount;
394    }
395
396    public Builder(
397        String url,
398        FolderSharedLinkEffectiveAccessField effectiveAccess,
399        EnumWrapper<FolderSharedLinkEffectivePermissionField> effectivePermission,
400        boolean isPasswordEnabled,
401        long downloadCount,
402        long previewCount) {
403      super();
404      this.url = url;
405      this.effectiveAccess = new EnumWrapper<FolderSharedLinkEffectiveAccessField>(effectiveAccess);
406      this.effectivePermission = effectivePermission;
407      this.isPasswordEnabled = isPasswordEnabled;
408      this.downloadCount = downloadCount;
409      this.previewCount = previewCount;
410    }
411
412    public Builder(
413        String url,
414        EnumWrapper<FolderSharedLinkEffectiveAccessField> effectiveAccess,
415        FolderSharedLinkEffectivePermissionField effectivePermission,
416        boolean isPasswordEnabled,
417        long downloadCount,
418        long previewCount) {
419      super();
420      this.url = url;
421      this.effectiveAccess = effectiveAccess;
422      this.effectivePermission =
423          new EnumWrapper<FolderSharedLinkEffectivePermissionField>(effectivePermission);
424      this.isPasswordEnabled = isPasswordEnabled;
425      this.downloadCount = downloadCount;
426      this.previewCount = previewCount;
427    }
428
429    public Builder(
430        String url,
431        EnumWrapper<FolderSharedLinkEffectiveAccessField> effectiveAccess,
432        EnumWrapper<FolderSharedLinkEffectivePermissionField> effectivePermission,
433        boolean isPasswordEnabled,
434        long downloadCount,
435        long previewCount) {
436      super();
437      this.url = url;
438      this.effectiveAccess = effectiveAccess;
439      this.effectivePermission = effectivePermission;
440      this.isPasswordEnabled = isPasswordEnabled;
441      this.downloadCount = downloadCount;
442      this.previewCount = previewCount;
443    }
444
445    public Builder downloadUrl(String downloadUrl) {
446      this.downloadUrl = downloadUrl;
447      this.markNullableFieldAsSet("download_url");
448      return this;
449    }
450
451    public Builder vanityUrl(String vanityUrl) {
452      this.vanityUrl = vanityUrl;
453      this.markNullableFieldAsSet("vanity_url");
454      return this;
455    }
456
457    public Builder vanityName(String vanityName) {
458      this.vanityName = vanityName;
459      this.markNullableFieldAsSet("vanity_name");
460      return this;
461    }
462
463    public Builder access(FolderSharedLinkAccessField access) {
464      this.access = new EnumWrapper<FolderSharedLinkAccessField>(access);
465      return this;
466    }
467
468    public Builder access(EnumWrapper<FolderSharedLinkAccessField> access) {
469      this.access = access;
470      return this;
471    }
472
473    public Builder unsharedAt(OffsetDateTime unsharedAt) {
474      this.unsharedAt = unsharedAt;
475      this.markNullableFieldAsSet("unshared_at");
476      return this;
477    }
478
479    public Builder permissions(FolderSharedLinkPermissionsField permissions) {
480      this.permissions = permissions;
481      return this;
482    }
483
484    public FolderSharedLinkField build() {
485      return new FolderSharedLinkField(this);
486    }
487  }
488}