• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

box / box-java-sdk / #7261

10 Jun 2026 03:14PM UTC coverage: 34.885% (-0.1%) from 34.986%
#7261

push

github

web-flow
feat: Add new event types (box/box-openapi#1703) (box/box-openapi#605) (#1889)

Co-authored-by: box-sdk-build <box-sdk-build@box.com>

40 of 60 new or added lines in 3 files covered. (66.67%)

136 existing lines in 11 files now uncovered.

19490 of 55869 relevant lines covered (34.89%)

0.35 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

87.23
/src/main/java/com/box/sdkgen/managers/usercollaborations/UserCollaborationsManager.java
1
package com.box.sdkgen.managers.usercollaborations;
2

3
import static com.box.sdkgen.internal.utils.UtilsManager.convertToString;
4
import static com.box.sdkgen.internal.utils.UtilsManager.entryOf;
5
import static com.box.sdkgen.internal.utils.UtilsManager.mapOf;
6
import static com.box.sdkgen.internal.utils.UtilsManager.mergeMaps;
7
import static com.box.sdkgen.internal.utils.UtilsManager.prepareParams;
8

9
import com.box.sdkgen.networking.auth.Authentication;
10
import com.box.sdkgen.networking.fetchoptions.FetchOptions;
11
import com.box.sdkgen.networking.fetchoptions.ResponseFormat;
12
import com.box.sdkgen.networking.fetchresponse.FetchResponse;
13
import com.box.sdkgen.networking.network.NetworkSession;
14
import com.box.sdkgen.schemas.collaboration.Collaboration;
15
import com.box.sdkgen.serialization.json.JsonManager;
16
import java.util.Map;
17

18
public class UserCollaborationsManager {
19

20
  public Authentication auth;
21

22
  public NetworkSession networkSession;
23

24
  public UserCollaborationsManager() {
×
25
    this.networkSession = new NetworkSession();
×
26
  }
×
27

28
  protected UserCollaborationsManager(Builder builder) {
1✔
29
    this.auth = builder.auth;
1✔
30
    this.networkSession = builder.networkSession;
1✔
31
  }
1✔
32

33
  /**
34
   * Retrieves a single collaboration.
35
   *
36
   * @param collaborationId The ID of the collaboration. Example: "1234"
37
   */
38
  public Collaboration getCollaborationById(String collaborationId) {
39
    return getCollaborationById(
1✔
40
        collaborationId, new GetCollaborationByIdQueryParams(), new GetCollaborationByIdHeaders());
41
  }
42

43
  /**
44
   * Retrieves a single collaboration.
45
   *
46
   * @param collaborationId The ID of the collaboration. Example: "1234"
47
   * @param queryParams Query parameters of getCollaborationById method
48
   */
49
  public Collaboration getCollaborationById(
50
      String collaborationId, GetCollaborationByIdQueryParams queryParams) {
51
    return getCollaborationById(collaborationId, queryParams, new GetCollaborationByIdHeaders());
×
52
  }
53

54
  /**
55
   * Retrieves a single collaboration.
56
   *
57
   * @param collaborationId The ID of the collaboration. Example: "1234"
58
   * @param headers Headers of getCollaborationById method
59
   */
60
  public Collaboration getCollaborationById(
61
      String collaborationId, GetCollaborationByIdHeaders headers) {
62
    return getCollaborationById(collaborationId, new GetCollaborationByIdQueryParams(), headers);
×
63
  }
64

65
  /**
66
   * Retrieves a single collaboration.
67
   *
68
   * @param collaborationId The ID of the collaboration. Example: "1234"
69
   * @param queryParams Query parameters of getCollaborationById method
70
   * @param headers Headers of getCollaborationById method
71
   */
72
  public Collaboration getCollaborationById(
73
      String collaborationId,
74
      GetCollaborationByIdQueryParams queryParams,
75
      GetCollaborationByIdHeaders headers) {
76
    Map<String, String> queryParamsMap =
1✔
77
        prepareParams(mapOf(entryOf("fields", convertToString(queryParams.getFields()))));
1✔
78
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
1✔
79
    FetchResponse response =
1✔
80
        this.networkSession
81
            .getNetworkClient()
1✔
82
            .fetch(
1✔
83
                new FetchOptions.Builder(
84
                        String.join(
1✔
85
                            "",
86
                            this.networkSession.getBaseUrls().getBaseUrl(),
1✔
87
                            "/2.0/collaborations/",
88
                            convertToString(collaborationId)),
1✔
89
                        "GET")
90
                    .params(queryParamsMap)
1✔
91
                    .headers(headersMap)
1✔
92
                    .responseFormat(ResponseFormat.JSON)
1✔
93
                    .auth(this.auth)
1✔
94
                    .networkSession(this.networkSession)
1✔
95
                    .build());
1✔
96
    return JsonManager.deserialize(response.getData(), Collaboration.class);
1✔
97
  }
98

99
  /**
100
   * Updates a collaboration. Can be used to change the owner of an item, or to accept collaboration
101
   * invites. In case of accepting collaboration invite, role is not required.
102
   *
103
   * @param collaborationId The ID of the collaboration. Example: "1234"
104
   */
105
  public Collaboration updateCollaborationById(String collaborationId) {
106
    return updateCollaborationById(
×
107
        collaborationId,
108
        new UpdateCollaborationByIdRequestBody(),
109
        new UpdateCollaborationByIdHeaders());
110
  }
111

112
  /**
113
   * Updates a collaboration. Can be used to change the owner of an item, or to accept collaboration
114
   * invites. In case of accepting collaboration invite, role is not required.
115
   *
116
   * @param collaborationId The ID of the collaboration. Example: "1234"
117
   * @param requestBody Request body of updateCollaborationById method
118
   */
119
  public Collaboration updateCollaborationById(
120
      String collaborationId, UpdateCollaborationByIdRequestBody requestBody) {
121
    return updateCollaborationById(
1✔
122
        collaborationId, requestBody, new UpdateCollaborationByIdHeaders());
123
  }
124

125
  /**
126
   * Updates a collaboration. Can be used to change the owner of an item, or to accept collaboration
127
   * invites. In case of accepting collaboration invite, role is not required.
128
   *
129
   * @param collaborationId The ID of the collaboration. Example: "1234"
130
   * @param headers Headers of updateCollaborationById method
131
   */
132
  public Collaboration updateCollaborationById(
133
      String collaborationId, UpdateCollaborationByIdHeaders headers) {
134
    return updateCollaborationById(
×
135
        collaborationId, new UpdateCollaborationByIdRequestBody(), headers);
136
  }
137

138
  /**
139
   * Updates a collaboration. Can be used to change the owner of an item, or to accept collaboration
140
   * invites. In case of accepting collaboration invite, role is not required.
141
   *
142
   * @param collaborationId The ID of the collaboration. Example: "1234"
143
   * @param requestBody Request body of updateCollaborationById method
144
   * @param headers Headers of updateCollaborationById method
145
   */
146
  public Collaboration updateCollaborationById(
147
      String collaborationId,
148
      UpdateCollaborationByIdRequestBody requestBody,
149
      UpdateCollaborationByIdHeaders headers) {
150
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
1✔
151
    FetchResponse response =
1✔
152
        this.networkSession
153
            .getNetworkClient()
1✔
154
            .fetch(
1✔
155
                new FetchOptions.Builder(
156
                        String.join(
1✔
157
                            "",
158
                            this.networkSession.getBaseUrls().getBaseUrl(),
1✔
159
                            "/2.0/collaborations/",
160
                            convertToString(collaborationId)),
1✔
161
                        "PUT")
162
                    .headers(headersMap)
1✔
163
                    .data(JsonManager.serialize(requestBody))
1✔
164
                    .contentType("application/json")
1✔
165
                    .responseFormat(ResponseFormat.JSON)
1✔
166
                    .auth(this.auth)
1✔
167
                    .networkSession(this.networkSession)
1✔
168
                    .build());
1✔
169
    if (convertToString(response.getStatus()).equals("204")) {
1✔
170
      return null;
1✔
171
    }
172
    return JsonManager.deserialize(response.getData(), Collaboration.class);
1✔
173
  }
174

175
  /**
176
   * Deletes a single collaboration.
177
   *
178
   * @param collaborationId The ID of the collaboration. Example: "1234"
179
   */
180
  public void deleteCollaborationById(String collaborationId) {
181
    deleteCollaborationById(collaborationId, new DeleteCollaborationByIdHeaders());
1✔
182
  }
1✔
183

184
  /**
185
   * Deletes a single collaboration.
186
   *
187
   * @param collaborationId The ID of the collaboration. Example: "1234"
188
   * @param headers Headers of deleteCollaborationById method
189
   */
190
  public void deleteCollaborationById(
191
      String collaborationId, DeleteCollaborationByIdHeaders headers) {
192
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
1✔
193
    FetchResponse response =
1✔
194
        this.networkSession
195
            .getNetworkClient()
1✔
196
            .fetch(
1✔
197
                new FetchOptions.Builder(
198
                        String.join(
1✔
199
                            "",
200
                            this.networkSession.getBaseUrls().getBaseUrl(),
1✔
201
                            "/2.0/collaborations/",
202
                            convertToString(collaborationId)),
1✔
203
                        "DELETE")
204
                    .headers(headersMap)
1✔
205
                    .responseFormat(ResponseFormat.NO_CONTENT)
1✔
206
                    .auth(this.auth)
1✔
207
                    .networkSession(this.networkSession)
1✔
208
                    .build());
1✔
209
  }
1✔
210

211
  /**
212
   * Adds a collaboration for a single user or a single group to a file or folder.
213
   *
214
   * <p>Collaborations can be created using email address, user IDs, or a group IDs.
215
   *
216
   * <p>If a collaboration is being created with a group, access to this endpoint is dependent on
217
   * the group's ability to be invited.
218
   *
219
   * <p>If collaboration is in `pending` status, field `name` is redacted when: - a collaboration
220
   * was created using `user_id`, - a collaboration was created using `login`.
221
   *
222
   * @param requestBody Request body of createCollaboration method
223
   */
224
  public Collaboration createCollaboration(CreateCollaborationRequestBody requestBody) {
225
    return createCollaboration(
1✔
226
        requestBody, new CreateCollaborationQueryParams(), new CreateCollaborationHeaders());
227
  }
228

229
  /**
230
   * Adds a collaboration for a single user or a single group to a file or folder.
231
   *
232
   * <p>Collaborations can be created using email address, user IDs, or a group IDs.
233
   *
234
   * <p>If a collaboration is being created with a group, access to this endpoint is dependent on
235
   * the group's ability to be invited.
236
   *
237
   * <p>If collaboration is in `pending` status, field `name` is redacted when: - a collaboration
238
   * was created using `user_id`, - a collaboration was created using `login`.
239
   *
240
   * @param requestBody Request body of createCollaboration method
241
   * @param queryParams Query parameters of createCollaboration method
242
   */
243
  public Collaboration createCollaboration(
244
      CreateCollaborationRequestBody requestBody, CreateCollaborationQueryParams queryParams) {
UNCOV
245
    return createCollaboration(requestBody, queryParams, new CreateCollaborationHeaders());
×
246
  }
247

248
  /**
249
   * Adds a collaboration for a single user or a single group to a file or folder.
250
   *
251
   * <p>Collaborations can be created using email address, user IDs, or a group IDs.
252
   *
253
   * <p>If a collaboration is being created with a group, access to this endpoint is dependent on
254
   * the group's ability to be invited.
255
   *
256
   * <p>If collaboration is in `pending` status, field `name` is redacted when: - a collaboration
257
   * was created using `user_id`, - a collaboration was created using `login`.
258
   *
259
   * @param requestBody Request body of createCollaboration method
260
   * @param headers Headers of createCollaboration method
261
   */
262
  public Collaboration createCollaboration(
263
      CreateCollaborationRequestBody requestBody, CreateCollaborationHeaders headers) {
UNCOV
264
    return createCollaboration(requestBody, new CreateCollaborationQueryParams(), headers);
×
265
  }
266

267
  /**
268
   * Adds a collaboration for a single user or a single group to a file or folder.
269
   *
270
   * <p>Collaborations can be created using email address, user IDs, or a group IDs.
271
   *
272
   * <p>If a collaboration is being created with a group, access to this endpoint is dependent on
273
   * the group's ability to be invited.
274
   *
275
   * <p>If collaboration is in `pending` status, field `name` is redacted when: - a collaboration
276
   * was created using `user_id`, - a collaboration was created using `login`.
277
   *
278
   * @param requestBody Request body of createCollaboration method
279
   * @param queryParams Query parameters of createCollaboration method
280
   * @param headers Headers of createCollaboration method
281
   */
282
  public Collaboration createCollaboration(
283
      CreateCollaborationRequestBody requestBody,
284
      CreateCollaborationQueryParams queryParams,
285
      CreateCollaborationHeaders headers) {
286
    Map<String, String> queryParamsMap =
1✔
287
        prepareParams(
1✔
288
            mapOf(
1✔
289
                entryOf("fields", convertToString(queryParams.getFields())),
1✔
290
                entryOf("notify", convertToString(queryParams.getNotify()))));
1✔
291
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
1✔
292
    FetchResponse response =
1✔
293
        this.networkSession
294
            .getNetworkClient()
1✔
295
            .fetch(
1✔
296
                new FetchOptions.Builder(
297
                        String.join(
1✔
298
                            "",
299
                            this.networkSession.getBaseUrls().getBaseUrl(),
1✔
300
                            "/2.0/collaborations"),
301
                        "POST")
302
                    .params(queryParamsMap)
1✔
303
                    .headers(headersMap)
1✔
304
                    .data(JsonManager.serialize(requestBody))
1✔
305
                    .contentType("application/json")
1✔
306
                    .responseFormat(ResponseFormat.JSON)
1✔
307
                    .auth(this.auth)
1✔
308
                    .networkSession(this.networkSession)
1✔
309
                    .build());
1✔
310
    return JsonManager.deserialize(response.getData(), Collaboration.class);
1✔
311
  }
312

313
  public Authentication getAuth() {
UNCOV
314
    return auth;
×
315
  }
316

317
  public NetworkSession getNetworkSession() {
318
    return networkSession;
×
319
  }
320

321
  public static class Builder {
322

323
    protected Authentication auth;
324

325
    protected NetworkSession networkSession;
326

327
    public Builder() {}
1✔
328

329
    public Builder auth(Authentication auth) {
330
      this.auth = auth;
1✔
331
      return this;
1✔
332
    }
333

334
    public Builder networkSession(NetworkSession networkSession) {
335
      this.networkSession = networkSession;
1✔
336
      return this;
1✔
337
    }
338

339
    public UserCollaborationsManager build() {
340
      if (this.networkSession == null) {
1✔
UNCOV
341
        this.networkSession = new NetworkSession();
×
342
      }
343
      return new UserCollaborationsManager(this);
1✔
344
    }
345
  }
346
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc