001package com.box.sdkgen.managers.usercollaborations;
002
003import com.box.sdkgen.internal.NullableFieldTracker;
004import com.box.sdkgen.internal.SerializableObject;
005import com.box.sdkgen.internal.utils.DateTimeUtils;
006import com.box.sdkgen.serialization.json.EnumWrapper;
007import com.fasterxml.jackson.annotation.JsonFilter;
008import com.fasterxml.jackson.annotation.JsonProperty;
009import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
010import com.fasterxml.jackson.databind.annotation.JsonSerialize;
011import java.time.OffsetDateTime;
012import java.util.Objects;
013
014@JsonFilter("nullablePropertyFilter")
015public class CreateCollaborationRequestBody extends SerializableObject {
016
017  /** The item to attach the comment to. */
018  protected final CreateCollaborationRequestBodyItemField item;
019
020  /** The user or group to give access to the item. */
021  @JsonProperty("accessible_by")
022  protected final CreateCollaborationRequestBodyAccessibleByField accessibleBy;
023
024  /** The level of access granted. */
025  @JsonDeserialize(
026      using =
027          CreateCollaborationRequestBodyRoleField
028              .CreateCollaborationRequestBodyRoleFieldDeserializer.class)
029  @JsonSerialize(
030      using =
031          CreateCollaborationRequestBodyRoleField.CreateCollaborationRequestBodyRoleFieldSerializer
032              .class)
033  protected final EnumWrapper<CreateCollaborationRequestBodyRoleField> role;
034
035  /**
036   * If set to `true`, collaborators have access to shared items, but such items won't be visible in
037   * the All Files list. Additionally, collaborators won't see the path to the root folder for the
038   * shared item.
039   */
040  @JsonProperty("is_access_only")
041  protected Boolean isAccessOnly;
042
043  /**
044   * Determines if the invited users can see the entire parent path to the associated folder. The
045   * user will not gain privileges in any parent folder and therefore can not see content the user
046   * is not collaborated on.
047   *
048   * <p>Be aware that this meaningfully increases the time required to load the invitee's **All
049   * Files** page. We recommend you limit the number of collaborations with `can_view_path` enabled
050   * to 1,000 per user.
051   *
052   * <p>Only an owner or co-owners can invite collaborators with a `can_view_path` of `true`. Only
053   * an owner can update `can_view_path` on existing collaborations.
054   *
055   * <p>`can_view_path` can only be used for folder collaborations.
056   *
057   * <p>When you delete a folder with `can_view_path=true`, collaborators may still see the parent
058   * path. For instructions on how to remove this, see [Even though a folder invited via
059   * can_view_path is deleted, the path remains
060   * displayed](https://support.box.com/hc/en-us/articles/37472814319891-Even-though-a-folder-invited-via-can-view-path-is-deleted-the-path-remains-displayed).
061   */
062  @JsonProperty("can_view_path")
063  protected Boolean canViewPath;
064
065  /**
066   * Set the expiration date for the collaboration. At this date, the collaboration will be
067   * automatically removed from the item.
068   *
069   * <p>This feature will only work if the **Automatically remove invited collaborators: Allow
070   * folder owners to extend the expiry date** setting has been enabled in the **Enterprise
071   * Settings** of the **Admin Console**. When the setting is not enabled, collaborations can not
072   * have an expiry date and a value for this field will be result in an error.
073   */
074  @JsonProperty("expires_at")
075  @JsonSerialize(using = DateTimeUtils.DateTimeSerializer.class)
076  @JsonDeserialize(using = DateTimeUtils.DateTimeDeserializer.class)
077  protected OffsetDateTime expiresAt;
078
079  public CreateCollaborationRequestBody(
080      CreateCollaborationRequestBodyItemField item,
081      CreateCollaborationRequestBodyAccessibleByField accessibleBy,
082      CreateCollaborationRequestBodyRoleField role) {
083    super();
084    this.item = item;
085    this.accessibleBy = accessibleBy;
086    this.role = new EnumWrapper<CreateCollaborationRequestBodyRoleField>(role);
087  }
088
089  public CreateCollaborationRequestBody(
090      @JsonProperty("item") CreateCollaborationRequestBodyItemField item,
091      @JsonProperty("accessible_by") CreateCollaborationRequestBodyAccessibleByField accessibleBy,
092      @JsonProperty("role") EnumWrapper<CreateCollaborationRequestBodyRoleField> role) {
093    super();
094    this.item = item;
095    this.accessibleBy = accessibleBy;
096    this.role = role;
097  }
098
099  protected CreateCollaborationRequestBody(Builder builder) {
100    super();
101    this.item = builder.item;
102    this.accessibleBy = builder.accessibleBy;
103    this.role = builder.role;
104    this.isAccessOnly = builder.isAccessOnly;
105    this.canViewPath = builder.canViewPath;
106    this.expiresAt = builder.expiresAt;
107    markNullableFieldsAsSet(builder.getExplicitlySetNullableFields());
108  }
109
110  public CreateCollaborationRequestBodyItemField getItem() {
111    return item;
112  }
113
114  public CreateCollaborationRequestBodyAccessibleByField getAccessibleBy() {
115    return accessibleBy;
116  }
117
118  public EnumWrapper<CreateCollaborationRequestBodyRoleField> getRole() {
119    return role;
120  }
121
122  public Boolean getIsAccessOnly() {
123    return isAccessOnly;
124  }
125
126  public Boolean getCanViewPath() {
127    return canViewPath;
128  }
129
130  public OffsetDateTime getExpiresAt() {
131    return expiresAt;
132  }
133
134  @Override
135  public boolean equals(Object o) {
136    if (this == o) {
137      return true;
138    }
139    if (o == null || getClass() != o.getClass()) {
140      return false;
141    }
142    CreateCollaborationRequestBody casted = (CreateCollaborationRequestBody) o;
143    return Objects.equals(item, casted.item)
144        && Objects.equals(accessibleBy, casted.accessibleBy)
145        && Objects.equals(role, casted.role)
146        && Objects.equals(isAccessOnly, casted.isAccessOnly)
147        && Objects.equals(canViewPath, casted.canViewPath)
148        && Objects.equals(expiresAt, casted.expiresAt);
149  }
150
151  @Override
152  public int hashCode() {
153    return Objects.hash(item, accessibleBy, role, isAccessOnly, canViewPath, expiresAt);
154  }
155
156  @Override
157  public String toString() {
158    return "CreateCollaborationRequestBody{"
159        + "item='"
160        + item
161        + '\''
162        + ", "
163        + "accessibleBy='"
164        + accessibleBy
165        + '\''
166        + ", "
167        + "role='"
168        + role
169        + '\''
170        + ", "
171        + "isAccessOnly='"
172        + isAccessOnly
173        + '\''
174        + ", "
175        + "canViewPath='"
176        + canViewPath
177        + '\''
178        + ", "
179        + "expiresAt='"
180        + expiresAt
181        + '\''
182        + "}";
183  }
184
185  public static class Builder extends NullableFieldTracker {
186
187    protected final CreateCollaborationRequestBodyItemField item;
188
189    protected final CreateCollaborationRequestBodyAccessibleByField accessibleBy;
190
191    protected final EnumWrapper<CreateCollaborationRequestBodyRoleField> role;
192
193    protected Boolean isAccessOnly;
194
195    protected Boolean canViewPath;
196
197    protected OffsetDateTime expiresAt;
198
199    public Builder(
200        CreateCollaborationRequestBodyItemField item,
201        CreateCollaborationRequestBodyAccessibleByField accessibleBy,
202        CreateCollaborationRequestBodyRoleField role) {
203      super();
204      this.item = item;
205      this.accessibleBy = accessibleBy;
206      this.role = new EnumWrapper<CreateCollaborationRequestBodyRoleField>(role);
207    }
208
209    public Builder(
210        CreateCollaborationRequestBodyItemField item,
211        CreateCollaborationRequestBodyAccessibleByField accessibleBy,
212        EnumWrapper<CreateCollaborationRequestBodyRoleField> role) {
213      super();
214      this.item = item;
215      this.accessibleBy = accessibleBy;
216      this.role = role;
217    }
218
219    public Builder isAccessOnly(Boolean isAccessOnly) {
220      this.isAccessOnly = isAccessOnly;
221      return this;
222    }
223
224    public Builder canViewPath(Boolean canViewPath) {
225      this.canViewPath = canViewPath;
226      return this;
227    }
228
229    public Builder expiresAt(OffsetDateTime expiresAt) {
230      this.expiresAt = expiresAt;
231      return this;
232    }
233
234    public CreateCollaborationRequestBody build() {
235      return new CreateCollaborationRequestBody(this);
236    }
237  }
238}