001package com.box.sdkgen.schemas.weblink;
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 WebLinkSharedLinkField 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 = WebLinkSharedLinkAccessField.WebLinkSharedLinkAccessFieldDeserializer.class)
065  @JsonSerialize(using = WebLinkSharedLinkAccessField.WebLinkSharedLinkAccessFieldSerializer.class)
066  protected EnumWrapper<WebLinkSharedLinkAccessField> 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          WebLinkSharedLinkEffectiveAccessField.WebLinkSharedLinkEffectiveAccessFieldDeserializer
076              .class)
077  @JsonSerialize(
078      using =
079          WebLinkSharedLinkEffectiveAccessField.WebLinkSharedLinkEffectiveAccessFieldSerializer
080              .class)
081  @JsonProperty("effective_access")
082  protected final EnumWrapper<WebLinkSharedLinkEffectiveAccessField> effectiveAccess;
083
084  /**
085   * The effective permissions for this shared link. These result in the more restrictive
086   * combination of the share link permissions and the item permissions set by the administrator,
087   * the owner, and any ancestor item such as a folder.
088   */
089  @JsonDeserialize(
090      using =
091          WebLinkSharedLinkEffectivePermissionField
092              .WebLinkSharedLinkEffectivePermissionFieldDeserializer.class)
093  @JsonSerialize(
094      using =
095          WebLinkSharedLinkEffectivePermissionField
096              .WebLinkSharedLinkEffectivePermissionFieldSerializer.class)
097  @JsonProperty("effective_permission")
098  protected final EnumWrapper<WebLinkSharedLinkEffectivePermissionField> effectivePermission;
099
100  /**
101   * The date and time when this link will be unshared. This field can only be set by users with
102   * paid accounts.
103   */
104  @JsonProperty("unshared_at")
105  @JsonSerialize(using = DateTimeUtils.DateTimeSerializer.class)
106  @JsonDeserialize(using = DateTimeUtils.DateTimeDeserializer.class)
107  @Nullable
108  protected OffsetDateTime unsharedAt;
109
110  /** Defines if the shared link requires a password to access the item. */
111  @JsonProperty("is_password_enabled")
112  protected final boolean isPasswordEnabled;
113
114  /**
115   * Defines if this link allows a user to preview, edit, and download an item. These permissions
116   * refer to the shared link only and do not supersede permissions applied to the item itself.
117   */
118  protected WebLinkSharedLinkPermissionsField permissions;
119
120  /** The number of times this item has been downloaded. */
121  @JsonProperty("download_count")
122  protected final long downloadCount;
123
124  /** The number of times this item has been previewed. */
125  @JsonProperty("preview_count")
126  protected final long previewCount;
127
128  public WebLinkSharedLinkField(
129      String url,
130      WebLinkSharedLinkEffectiveAccessField effectiveAccess,
131      WebLinkSharedLinkEffectivePermissionField effectivePermission,
132      boolean isPasswordEnabled,
133      long downloadCount,
134      long previewCount) {
135    super();
136    this.url = url;
137    this.effectiveAccess = new EnumWrapper<WebLinkSharedLinkEffectiveAccessField>(effectiveAccess);
138    this.effectivePermission =
139        new EnumWrapper<WebLinkSharedLinkEffectivePermissionField>(effectivePermission);
140    this.isPasswordEnabled = isPasswordEnabled;
141    this.downloadCount = downloadCount;
142    this.previewCount = previewCount;
143  }
144
145  public WebLinkSharedLinkField(
146      String url,
147      WebLinkSharedLinkEffectiveAccessField effectiveAccess,
148      EnumWrapper<WebLinkSharedLinkEffectivePermissionField> effectivePermission,
149      boolean isPasswordEnabled,
150      long downloadCount,
151      long previewCount) {
152    super();
153    this.url = url;
154    this.effectiveAccess = new EnumWrapper<WebLinkSharedLinkEffectiveAccessField>(effectiveAccess);
155    this.effectivePermission = effectivePermission;
156    this.isPasswordEnabled = isPasswordEnabled;
157    this.downloadCount = downloadCount;
158    this.previewCount = previewCount;
159  }
160
161  public WebLinkSharedLinkField(
162      String url,
163      EnumWrapper<WebLinkSharedLinkEffectiveAccessField> effectiveAccess,
164      WebLinkSharedLinkEffectivePermissionField effectivePermission,
165      boolean isPasswordEnabled,
166      long downloadCount,
167      long previewCount) {
168    super();
169    this.url = url;
170    this.effectiveAccess = effectiveAccess;
171    this.effectivePermission =
172        new EnumWrapper<WebLinkSharedLinkEffectivePermissionField>(effectivePermission);
173    this.isPasswordEnabled = isPasswordEnabled;
174    this.downloadCount = downloadCount;
175    this.previewCount = previewCount;
176  }
177
178  public WebLinkSharedLinkField(
179      @JsonProperty("url") String url,
180      @JsonProperty("effective_access")
181          EnumWrapper<WebLinkSharedLinkEffectiveAccessField> effectiveAccess,
182      @JsonProperty("effective_permission")
183          EnumWrapper<WebLinkSharedLinkEffectivePermissionField> effectivePermission,
184      @JsonProperty("is_password_enabled") boolean isPasswordEnabled,
185      @JsonProperty("download_count") long downloadCount,
186      @JsonProperty("preview_count") long previewCount) {
187    super();
188    this.url = url;
189    this.effectiveAccess = effectiveAccess;
190    this.effectivePermission = effectivePermission;
191    this.isPasswordEnabled = isPasswordEnabled;
192    this.downloadCount = downloadCount;
193    this.previewCount = previewCount;
194  }
195
196  protected WebLinkSharedLinkField(Builder builder) {
197    super();
198    this.url = builder.url;
199    this.downloadUrl = builder.downloadUrl;
200    this.vanityUrl = builder.vanityUrl;
201    this.vanityName = builder.vanityName;
202    this.access = builder.access;
203    this.effectiveAccess = builder.effectiveAccess;
204    this.effectivePermission = builder.effectivePermission;
205    this.unsharedAt = builder.unsharedAt;
206    this.isPasswordEnabled = builder.isPasswordEnabled;
207    this.permissions = builder.permissions;
208    this.downloadCount = builder.downloadCount;
209    this.previewCount = builder.previewCount;
210    markNullableFieldsAsSet(builder.getExplicitlySetNullableFields());
211  }
212
213  public String getUrl() {
214    return url;
215  }
216
217  public String getDownloadUrl() {
218    return downloadUrl;
219  }
220
221  public String getVanityUrl() {
222    return vanityUrl;
223  }
224
225  public String getVanityName() {
226    return vanityName;
227  }
228
229  public EnumWrapper<WebLinkSharedLinkAccessField> getAccess() {
230    return access;
231  }
232
233  public EnumWrapper<WebLinkSharedLinkEffectiveAccessField> getEffectiveAccess() {
234    return effectiveAccess;
235  }
236
237  public EnumWrapper<WebLinkSharedLinkEffectivePermissionField> getEffectivePermission() {
238    return effectivePermission;
239  }
240
241  public OffsetDateTime getUnsharedAt() {
242    return unsharedAt;
243  }
244
245  public boolean getIsPasswordEnabled() {
246    return isPasswordEnabled;
247  }
248
249  public WebLinkSharedLinkPermissionsField getPermissions() {
250    return permissions;
251  }
252
253  public long getDownloadCount() {
254    return downloadCount;
255  }
256
257  public long getPreviewCount() {
258    return previewCount;
259  }
260
261  @Override
262  public boolean equals(Object o) {
263    if (this == o) {
264      return true;
265    }
266    if (o == null || getClass() != o.getClass()) {
267      return false;
268    }
269    WebLinkSharedLinkField casted = (WebLinkSharedLinkField) o;
270    return Objects.equals(url, casted.url)
271        && Objects.equals(downloadUrl, casted.downloadUrl)
272        && Objects.equals(vanityUrl, casted.vanityUrl)
273        && Objects.equals(vanityName, casted.vanityName)
274        && Objects.equals(access, casted.access)
275        && Objects.equals(effectiveAccess, casted.effectiveAccess)
276        && Objects.equals(effectivePermission, casted.effectivePermission)
277        && Objects.equals(unsharedAt, casted.unsharedAt)
278        && Objects.equals(isPasswordEnabled, casted.isPasswordEnabled)
279        && Objects.equals(permissions, casted.permissions)
280        && Objects.equals(downloadCount, casted.downloadCount)
281        && Objects.equals(previewCount, casted.previewCount);
282  }
283
284  @Override
285  public int hashCode() {
286    return Objects.hash(
287        url,
288        downloadUrl,
289        vanityUrl,
290        vanityName,
291        access,
292        effectiveAccess,
293        effectivePermission,
294        unsharedAt,
295        isPasswordEnabled,
296        permissions,
297        downloadCount,
298        previewCount);
299  }
300
301  @Override
302  public String toString() {
303    return "WebLinkSharedLinkField{"
304        + "url='"
305        + url
306        + '\''
307        + ", "
308        + "downloadUrl='"
309        + downloadUrl
310        + '\''
311        + ", "
312        + "vanityUrl='"
313        + vanityUrl
314        + '\''
315        + ", "
316        + "vanityName='"
317        + vanityName
318        + '\''
319        + ", "
320        + "access='"
321        + access
322        + '\''
323        + ", "
324        + "effectiveAccess='"
325        + effectiveAccess
326        + '\''
327        + ", "
328        + "effectivePermission='"
329        + effectivePermission
330        + '\''
331        + ", "
332        + "unsharedAt='"
333        + unsharedAt
334        + '\''
335        + ", "
336        + "isPasswordEnabled='"
337        + isPasswordEnabled
338        + '\''
339        + ", "
340        + "permissions='"
341        + permissions
342        + '\''
343        + ", "
344        + "downloadCount='"
345        + downloadCount
346        + '\''
347        + ", "
348        + "previewCount='"
349        + previewCount
350        + '\''
351        + "}";
352  }
353
354  public static class Builder extends NullableFieldTracker {
355
356    protected final String url;
357
358    protected String downloadUrl;
359
360    protected String vanityUrl;
361
362    protected String vanityName;
363
364    protected EnumWrapper<WebLinkSharedLinkAccessField> access;
365
366    protected final EnumWrapper<WebLinkSharedLinkEffectiveAccessField> effectiveAccess;
367
368    protected final EnumWrapper<WebLinkSharedLinkEffectivePermissionField> effectivePermission;
369
370    protected OffsetDateTime unsharedAt;
371
372    protected final boolean isPasswordEnabled;
373
374    protected WebLinkSharedLinkPermissionsField permissions;
375
376    protected final long downloadCount;
377
378    protected final long previewCount;
379
380    public Builder(
381        String url,
382        WebLinkSharedLinkEffectiveAccessField effectiveAccess,
383        WebLinkSharedLinkEffectivePermissionField effectivePermission,
384        boolean isPasswordEnabled,
385        long downloadCount,
386        long previewCount) {
387      super();
388      this.url = url;
389      this.effectiveAccess =
390          new EnumWrapper<WebLinkSharedLinkEffectiveAccessField>(effectiveAccess);
391      this.effectivePermission =
392          new EnumWrapper<WebLinkSharedLinkEffectivePermissionField>(effectivePermission);
393      this.isPasswordEnabled = isPasswordEnabled;
394      this.downloadCount = downloadCount;
395      this.previewCount = previewCount;
396    }
397
398    public Builder(
399        String url,
400        WebLinkSharedLinkEffectiveAccessField effectiveAccess,
401        EnumWrapper<WebLinkSharedLinkEffectivePermissionField> effectivePermission,
402        boolean isPasswordEnabled,
403        long downloadCount,
404        long previewCount) {
405      super();
406      this.url = url;
407      this.effectiveAccess =
408          new EnumWrapper<WebLinkSharedLinkEffectiveAccessField>(effectiveAccess);
409      this.effectivePermission = effectivePermission;
410      this.isPasswordEnabled = isPasswordEnabled;
411      this.downloadCount = downloadCount;
412      this.previewCount = previewCount;
413    }
414
415    public Builder(
416        String url,
417        EnumWrapper<WebLinkSharedLinkEffectiveAccessField> effectiveAccess,
418        WebLinkSharedLinkEffectivePermissionField effectivePermission,
419        boolean isPasswordEnabled,
420        long downloadCount,
421        long previewCount) {
422      super();
423      this.url = url;
424      this.effectiveAccess = effectiveAccess;
425      this.effectivePermission =
426          new EnumWrapper<WebLinkSharedLinkEffectivePermissionField>(effectivePermission);
427      this.isPasswordEnabled = isPasswordEnabled;
428      this.downloadCount = downloadCount;
429      this.previewCount = previewCount;
430    }
431
432    public Builder(
433        String url,
434        EnumWrapper<WebLinkSharedLinkEffectiveAccessField> effectiveAccess,
435        EnumWrapper<WebLinkSharedLinkEffectivePermissionField> effectivePermission,
436        boolean isPasswordEnabled,
437        long downloadCount,
438        long previewCount) {
439      super();
440      this.url = url;
441      this.effectiveAccess = effectiveAccess;
442      this.effectivePermission = effectivePermission;
443      this.isPasswordEnabled = isPasswordEnabled;
444      this.downloadCount = downloadCount;
445      this.previewCount = previewCount;
446    }
447
448    public Builder downloadUrl(String downloadUrl) {
449      this.downloadUrl = downloadUrl;
450      this.markNullableFieldAsSet("download_url");
451      return this;
452    }
453
454    public Builder vanityUrl(String vanityUrl) {
455      this.vanityUrl = vanityUrl;
456      this.markNullableFieldAsSet("vanity_url");
457      return this;
458    }
459
460    public Builder vanityName(String vanityName) {
461      this.vanityName = vanityName;
462      this.markNullableFieldAsSet("vanity_name");
463      return this;
464    }
465
466    public Builder access(WebLinkSharedLinkAccessField access) {
467      this.access = new EnumWrapper<WebLinkSharedLinkAccessField>(access);
468      return this;
469    }
470
471    public Builder access(EnumWrapper<WebLinkSharedLinkAccessField> access) {
472      this.access = access;
473      return this;
474    }
475
476    public Builder unsharedAt(OffsetDateTime unsharedAt) {
477      this.unsharedAt = unsharedAt;
478      this.markNullableFieldAsSet("unshared_at");
479      return this;
480    }
481
482    public Builder permissions(WebLinkSharedLinkPermissionsField permissions) {
483      this.permissions = permissions;
484      return this;
485    }
486
487    public WebLinkSharedLinkField build() {
488      return new WebLinkSharedLinkField(this);
489    }
490  }
491}