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

box / box-java-sdk / #5076

07 Oct 2025 12:35PM UTC coverage: 37.132% (+0.007%) from 37.125%
#5076

push

github

web-flow
test: Change `Event.additionalDetails` field assertion in events test (box/box-codegen#858) (#1491)

18454 of 49699 relevant lines covered (37.13%)

0.37 hits per line

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

89.92
/src/main/java/com/box/sdkgen/managers/sharedlinksfiles/SharedLinksFilesManager.java
1
package com.box.sdkgen.managers.sharedlinksfiles;
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.filefull.FileFull;
15
import com.box.sdkgen.serialization.json.JsonManager;
16
import java.util.Map;
17

18
public class SharedLinksFilesManager {
19

20
  public Authentication auth;
21

22
  public NetworkSession networkSession;
23

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

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

33
  /**
34
   * Returns the file represented by a shared link.
35
   *
36
   * <p>A shared file can be represented by a shared link, which can originate within the current
37
   * enterprise or within another.
38
   *
39
   * <p>This endpoint allows an application to retrieve information about a shared file when only
40
   * given a shared link.
41
   *
42
   * <p>The `shared_link_permission_options` array field can be returned by requesting it in the
43
   * `fields` query parameter.
44
   *
45
   * @param headers Headers of findFileForSharedLink method
46
   */
47
  public FileFull findFileForSharedLink(FindFileForSharedLinkHeaders headers) {
48
    return findFileForSharedLink(new FindFileForSharedLinkQueryParams(), headers);
×
49
  }
50

51
  /**
52
   * Returns the file represented by a shared link.
53
   *
54
   * <p>A shared file can be represented by a shared link, which can originate within the current
55
   * enterprise or within another.
56
   *
57
   * <p>This endpoint allows an application to retrieve information about a shared file when only
58
   * given a shared link.
59
   *
60
   * <p>The `shared_link_permission_options` array field can be returned by requesting it in the
61
   * `fields` query parameter.
62
   *
63
   * @param queryParams Query parameters of findFileForSharedLink method
64
   * @param headers Headers of findFileForSharedLink method
65
   */
66
  public FileFull findFileForSharedLink(
67
      FindFileForSharedLinkQueryParams queryParams, FindFileForSharedLinkHeaders headers) {
68
    Map<String, String> queryParamsMap =
1✔
69
        prepareParams(mapOf(entryOf("fields", convertToString(queryParams.getFields()))));
1✔
70
    Map<String, String> headersMap =
1✔
71
        prepareParams(
1✔
72
            mergeMaps(
1✔
73
                mapOf(
1✔
74
                    entryOf("if-none-match", convertToString(headers.getIfNoneMatch())),
1✔
75
                    entryOf("boxapi", convertToString(headers.getBoxapi()))),
1✔
76
                headers.getExtraHeaders()));
1✔
77
    FetchResponse response =
1✔
78
        this.networkSession
79
            .getNetworkClient()
1✔
80
            .fetch(
1✔
81
                new FetchOptions.Builder(
82
                        String.join(
1✔
83
                            "",
84
                            this.networkSession.getBaseUrls().getBaseUrl(),
1✔
85
                            "/2.0/shared_items"),
86
                        "GET")
87
                    .params(queryParamsMap)
1✔
88
                    .headers(headersMap)
1✔
89
                    .responseFormat(ResponseFormat.JSON)
1✔
90
                    .auth(this.auth)
1✔
91
                    .networkSession(this.networkSession)
1✔
92
                    .build());
1✔
93
    return JsonManager.deserialize(response.getData(), FileFull.class);
1✔
94
  }
95

96
  /**
97
   * Gets the information for a shared link on a file.
98
   *
99
   * @param fileId The unique identifier that represents a file.
100
   *     <p>The ID for any file can be determined by visiting a file in the web application and
101
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
102
   *     `file_id` is `123`. Example: "12345"
103
   * @param queryParams Query parameters of getSharedLinkForFile method
104
   */
105
  public FileFull getSharedLinkForFile(String fileId, GetSharedLinkForFileQueryParams queryParams) {
106
    return getSharedLinkForFile(fileId, queryParams, new GetSharedLinkForFileHeaders());
1✔
107
  }
108

109
  /**
110
   * Gets the information for a shared link on a file.
111
   *
112
   * @param fileId The unique identifier that represents a file.
113
   *     <p>The ID for any file can be determined by visiting a file in the web application and
114
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
115
   *     `file_id` is `123`. Example: "12345"
116
   * @param queryParams Query parameters of getSharedLinkForFile method
117
   * @param headers Headers of getSharedLinkForFile method
118
   */
119
  public FileFull getSharedLinkForFile(
120
      String fileId,
121
      GetSharedLinkForFileQueryParams queryParams,
122
      GetSharedLinkForFileHeaders headers) {
123
    Map<String, String> queryParamsMap =
1✔
124
        prepareParams(mapOf(entryOf("fields", convertToString(queryParams.getFields()))));
1✔
125
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
1✔
126
    FetchResponse response =
1✔
127
        this.networkSession
128
            .getNetworkClient()
1✔
129
            .fetch(
1✔
130
                new FetchOptions.Builder(
131
                        String.join(
1✔
132
                            "",
133
                            this.networkSession.getBaseUrls().getBaseUrl(),
1✔
134
                            "/2.0/files/",
135
                            convertToString(fileId),
1✔
136
                            "#get_shared_link"),
137
                        "GET")
138
                    .params(queryParamsMap)
1✔
139
                    .headers(headersMap)
1✔
140
                    .responseFormat(ResponseFormat.JSON)
1✔
141
                    .auth(this.auth)
1✔
142
                    .networkSession(this.networkSession)
1✔
143
                    .build());
1✔
144
    return JsonManager.deserialize(response.getData(), FileFull.class);
1✔
145
  }
146

147
  /**
148
   * Adds a shared link to a file.
149
   *
150
   * @param fileId The unique identifier that represents a file.
151
   *     <p>The ID for any file can be determined by visiting a file in the web application and
152
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
153
   *     `file_id` is `123`. Example: "12345"
154
   * @param queryParams Query parameters of addShareLinkToFile method
155
   */
156
  public FileFull addShareLinkToFile(String fileId, AddShareLinkToFileQueryParams queryParams) {
157
    return addShareLinkToFile(
×
158
        fileId, new AddShareLinkToFileRequestBody(), queryParams, new AddShareLinkToFileHeaders());
159
  }
160

161
  /**
162
   * Adds a shared link to a file.
163
   *
164
   * @param fileId The unique identifier that represents a file.
165
   *     <p>The ID for any file can be determined by visiting a file in the web application and
166
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
167
   *     `file_id` is `123`. Example: "12345"
168
   * @param requestBody Request body of addShareLinkToFile method
169
   * @param queryParams Query parameters of addShareLinkToFile method
170
   */
171
  public FileFull addShareLinkToFile(
172
      String fileId,
173
      AddShareLinkToFileRequestBody requestBody,
174
      AddShareLinkToFileQueryParams queryParams) {
175
    return addShareLinkToFile(fileId, requestBody, queryParams, new AddShareLinkToFileHeaders());
1✔
176
  }
177

178
  /**
179
   * Adds a shared link to a file.
180
   *
181
   * @param fileId The unique identifier that represents a file.
182
   *     <p>The ID for any file can be determined by visiting a file in the web application and
183
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
184
   *     `file_id` is `123`. Example: "12345"
185
   * @param queryParams Query parameters of addShareLinkToFile method
186
   * @param headers Headers of addShareLinkToFile method
187
   */
188
  public FileFull addShareLinkToFile(
189
      String fileId, AddShareLinkToFileQueryParams queryParams, AddShareLinkToFileHeaders headers) {
190
    return addShareLinkToFile(fileId, new AddShareLinkToFileRequestBody(), queryParams, headers);
×
191
  }
192

193
  /**
194
   * Adds a shared link to a file.
195
   *
196
   * @param fileId The unique identifier that represents a file.
197
   *     <p>The ID for any file can be determined by visiting a file in the web application and
198
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
199
   *     `file_id` is `123`. Example: "12345"
200
   * @param requestBody Request body of addShareLinkToFile method
201
   * @param queryParams Query parameters of addShareLinkToFile method
202
   * @param headers Headers of addShareLinkToFile method
203
   */
204
  public FileFull addShareLinkToFile(
205
      String fileId,
206
      AddShareLinkToFileRequestBody requestBody,
207
      AddShareLinkToFileQueryParams queryParams,
208
      AddShareLinkToFileHeaders headers) {
209
    Map<String, String> queryParamsMap =
1✔
210
        prepareParams(mapOf(entryOf("fields", convertToString(queryParams.getFields()))));
1✔
211
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
1✔
212
    FetchResponse response =
1✔
213
        this.networkSession
214
            .getNetworkClient()
1✔
215
            .fetch(
1✔
216
                new FetchOptions.Builder(
217
                        String.join(
1✔
218
                            "",
219
                            this.networkSession.getBaseUrls().getBaseUrl(),
1✔
220
                            "/2.0/files/",
221
                            convertToString(fileId),
1✔
222
                            "#add_shared_link"),
223
                        "PUT")
224
                    .params(queryParamsMap)
1✔
225
                    .headers(headersMap)
1✔
226
                    .data(JsonManager.serialize(requestBody))
1✔
227
                    .contentType("application/json")
1✔
228
                    .responseFormat(ResponseFormat.JSON)
1✔
229
                    .auth(this.auth)
1✔
230
                    .networkSession(this.networkSession)
1✔
231
                    .build());
1✔
232
    return JsonManager.deserialize(response.getData(), FileFull.class);
1✔
233
  }
234

235
  /**
236
   * Updates a shared link on a file.
237
   *
238
   * @param fileId The unique identifier that represents a file.
239
   *     <p>The ID for any file can be determined by visiting a file in the web application and
240
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
241
   *     `file_id` is `123`. Example: "12345"
242
   * @param queryParams Query parameters of updateSharedLinkOnFile method
243
   */
244
  public FileFull updateSharedLinkOnFile(
245
      String fileId, UpdateSharedLinkOnFileQueryParams queryParams) {
246
    return updateSharedLinkOnFile(
×
247
        fileId,
248
        new UpdateSharedLinkOnFileRequestBody(),
249
        queryParams,
250
        new UpdateSharedLinkOnFileHeaders());
251
  }
252

253
  /**
254
   * Updates a shared link on a file.
255
   *
256
   * @param fileId The unique identifier that represents a file.
257
   *     <p>The ID for any file can be determined by visiting a file in the web application and
258
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
259
   *     `file_id` is `123`. Example: "12345"
260
   * @param requestBody Request body of updateSharedLinkOnFile method
261
   * @param queryParams Query parameters of updateSharedLinkOnFile method
262
   */
263
  public FileFull updateSharedLinkOnFile(
264
      String fileId,
265
      UpdateSharedLinkOnFileRequestBody requestBody,
266
      UpdateSharedLinkOnFileQueryParams queryParams) {
267
    return updateSharedLinkOnFile(
1✔
268
        fileId, requestBody, queryParams, new UpdateSharedLinkOnFileHeaders());
269
  }
270

271
  /**
272
   * Updates a shared link on a file.
273
   *
274
   * @param fileId The unique identifier that represents a file.
275
   *     <p>The ID for any file can be determined by visiting a file in the web application and
276
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
277
   *     `file_id` is `123`. Example: "12345"
278
   * @param queryParams Query parameters of updateSharedLinkOnFile method
279
   * @param headers Headers of updateSharedLinkOnFile method
280
   */
281
  public FileFull updateSharedLinkOnFile(
282
      String fileId,
283
      UpdateSharedLinkOnFileQueryParams queryParams,
284
      UpdateSharedLinkOnFileHeaders headers) {
285
    return updateSharedLinkOnFile(
×
286
        fileId, new UpdateSharedLinkOnFileRequestBody(), queryParams, headers);
287
  }
288

289
  /**
290
   * Updates a shared link on a file.
291
   *
292
   * @param fileId The unique identifier that represents a file.
293
   *     <p>The ID for any file can be determined by visiting a file in the web application and
294
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
295
   *     `file_id` is `123`. Example: "12345"
296
   * @param requestBody Request body of updateSharedLinkOnFile method
297
   * @param queryParams Query parameters of updateSharedLinkOnFile method
298
   * @param headers Headers of updateSharedLinkOnFile method
299
   */
300
  public FileFull updateSharedLinkOnFile(
301
      String fileId,
302
      UpdateSharedLinkOnFileRequestBody requestBody,
303
      UpdateSharedLinkOnFileQueryParams queryParams,
304
      UpdateSharedLinkOnFileHeaders headers) {
305
    Map<String, String> queryParamsMap =
1✔
306
        prepareParams(mapOf(entryOf("fields", convertToString(queryParams.getFields()))));
1✔
307
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
1✔
308
    FetchResponse response =
1✔
309
        this.networkSession
310
            .getNetworkClient()
1✔
311
            .fetch(
1✔
312
                new FetchOptions.Builder(
313
                        String.join(
1✔
314
                            "",
315
                            this.networkSession.getBaseUrls().getBaseUrl(),
1✔
316
                            "/2.0/files/",
317
                            convertToString(fileId),
1✔
318
                            "#update_shared_link"),
319
                        "PUT")
320
                    .params(queryParamsMap)
1✔
321
                    .headers(headersMap)
1✔
322
                    .data(JsonManager.serialize(requestBody))
1✔
323
                    .contentType("application/json")
1✔
324
                    .responseFormat(ResponseFormat.JSON)
1✔
325
                    .auth(this.auth)
1✔
326
                    .networkSession(this.networkSession)
1✔
327
                    .build());
1✔
328
    return JsonManager.deserialize(response.getData(), FileFull.class);
1✔
329
  }
330

331
  /**
332
   * Removes a shared link from a file.
333
   *
334
   * @param fileId The unique identifier that represents a file.
335
   *     <p>The ID for any file can be determined by visiting a file in the web application and
336
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
337
   *     `file_id` is `123`. Example: "12345"
338
   * @param queryParams Query parameters of removeSharedLinkFromFile method
339
   */
340
  public FileFull removeSharedLinkFromFile(
341
      String fileId, RemoveSharedLinkFromFileQueryParams queryParams) {
342
    return removeSharedLinkFromFile(
×
343
        fileId,
344
        new RemoveSharedLinkFromFileRequestBody(),
345
        queryParams,
346
        new RemoveSharedLinkFromFileHeaders());
347
  }
348

349
  /**
350
   * Removes a shared link from a file.
351
   *
352
   * @param fileId The unique identifier that represents a file.
353
   *     <p>The ID for any file can be determined by visiting a file in the web application and
354
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
355
   *     `file_id` is `123`. Example: "12345"
356
   * @param requestBody Request body of removeSharedLinkFromFile method
357
   * @param queryParams Query parameters of removeSharedLinkFromFile method
358
   */
359
  public FileFull removeSharedLinkFromFile(
360
      String fileId,
361
      RemoveSharedLinkFromFileRequestBody requestBody,
362
      RemoveSharedLinkFromFileQueryParams queryParams) {
363
    return removeSharedLinkFromFile(
1✔
364
        fileId, requestBody, queryParams, new RemoveSharedLinkFromFileHeaders());
365
  }
366

367
  /**
368
   * Removes a shared link from a file.
369
   *
370
   * @param fileId The unique identifier that represents a file.
371
   *     <p>The ID for any file can be determined by visiting a file in the web application and
372
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
373
   *     `file_id` is `123`. Example: "12345"
374
   * @param queryParams Query parameters of removeSharedLinkFromFile method
375
   * @param headers Headers of removeSharedLinkFromFile method
376
   */
377
  public FileFull removeSharedLinkFromFile(
378
      String fileId,
379
      RemoveSharedLinkFromFileQueryParams queryParams,
380
      RemoveSharedLinkFromFileHeaders headers) {
381
    return removeSharedLinkFromFile(
×
382
        fileId, new RemoveSharedLinkFromFileRequestBody(), queryParams, headers);
383
  }
384

385
  /**
386
   * Removes a shared link from a file.
387
   *
388
   * @param fileId The unique identifier that represents a file.
389
   *     <p>The ID for any file can be determined by visiting a file in the web application and
390
   *     copying the ID from the URL. For example, for the URL `https://*.app.box.com/files/123` the
391
   *     `file_id` is `123`. Example: "12345"
392
   * @param requestBody Request body of removeSharedLinkFromFile method
393
   * @param queryParams Query parameters of removeSharedLinkFromFile method
394
   * @param headers Headers of removeSharedLinkFromFile method
395
   */
396
  public FileFull removeSharedLinkFromFile(
397
      String fileId,
398
      RemoveSharedLinkFromFileRequestBody requestBody,
399
      RemoveSharedLinkFromFileQueryParams queryParams,
400
      RemoveSharedLinkFromFileHeaders headers) {
401
    Map<String, String> queryParamsMap =
1✔
402
        prepareParams(mapOf(entryOf("fields", convertToString(queryParams.getFields()))));
1✔
403
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
1✔
404
    FetchResponse response =
1✔
405
        this.networkSession
406
            .getNetworkClient()
1✔
407
            .fetch(
1✔
408
                new FetchOptions.Builder(
409
                        String.join(
1✔
410
                            "",
411
                            this.networkSession.getBaseUrls().getBaseUrl(),
1✔
412
                            "/2.0/files/",
413
                            convertToString(fileId),
1✔
414
                            "#remove_shared_link"),
415
                        "PUT")
416
                    .params(queryParamsMap)
1✔
417
                    .headers(headersMap)
1✔
418
                    .data(JsonManager.serialize(requestBody))
1✔
419
                    .contentType("application/json")
1✔
420
                    .responseFormat(ResponseFormat.JSON)
1✔
421
                    .auth(this.auth)
1✔
422
                    .networkSession(this.networkSession)
1✔
423
                    .build());
1✔
424
    return JsonManager.deserialize(response.getData(), FileFull.class);
1✔
425
  }
426

427
  public Authentication getAuth() {
428
    return auth;
×
429
  }
430

431
  public NetworkSession getNetworkSession() {
432
    return networkSession;
×
433
  }
434

435
  public static class Builder {
436

437
    protected Authentication auth;
438

439
    protected NetworkSession networkSession;
440

441
    public Builder() {
1✔
442
      this.networkSession = new NetworkSession();
1✔
443
    }
1✔
444

445
    public Builder auth(Authentication auth) {
446
      this.auth = auth;
1✔
447
      return this;
1✔
448
    }
449

450
    public Builder networkSession(NetworkSession networkSession) {
451
      this.networkSession = networkSession;
1✔
452
      return this;
1✔
453
    }
454

455
    public SharedLinksFilesManager build() {
456
      return new SharedLinksFilesManager(this);
1✔
457
    }
458
  }
459
}
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