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

box / box-java-sdk / #6242

10 Feb 2026 05:27PM UTC coverage: 35.714% (+11.4%) from 24.324%
#6242

push

github

web-flow
fix(boxsdkgen): Move assigning default values from builder constructor to `build()` method (box/box-codegen#922) (#1712)

0 of 1677 new or added lines in 569 files covered. (0.0%)

2146 existing lines in 544 files now uncovered.

7382 of 20670 relevant lines covered (35.71%)

0.4 hits per line

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

0.0
/src/main/java/com/box/sdkgen/managers/zipdownloads/ZipDownloadsManager.java
1
package com.box.sdkgen.managers.zipdownloads;
2

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

7
import com.box.sdkgen.networking.auth.Authentication;
8
import com.box.sdkgen.networking.fetchoptions.FetchOptions;
9
import com.box.sdkgen.networking.fetchoptions.ResponseFormat;
10
import com.box.sdkgen.networking.fetchresponse.FetchResponse;
11
import com.box.sdkgen.networking.network.NetworkSession;
12
import com.box.sdkgen.schemas.zipdownload.ZipDownload;
13
import com.box.sdkgen.schemas.zipdownloadrequest.ZipDownloadRequest;
14
import com.box.sdkgen.schemas.zipdownloadstatus.ZipDownloadStatus;
15
import com.box.sdkgen.serialization.json.JsonManager;
16
import java.io.InputStream;
17
import java.util.Map;
18

19
public class ZipDownloadsManager {
20

21
  public Authentication auth;
22

23
  public NetworkSession networkSession;
24

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

29
  protected ZipDownloadsManager(Builder builder) {
×
30
    this.auth = builder.auth;
×
31
    this.networkSession = builder.networkSession;
×
32
  }
×
33

34
  /**
35
   * Creates a request to download multiple files and folders as a single `zip` archive file. This
36
   * API does not return the archive but instead performs all the checks to ensure that the user has
37
   * access to all the items, and then returns a `download_url` and a `status_url` that can be used
38
   * to download the archive.
39
   *
40
   * <p>The limit for an archive is either the Account's upload limit or 10,000 files, whichever is
41
   * met first.
42
   *
43
   * <p>**Note**: Downloading a large file can be affected by various factors such as distance,
44
   * network latency, bandwidth, and congestion, as well as packet loss ratio and current server
45
   * load. For these reasons we recommend that a maximum ZIP archive total size does not exceed
46
   * 25GB.
47
   *
48
   * @param requestBody Request body of createZipDownload method
49
   */
50
  public ZipDownload createZipDownload(ZipDownloadRequest requestBody) {
51
    return createZipDownload(requestBody, new CreateZipDownloadHeaders());
×
52
  }
53

54
  /**
55
   * Creates a request to download multiple files and folders as a single `zip` archive file. This
56
   * API does not return the archive but instead performs all the checks to ensure that the user has
57
   * access to all the items, and then returns a `download_url` and a `status_url` that can be used
58
   * to download the archive.
59
   *
60
   * <p>The limit for an archive is either the Account's upload limit or 10,000 files, whichever is
61
   * met first.
62
   *
63
   * <p>**Note**: Downloading a large file can be affected by various factors such as distance,
64
   * network latency, bandwidth, and congestion, as well as packet loss ratio and current server
65
   * load. For these reasons we recommend that a maximum ZIP archive total size does not exceed
66
   * 25GB.
67
   *
68
   * @param requestBody Request body of createZipDownload method
69
   * @param headers Headers of createZipDownload method
70
   */
71
  public ZipDownload createZipDownload(
72
      ZipDownloadRequest requestBody, CreateZipDownloadHeaders headers) {
73
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
×
74
    FetchResponse response =
×
75
        this.networkSession
76
            .getNetworkClient()
×
77
            .fetch(
×
78
                new FetchOptions.Builder(
79
                        String.join(
×
80
                            "",
81
                            this.networkSession.getBaseUrls().getBaseUrl(),
×
82
                            "/2.0/zip_downloads"),
83
                        "POST")
84
                    .headers(headersMap)
×
85
                    .data(JsonManager.serialize(requestBody))
×
86
                    .contentType("application/json")
×
87
                    .responseFormat(ResponseFormat.JSON)
×
88
                    .auth(this.auth)
×
89
                    .networkSession(this.networkSession)
×
90
                    .build());
×
91
    return JsonManager.deserialize(response.getData(), ZipDownload.class);
×
92
  }
93

94
  /**
95
   * Returns the contents of a `zip` archive in binary format. This URL does not require any form of
96
   * authentication and could be used in a user's browser to download the archive to a user's
97
   * device.
98
   *
99
   * <p>By default, this URL is only valid for a few seconds from the creation of the request for
100
   * this archive. Once a download has started it can not be stopped and resumed, instead a new
101
   * request for a zip archive would need to be created.
102
   *
103
   * <p>The URL of this endpoint should not be considered as fixed. Instead, use the [Create zip
104
   * download](https://developer.box.com/reference/post-zip-downloads) API to request to create a
105
   * `zip` archive, and then follow the `download_url` field in the response to this endpoint.
106
   *
107
   * @param downloadUrl The URL that can be used to download created `zip` archive. Example:
108
   *     `https://dl.boxcloud.com/2.0/zip_downloads/29l00nfxDyHOt7RphI9zT_w==nDnZEDjY2S8iEWWCHEEiptFxwoWojjlibZjJ6geuE5xnXENDTPxzgbks_yY=/content`
109
   */
110
  public InputStream getZipDownloadContent(String downloadUrl) {
111
    return getZipDownloadContent(downloadUrl, new GetZipDownloadContentHeaders());
×
112
  }
113

114
  /**
115
   * Returns the contents of a `zip` archive in binary format. This URL does not require any form of
116
   * authentication and could be used in a user's browser to download the archive to a user's
117
   * device.
118
   *
119
   * <p>By default, this URL is only valid for a few seconds from the creation of the request for
120
   * this archive. Once a download has started it can not be stopped and resumed, instead a new
121
   * request for a zip archive would need to be created.
122
   *
123
   * <p>The URL of this endpoint should not be considered as fixed. Instead, use the [Create zip
124
   * download](https://developer.box.com/reference/post-zip-downloads) API to request to create a
125
   * `zip` archive, and then follow the `download_url` field in the response to this endpoint.
126
   *
127
   * @param downloadUrl The URL that can be used to download created `zip` archive. Example:
128
   *     `https://dl.boxcloud.com/2.0/zip_downloads/29l00nfxDyHOt7RphI9zT_w==nDnZEDjY2S8iEWWCHEEiptFxwoWojjlibZjJ6geuE5xnXENDTPxzgbks_yY=/content`
129
   * @param headers Headers of getZipDownloadContent method
130
   */
131
  public InputStream getZipDownloadContent(
132
      String downloadUrl, GetZipDownloadContentHeaders headers) {
133
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
×
134
    FetchResponse response =
×
135
        this.networkSession
136
            .getNetworkClient()
×
137
            .fetch(
×
138
                new FetchOptions.Builder(downloadUrl, "GET")
139
                    .headers(headersMap)
×
140
                    .responseFormat(ResponseFormat.BINARY)
×
141
                    .auth(this.auth)
×
142
                    .networkSession(this.networkSession)
×
143
                    .build());
×
144
    return response.getContent();
×
145
  }
146

147
  /**
148
   * Returns the download status of a `zip` archive, allowing an application to inspect the progress
149
   * of the download as well as the number of items that might have been skipped.
150
   *
151
   * <p>This endpoint can only be accessed once the download has started. Subsequently this endpoint
152
   * is valid for 12 hours from the start of the download.
153
   *
154
   * <p>The URL of this endpoint should not be considered as fixed. Instead, use the [Create zip
155
   * download](https://developer.box.com/reference/post-zip-downloads) API to request to create a
156
   * `zip` archive, and then follow the `status_url` field in the response to this endpoint.
157
   *
158
   * @param statusUrl The URL that can be used to get the status of the `zip` archive being
159
   *     downloaded. Example:
160
   *     `https://dl.boxcloud.com/2.0/zip_downloads/29l00nfxDyHOt7RphI9zT_w==nDnZEDjY2S8iEWWCHEEiptFxwoWojjlibZjJ6geuE5xnXENDTPxzgbks_yY=/status`
161
   */
162
  public ZipDownloadStatus getZipDownloadStatus(String statusUrl) {
163
    return getZipDownloadStatus(statusUrl, new GetZipDownloadStatusHeaders());
×
164
  }
165

166
  /**
167
   * Returns the download status of a `zip` archive, allowing an application to inspect the progress
168
   * of the download as well as the number of items that might have been skipped.
169
   *
170
   * <p>This endpoint can only be accessed once the download has started. Subsequently this endpoint
171
   * is valid for 12 hours from the start of the download.
172
   *
173
   * <p>The URL of this endpoint should not be considered as fixed. Instead, use the [Create zip
174
   * download](https://developer.box.com/reference/post-zip-downloads) API to request to create a
175
   * `zip` archive, and then follow the `status_url` field in the response to this endpoint.
176
   *
177
   * @param statusUrl The URL that can be used to get the status of the `zip` archive being
178
   *     downloaded. Example:
179
   *     `https://dl.boxcloud.com/2.0/zip_downloads/29l00nfxDyHOt7RphI9zT_w==nDnZEDjY2S8iEWWCHEEiptFxwoWojjlibZjJ6geuE5xnXENDTPxzgbks_yY=/status`
180
   * @param headers Headers of getZipDownloadStatus method
181
   */
182
  public ZipDownloadStatus getZipDownloadStatus(
183
      String statusUrl, GetZipDownloadStatusHeaders headers) {
184
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
×
185
    FetchResponse response =
×
186
        this.networkSession
187
            .getNetworkClient()
×
188
            .fetch(
×
189
                new FetchOptions.Builder(statusUrl, "GET")
190
                    .headers(headersMap)
×
191
                    .responseFormat(ResponseFormat.JSON)
×
192
                    .auth(this.auth)
×
193
                    .networkSession(this.networkSession)
×
194
                    .build());
×
195
    return JsonManager.deserialize(response.getData(), ZipDownloadStatus.class);
×
196
  }
197

198
  /**
199
   * Creates a zip and downloads its content
200
   *
201
   * @param requestBody Zip download request body
202
   */
203
  public InputStream downloadZip(ZipDownloadRequest requestBody) {
204
    return downloadZip(requestBody, new DownloadZipHeaders());
×
205
  }
206

207
  /**
208
   * Creates a zip and downloads its content
209
   *
210
   * @param requestBody Zip download request body
211
   * @param headers Headers of zip download method
212
   */
213
  public InputStream downloadZip(ZipDownloadRequest requestBody, DownloadZipHeaders headers) {
214
    ZipDownload zipDownloadSession =
×
215
        this.createZipDownload(
×
216
            new ZipDownloadRequest.Builder(requestBody.getItems())
×
217
                .downloadFileName(requestBody.getDownloadFileName())
×
218
                .build(),
×
219
            new CreateZipDownloadHeaders.Builder().extraHeaders(headers.getExtraHeaders()).build());
×
220
    return this.getZipDownloadContent(
×
221
        zipDownloadSession.getDownloadUrl(),
×
222
        new GetZipDownloadContentHeaders.Builder().extraHeaders(headers.getExtraHeaders()).build());
×
223
  }
224

225
  public Authentication getAuth() {
226
    return auth;
×
227
  }
228

229
  public NetworkSession getNetworkSession() {
230
    return networkSession;
×
231
  }
232

233
  public static class Builder {
234

235
    protected Authentication auth;
236

237
    protected NetworkSession networkSession;
238

NEW
239
    public Builder() {}
×
240

241
    public Builder auth(Authentication auth) {
UNCOV
242
      this.auth = auth;
×
UNCOV
243
      return this;
×
244
    }
245

246
    public Builder networkSession(NetworkSession networkSession) {
UNCOV
247
      this.networkSession = networkSession;
×
UNCOV
248
      return this;
×
249
    }
250

251
    public ZipDownloadsManager build() {
NEW
252
      if (this.networkSession == null) {
×
NEW
253
        this.networkSession = new NetworkSession();
×
254
      }
255
      return new ZipDownloadsManager(this);
×
256
    }
257
  }
258
}
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