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