• 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

88.57
/src/main/java/com/box/sdkgen/managers/folders/FoldersManager.java
1
package com.box.sdkgen.managers.folders;
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.folderfull.FolderFull;
15
import com.box.sdkgen.schemas.items.Items;
16
import com.box.sdkgen.serialization.json.JsonManager;
17
import java.util.Map;
18

19
public class FoldersManager {
20

21
  public Authentication auth;
22

23
  public NetworkSession networkSession;
24

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

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

34
  /**
35
   * Retrieves details for a folder, including the first 100 entries in the folder.
36
   *
37
   * <p>Passing `sort`, `direction`, `offset`, and `limit` parameters in query allows you to manage
38
   * the list of returned [folder items](r://folder--full#param-item-collection).
39
   *
40
   * <p>To fetch more items within the folder, use the [Get items in a
41
   * folder](e://get-folders-id-items) endpoint.
42
   *
43
   * @param folderId The unique identifier that represent a folder.
44
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
45
   *     and copying the ID from the URL. For example, for the URL
46
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
47
   *     <p>The root folder of a Box account is always represented by the ID `0`. Example: "12345"
48
   */
49
  public FolderFull getFolderById(String folderId) {
50
    return getFolderById(folderId, new GetFolderByIdQueryParams(), new GetFolderByIdHeaders());
1✔
51
  }
52

53
  /**
54
   * Retrieves details for a folder, including the first 100 entries in the folder.
55
   *
56
   * <p>Passing `sort`, `direction`, `offset`, and `limit` parameters in query allows you to manage
57
   * the list of returned [folder items](r://folder--full#param-item-collection).
58
   *
59
   * <p>To fetch more items within the folder, use the [Get items in a
60
   * folder](e://get-folders-id-items) endpoint.
61
   *
62
   * @param folderId The unique identifier that represent a folder.
63
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
64
   *     and copying the ID from the URL. For example, for the URL
65
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
66
   *     <p>The root folder of a Box account is always represented by the ID `0`. Example: "12345"
67
   * @param queryParams Query parameters of getFolderById method
68
   */
69
  public FolderFull getFolderById(String folderId, GetFolderByIdQueryParams queryParams) {
70
    return getFolderById(folderId, queryParams, new GetFolderByIdHeaders());
1✔
71
  }
72

73
  /**
74
   * Retrieves details for a folder, including the first 100 entries in the folder.
75
   *
76
   * <p>Passing `sort`, `direction`, `offset`, and `limit` parameters in query allows you to manage
77
   * the list of returned [folder items](r://folder--full#param-item-collection).
78
   *
79
   * <p>To fetch more items within the folder, use the [Get items in a
80
   * folder](e://get-folders-id-items) endpoint.
81
   *
82
   * @param folderId The unique identifier that represent a folder.
83
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
84
   *     and copying the ID from the URL. For example, for the URL
85
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
86
   *     <p>The root folder of a Box account is always represented by the ID `0`. Example: "12345"
87
   * @param headers Headers of getFolderById method
88
   */
89
  public FolderFull getFolderById(String folderId, GetFolderByIdHeaders headers) {
90
    return getFolderById(folderId, new GetFolderByIdQueryParams(), headers);
×
91
  }
92

93
  /**
94
   * Retrieves details for a folder, including the first 100 entries in the folder.
95
   *
96
   * <p>Passing `sort`, `direction`, `offset`, and `limit` parameters in query allows you to manage
97
   * the list of returned [folder items](r://folder--full#param-item-collection).
98
   *
99
   * <p>To fetch more items within the folder, use the [Get items in a
100
   * folder](e://get-folders-id-items) endpoint.
101
   *
102
   * @param folderId The unique identifier that represent a folder.
103
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
104
   *     and copying the ID from the URL. For example, for the URL
105
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
106
   *     <p>The root folder of a Box account is always represented by the ID `0`. Example: "12345"
107
   * @param queryParams Query parameters of getFolderById method
108
   * @param headers Headers of getFolderById method
109
   */
110
  public FolderFull getFolderById(
111
      String folderId, GetFolderByIdQueryParams queryParams, GetFolderByIdHeaders headers) {
112
    Map<String, String> queryParamsMap =
1✔
113
        prepareParams(
1✔
114
            mapOf(
1✔
115
                entryOf("fields", convertToString(queryParams.getFields())),
1✔
116
                entryOf("sort", convertToString(queryParams.getSort())),
1✔
117
                entryOf("direction", convertToString(queryParams.getDirection())),
1✔
118
                entryOf("offset", convertToString(queryParams.getOffset())),
1✔
119
                entryOf("limit", convertToString(queryParams.getLimit()))));
1✔
120
    Map<String, String> headersMap =
1✔
121
        prepareParams(
1✔
122
            mergeMaps(
1✔
123
                mapOf(
1✔
124
                    entryOf("if-none-match", convertToString(headers.getIfNoneMatch())),
1✔
125
                    entryOf("boxapi", convertToString(headers.getBoxapi()))),
1✔
126
                headers.getExtraHeaders()));
1✔
127
    FetchResponse response =
1✔
128
        this.networkSession
129
            .getNetworkClient()
1✔
130
            .fetch(
1✔
131
                new FetchOptions.Builder(
132
                        String.join(
1✔
133
                            "",
134
                            this.networkSession.getBaseUrls().getBaseUrl(),
1✔
135
                            "/2.0/folders/",
136
                            convertToString(folderId)),
1✔
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(), FolderFull.class);
1✔
145
  }
146

147
  /**
148
   * Updates a folder. This can be also be used to move the folder, create shared links, update
149
   * collaborations, and more.
150
   *
151
   * @param folderId The unique identifier that represent a folder.
152
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
153
   *     and copying the ID from the URL. For example, for the URL
154
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
155
   *     <p>The root folder of a Box account is always represented by the ID `0`. Example: "12345"
156
   */
157
  public FolderFull updateFolderById(String folderId) {
158
    return updateFolderById(
×
159
        folderId,
160
        new UpdateFolderByIdRequestBody(),
161
        new UpdateFolderByIdQueryParams(),
162
        new UpdateFolderByIdHeaders());
163
  }
164

165
  /**
166
   * Updates a folder. This can be also be used to move the folder, create shared links, update
167
   * collaborations, and more.
168
   *
169
   * @param folderId The unique identifier that represent a folder.
170
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
171
   *     and copying the ID from the URL. For example, for the URL
172
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
173
   *     <p>The root folder of a Box account is always represented by the ID `0`. Example: "12345"
174
   * @param requestBody Request body of updateFolderById method
175
   */
176
  public FolderFull updateFolderById(String folderId, UpdateFolderByIdRequestBody requestBody) {
177
    return updateFolderById(
1✔
178
        folderId, requestBody, new UpdateFolderByIdQueryParams(), new UpdateFolderByIdHeaders());
179
  }
180

181
  /**
182
   * Updates a folder. This can be also be used to move the folder, create shared links, update
183
   * collaborations, and more.
184
   *
185
   * @param folderId The unique identifier that represent a folder.
186
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
187
   *     and copying the ID from the URL. For example, for the URL
188
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
189
   *     <p>The root folder of a Box account is always represented by the ID `0`. Example: "12345"
190
   * @param queryParams Query parameters of updateFolderById method
191
   */
192
  public FolderFull updateFolderById(String folderId, UpdateFolderByIdQueryParams queryParams) {
193
    return updateFolderById(
×
194
        folderId, new UpdateFolderByIdRequestBody(), queryParams, new UpdateFolderByIdHeaders());
195
  }
196

197
  /**
198
   * Updates a folder. This can be also be used to move the folder, create shared links, update
199
   * collaborations, and more.
200
   *
201
   * @param folderId The unique identifier that represent a folder.
202
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
203
   *     and copying the ID from the URL. For example, for the URL
204
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
205
   *     <p>The root folder of a Box account is always represented by the ID `0`. Example: "12345"
206
   * @param requestBody Request body of updateFolderById method
207
   * @param queryParams Query parameters of updateFolderById method
208
   */
209
  public FolderFull updateFolderById(
210
      String folderId,
211
      UpdateFolderByIdRequestBody requestBody,
212
      UpdateFolderByIdQueryParams queryParams) {
213
    return updateFolderById(folderId, requestBody, queryParams, new UpdateFolderByIdHeaders());
×
214
  }
215

216
  /**
217
   * Updates a folder. This can be also be used to move the folder, create shared links, update
218
   * collaborations, and more.
219
   *
220
   * @param folderId The unique identifier that represent a folder.
221
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
222
   *     and copying the ID from the URL. For example, for the URL
223
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
224
   *     <p>The root folder of a Box account is always represented by the ID `0`. Example: "12345"
225
   * @param headers Headers of updateFolderById method
226
   */
227
  public FolderFull updateFolderById(String folderId, UpdateFolderByIdHeaders headers) {
228
    return updateFolderById(
×
229
        folderId, new UpdateFolderByIdRequestBody(), new UpdateFolderByIdQueryParams(), headers);
230
  }
231

232
  /**
233
   * Updates a folder. This can be also be used to move the folder, create shared links, update
234
   * collaborations, and more.
235
   *
236
   * @param folderId The unique identifier that represent a folder.
237
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
238
   *     and copying the ID from the URL. For example, for the URL
239
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
240
   *     <p>The root folder of a Box account is always represented by the ID `0`. Example: "12345"
241
   * @param requestBody Request body of updateFolderById method
242
   * @param headers Headers of updateFolderById method
243
   */
244
  public FolderFull updateFolderById(
245
      String folderId, UpdateFolderByIdRequestBody requestBody, UpdateFolderByIdHeaders headers) {
246
    return updateFolderById(folderId, requestBody, new UpdateFolderByIdQueryParams(), headers);
×
247
  }
248

249
  /**
250
   * Updates a folder. This can be also be used to move the folder, create shared links, update
251
   * collaborations, and more.
252
   *
253
   * @param folderId The unique identifier that represent a folder.
254
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
255
   *     and copying the ID from the URL. For example, for the URL
256
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
257
   *     <p>The root folder of a Box account is always represented by the ID `0`. Example: "12345"
258
   * @param queryParams Query parameters of updateFolderById method
259
   * @param headers Headers of updateFolderById method
260
   */
261
  public FolderFull updateFolderById(
262
      String folderId, UpdateFolderByIdQueryParams queryParams, UpdateFolderByIdHeaders headers) {
263
    return updateFolderById(folderId, new UpdateFolderByIdRequestBody(), queryParams, headers);
×
264
  }
265

266
  /**
267
   * Updates a folder. This can be also be used to move the folder, create shared links, update
268
   * collaborations, and more.
269
   *
270
   * @param folderId The unique identifier that represent a folder.
271
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
272
   *     and copying the ID from the URL. For example, for the URL
273
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
274
   *     <p>The root folder of a Box account is always represented by the ID `0`. Example: "12345"
275
   * @param requestBody Request body of updateFolderById method
276
   * @param queryParams Query parameters of updateFolderById method
277
   * @param headers Headers of updateFolderById method
278
   */
279
  public FolderFull updateFolderById(
280
      String folderId,
281
      UpdateFolderByIdRequestBody requestBody,
282
      UpdateFolderByIdQueryParams queryParams,
283
      UpdateFolderByIdHeaders headers) {
284
    Map<String, String> queryParamsMap =
1✔
285
        prepareParams(mapOf(entryOf("fields", convertToString(queryParams.getFields()))));
1✔
286
    Map<String, String> headersMap =
1✔
287
        prepareParams(
1✔
288
            mergeMaps(
1✔
289
                mapOf(entryOf("if-match", convertToString(headers.getIfMatch()))),
1✔
290
                headers.getExtraHeaders()));
1✔
291
    FetchResponse response =
1✔
292
        this.networkSession
293
            .getNetworkClient()
1✔
294
            .fetch(
1✔
295
                new FetchOptions.Builder(
296
                        String.join(
1✔
297
                            "",
298
                            this.networkSession.getBaseUrls().getBaseUrl(),
1✔
299
                            "/2.0/folders/",
300
                            convertToString(folderId)),
1✔
301
                        "PUT")
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(), FolderFull.class);
1✔
311
  }
312

313
  /**
314
   * Deletes a folder, either permanently or by moving it to the trash.
315
   *
316
   * @param folderId The unique identifier that represent a folder.
317
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
318
   *     and copying the ID from the URL. For example, for the URL
319
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
320
   *     <p>The root folder of a Box account is always represented by the ID `0`. Example: "12345"
321
   */
322
  public void deleteFolderById(String folderId) {
323
    deleteFolderById(folderId, new DeleteFolderByIdQueryParams(), new DeleteFolderByIdHeaders());
1✔
324
  }
1✔
325

326
  /**
327
   * Deletes a folder, either permanently or by moving it to the trash.
328
   *
329
   * @param folderId The unique identifier that represent a folder.
330
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
331
   *     and copying the ID from the URL. For example, for the URL
332
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
333
   *     <p>The root folder of a Box account is always represented by the ID `0`. Example: "12345"
334
   * @param queryParams Query parameters of deleteFolderById method
335
   */
336
  public void deleteFolderById(String folderId, DeleteFolderByIdQueryParams queryParams) {
337
    deleteFolderById(folderId, queryParams, new DeleteFolderByIdHeaders());
1✔
338
  }
1✔
339

340
  /**
341
   * Deletes a folder, either permanently or by moving it to the trash.
342
   *
343
   * @param folderId The unique identifier that represent a folder.
344
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
345
   *     and copying the ID from the URL. For example, for the URL
346
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
347
   *     <p>The root folder of a Box account is always represented by the ID `0`. Example: "12345"
348
   * @param headers Headers of deleteFolderById method
349
   */
350
  public void deleteFolderById(String folderId, DeleteFolderByIdHeaders headers) {
351
    deleteFolderById(folderId, new DeleteFolderByIdQueryParams(), headers);
×
352
  }
×
353

354
  /**
355
   * Deletes a folder, either permanently or by moving it to the trash.
356
   *
357
   * @param folderId The unique identifier that represent a folder.
358
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
359
   *     and copying the ID from the URL. For example, for the URL
360
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
361
   *     <p>The root folder of a Box account is always represented by the ID `0`. Example: "12345"
362
   * @param queryParams Query parameters of deleteFolderById method
363
   * @param headers Headers of deleteFolderById method
364
   */
365
  public void deleteFolderById(
366
      String folderId, DeleteFolderByIdQueryParams queryParams, DeleteFolderByIdHeaders headers) {
367
    Map<String, String> queryParamsMap =
1✔
368
        prepareParams(mapOf(entryOf("recursive", convertToString(queryParams.getRecursive()))));
1✔
369
    Map<String, String> headersMap =
1✔
370
        prepareParams(
1✔
371
            mergeMaps(
1✔
372
                mapOf(entryOf("if-match", convertToString(headers.getIfMatch()))),
1✔
373
                headers.getExtraHeaders()));
1✔
374
    FetchResponse response =
1✔
375
        this.networkSession
376
            .getNetworkClient()
1✔
377
            .fetch(
1✔
378
                new FetchOptions.Builder(
379
                        String.join(
1✔
380
                            "",
381
                            this.networkSession.getBaseUrls().getBaseUrl(),
1✔
382
                            "/2.0/folders/",
383
                            convertToString(folderId)),
1✔
384
                        "DELETE")
385
                    .params(queryParamsMap)
1✔
386
                    .headers(headersMap)
1✔
387
                    .responseFormat(ResponseFormat.NO_CONTENT)
1✔
388
                    .auth(this.auth)
1✔
389
                    .networkSession(this.networkSession)
1✔
390
                    .build());
1✔
391
  }
1✔
392

393
  /**
394
   * Retrieves a page of items in a folder. These items can be files, folders, and web links.
395
   *
396
   * <p>To request more information about the folder itself, like its size, use the [Get a
397
   * folder](#get-folders-id) endpoint instead.
398
   *
399
   * @param folderId The unique identifier that represent a folder.
400
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
401
   *     and copying the ID from the URL. For example, for the URL
402
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
403
   *     <p>The root folder of a Box account is always represented by the ID `0`. Example: "12345"
404
   */
405
  public Items getFolderItems(String folderId) {
406
    return getFolderItems(folderId, new GetFolderItemsQueryParams(), new GetFolderItemsHeaders());
1✔
407
  }
408

409
  /**
410
   * Retrieves a page of items in a folder. These items can be files, folders, and web links.
411
   *
412
   * <p>To request more information about the folder itself, like its size, use the [Get a
413
   * folder](#get-folders-id) endpoint instead.
414
   *
415
   * @param folderId The unique identifier that represent a folder.
416
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
417
   *     and copying the ID from the URL. For example, for the URL
418
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
419
   *     <p>The root folder of a Box account is always represented by the ID `0`. Example: "12345"
420
   * @param queryParams Query parameters of getFolderItems method
421
   */
422
  public Items getFolderItems(String folderId, GetFolderItemsQueryParams queryParams) {
423
    return getFolderItems(folderId, queryParams, new GetFolderItemsHeaders());
×
424
  }
425

426
  /**
427
   * Retrieves a page of items in a folder. These items can be files, folders, and web links.
428
   *
429
   * <p>To request more information about the folder itself, like its size, use the [Get a
430
   * folder](#get-folders-id) endpoint instead.
431
   *
432
   * @param folderId The unique identifier that represent a folder.
433
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
434
   *     and copying the ID from the URL. For example, for the URL
435
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
436
   *     <p>The root folder of a Box account is always represented by the ID `0`. Example: "12345"
437
   * @param headers Headers of getFolderItems method
438
   */
439
  public Items getFolderItems(String folderId, GetFolderItemsHeaders headers) {
440
    return getFolderItems(folderId, new GetFolderItemsQueryParams(), headers);
×
441
  }
442

443
  /**
444
   * Retrieves a page of items in a folder. These items can be files, folders, and web links.
445
   *
446
   * <p>To request more information about the folder itself, like its size, use the [Get a
447
   * folder](#get-folders-id) endpoint instead.
448
   *
449
   * @param folderId The unique identifier that represent a folder.
450
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
451
   *     and copying the ID from the URL. For example, for the URL
452
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
453
   *     <p>The root folder of a Box account is always represented by the ID `0`. Example: "12345"
454
   * @param queryParams Query parameters of getFolderItems method
455
   * @param headers Headers of getFolderItems method
456
   */
457
  public Items getFolderItems(
458
      String folderId, GetFolderItemsQueryParams queryParams, GetFolderItemsHeaders headers) {
459
    Map<String, String> queryParamsMap =
1✔
460
        prepareParams(
1✔
461
            mapOf(
1✔
462
                entryOf("fields", convertToString(queryParams.getFields())),
1✔
463
                entryOf("usemarker", convertToString(queryParams.getUsemarker())),
1✔
464
                entryOf("marker", convertToString(queryParams.getMarker())),
1✔
465
                entryOf("offset", convertToString(queryParams.getOffset())),
1✔
466
                entryOf("limit", convertToString(queryParams.getLimit())),
1✔
467
                entryOf("sort", convertToString(queryParams.getSort())),
1✔
468
                entryOf("direction", convertToString(queryParams.getDirection()))));
1✔
469
    Map<String, String> headersMap =
1✔
470
        prepareParams(
1✔
471
            mergeMaps(
1✔
472
                mapOf(entryOf("boxapi", convertToString(headers.getBoxapi()))),
1✔
473
                headers.getExtraHeaders()));
1✔
474
    FetchResponse response =
1✔
475
        this.networkSession
476
            .getNetworkClient()
1✔
477
            .fetch(
1✔
478
                new FetchOptions.Builder(
479
                        String.join(
1✔
480
                            "",
481
                            this.networkSession.getBaseUrls().getBaseUrl(),
1✔
482
                            "/2.0/folders/",
483
                            convertToString(folderId),
1✔
484
                            "/items"),
485
                        "GET")
486
                    .params(queryParamsMap)
1✔
487
                    .headers(headersMap)
1✔
488
                    .responseFormat(ResponseFormat.JSON)
1✔
489
                    .auth(this.auth)
1✔
490
                    .networkSession(this.networkSession)
1✔
491
                    .build());
1✔
492
    return JsonManager.deserialize(response.getData(), Items.class);
1✔
493
  }
494

495
  /**
496
   * Creates a new empty folder within the specified parent folder.
497
   *
498
   * @param requestBody Request body of createFolder method
499
   */
500
  public FolderFull createFolder(CreateFolderRequestBody requestBody) {
501
    return createFolder(requestBody, new CreateFolderQueryParams(), new CreateFolderHeaders());
1✔
502
  }
503

504
  /**
505
   * Creates a new empty folder within the specified parent folder.
506
   *
507
   * @param requestBody Request body of createFolder method
508
   * @param queryParams Query parameters of createFolder method
509
   */
510
  public FolderFull createFolder(
511
      CreateFolderRequestBody requestBody, CreateFolderQueryParams queryParams) {
512
    return createFolder(requestBody, queryParams, new CreateFolderHeaders());
×
513
  }
514

515
  /**
516
   * Creates a new empty folder within the specified parent folder.
517
   *
518
   * @param requestBody Request body of createFolder method
519
   * @param headers Headers of createFolder method
520
   */
521
  public FolderFull createFolder(CreateFolderRequestBody requestBody, CreateFolderHeaders headers) {
522
    return createFolder(requestBody, new CreateFolderQueryParams(), headers);
×
523
  }
524

525
  /**
526
   * Creates a new empty folder within the specified parent folder.
527
   *
528
   * @param requestBody Request body of createFolder method
529
   * @param queryParams Query parameters of createFolder method
530
   * @param headers Headers of createFolder method
531
   */
532
  public FolderFull createFolder(
533
      CreateFolderRequestBody requestBody,
534
      CreateFolderQueryParams queryParams,
535
      CreateFolderHeaders headers) {
536
    Map<String, String> queryParamsMap =
1✔
537
        prepareParams(mapOf(entryOf("fields", convertToString(queryParams.getFields()))));
1✔
538
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
1✔
539
    FetchResponse response =
1✔
540
        this.networkSession
541
            .getNetworkClient()
1✔
542
            .fetch(
1✔
543
                new FetchOptions.Builder(
544
                        String.join(
1✔
545
                            "", this.networkSession.getBaseUrls().getBaseUrl(), "/2.0/folders"),
1✔
546
                        "POST")
547
                    .params(queryParamsMap)
1✔
548
                    .headers(headersMap)
1✔
549
                    .data(JsonManager.serialize(requestBody))
1✔
550
                    .contentType("application/json")
1✔
551
                    .responseFormat(ResponseFormat.JSON)
1✔
552
                    .auth(this.auth)
1✔
553
                    .networkSession(this.networkSession)
1✔
554
                    .build());
1✔
555
    return JsonManager.deserialize(response.getData(), FolderFull.class);
1✔
556
  }
557

558
  /**
559
   * Creates a copy of a folder within a destination folder.
560
   *
561
   * <p>The original folder will not be changed.
562
   *
563
   * @param folderId The unique identifier of the folder to copy.
564
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
565
   *     and copying the ID from the URL. For example, for the URL
566
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
567
   *     <p>The root folder with the ID `0` can not be copied. Example: "0"
568
   * @param requestBody Request body of copyFolder method
569
   */
570
  public FolderFull copyFolder(String folderId, CopyFolderRequestBody requestBody) {
571
    return copyFolder(folderId, requestBody, new CopyFolderQueryParams(), new CopyFolderHeaders());
1✔
572
  }
573

574
  /**
575
   * Creates a copy of a folder within a destination folder.
576
   *
577
   * <p>The original folder will not be changed.
578
   *
579
   * @param folderId The unique identifier of the folder to copy.
580
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
581
   *     and copying the ID from the URL. For example, for the URL
582
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
583
   *     <p>The root folder with the ID `0` can not be copied. Example: "0"
584
   * @param requestBody Request body of copyFolder method
585
   * @param queryParams Query parameters of copyFolder method
586
   */
587
  public FolderFull copyFolder(
588
      String folderId, CopyFolderRequestBody requestBody, CopyFolderQueryParams queryParams) {
589
    return copyFolder(folderId, requestBody, queryParams, new CopyFolderHeaders());
×
590
  }
591

592
  /**
593
   * Creates a copy of a folder within a destination folder.
594
   *
595
   * <p>The original folder will not be changed.
596
   *
597
   * @param folderId The unique identifier of the folder to copy.
598
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
599
   *     and copying the ID from the URL. For example, for the URL
600
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
601
   *     <p>The root folder with the ID `0` can not be copied. Example: "0"
602
   * @param requestBody Request body of copyFolder method
603
   * @param headers Headers of copyFolder method
604
   */
605
  public FolderFull copyFolder(
606
      String folderId, CopyFolderRequestBody requestBody, CopyFolderHeaders headers) {
607
    return copyFolder(folderId, requestBody, new CopyFolderQueryParams(), headers);
×
608
  }
609

610
  /**
611
   * Creates a copy of a folder within a destination folder.
612
   *
613
   * <p>The original folder will not be changed.
614
   *
615
   * @param folderId The unique identifier of the folder to copy.
616
   *     <p>The ID for any folder can be determined by visiting this folder in the web application
617
   *     and copying the ID from the URL. For example, for the URL
618
   *     `https://*.app.box.com/folder/123` the `folder_id` is `123`.
619
   *     <p>The root folder with the ID `0` can not be copied. Example: "0"
620
   * @param requestBody Request body of copyFolder method
621
   * @param queryParams Query parameters of copyFolder method
622
   * @param headers Headers of copyFolder method
623
   */
624
  public FolderFull copyFolder(
625
      String folderId,
626
      CopyFolderRequestBody requestBody,
627
      CopyFolderQueryParams queryParams,
628
      CopyFolderHeaders headers) {
629
    Map<String, String> queryParamsMap =
1✔
630
        prepareParams(mapOf(entryOf("fields", convertToString(queryParams.getFields()))));
1✔
631
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
1✔
632
    FetchResponse response =
1✔
633
        this.networkSession
634
            .getNetworkClient()
1✔
635
            .fetch(
1✔
636
                new FetchOptions.Builder(
637
                        String.join(
1✔
638
                            "",
639
                            this.networkSession.getBaseUrls().getBaseUrl(),
1✔
640
                            "/2.0/folders/",
641
                            convertToString(folderId),
1✔
642
                            "/copy"),
643
                        "POST")
644
                    .params(queryParamsMap)
1✔
645
                    .headers(headersMap)
1✔
646
                    .data(JsonManager.serialize(requestBody))
1✔
647
                    .contentType("application/json")
1✔
648
                    .responseFormat(ResponseFormat.JSON)
1✔
649
                    .auth(this.auth)
1✔
650
                    .networkSession(this.networkSession)
1✔
651
                    .build());
1✔
652
    return JsonManager.deserialize(response.getData(), FolderFull.class);
1✔
653
  }
654

655
  public Authentication getAuth() {
656
    return auth;
×
657
  }
658

659
  public NetworkSession getNetworkSession() {
660
    return networkSession;
×
661
  }
662

663
  public static class Builder {
664

665
    protected Authentication auth;
666

667
    protected NetworkSession networkSession;
668

669
    public Builder() {
1✔
670
      this.networkSession = new NetworkSession();
1✔
671
    }
1✔
672

673
    public Builder auth(Authentication auth) {
674
      this.auth = auth;
1✔
675
      return this;
1✔
676
    }
677

678
    public Builder networkSession(NetworkSession networkSession) {
679
      this.networkSession = networkSession;
1✔
680
      return this;
1✔
681
    }
682

683
    public FoldersManager build() {
684
      return new FoldersManager(this);
1✔
685
    }
686
  }
687
}
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