• 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

91.57
/src/main/java/com/box/sdkgen/managers/weblinks/WebLinksManager.java
1
package com.box.sdkgen.managers.weblinks;
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.weblink.WebLink;
15
import com.box.sdkgen.serialization.json.JsonManager;
16
import java.util.Map;
17

18
public class WebLinksManager {
19

20
  public Authentication auth;
21

22
  public NetworkSession networkSession;
23

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

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

33
  /**
34
   * Creates a web link object within a folder.
35
   *
36
   * @param requestBody Request body of createWebLink method
37
   */
38
  public WebLink createWebLink(CreateWebLinkRequestBody requestBody) {
39
    return createWebLink(requestBody, new CreateWebLinkHeaders());
1✔
40
  }
41

42
  /**
43
   * Creates a web link object within a folder.
44
   *
45
   * @param requestBody Request body of createWebLink method
46
   * @param headers Headers of createWebLink method
47
   */
48
  public WebLink createWebLink(CreateWebLinkRequestBody requestBody, CreateWebLinkHeaders headers) {
49
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
1✔
50
    FetchResponse response =
1✔
51
        this.networkSession
52
            .getNetworkClient()
1✔
53
            .fetch(
1✔
54
                new FetchOptions.Builder(
55
                        String.join(
1✔
56
                            "", this.networkSession.getBaseUrls().getBaseUrl(), "/2.0/web_links"),
1✔
57
                        "POST")
58
                    .headers(headersMap)
1✔
59
                    .data(JsonManager.serialize(requestBody))
1✔
60
                    .contentType("application/json")
1✔
61
                    .responseFormat(ResponseFormat.JSON)
1✔
62
                    .auth(this.auth)
1✔
63
                    .networkSession(this.networkSession)
1✔
64
                    .build());
1✔
65
    return JsonManager.deserialize(response.getData(), WebLink.class);
1✔
66
  }
67

68
  /**
69
   * Retrieve information about a web link.
70
   *
71
   * @param webLinkId The ID of the web link. Example: "12345"
72
   */
73
  public WebLink getWebLinkById(String webLinkId) {
74
    return getWebLinkById(webLinkId, new GetWebLinkByIdHeaders());
1✔
75
  }
76

77
  /**
78
   * Retrieve information about a web link.
79
   *
80
   * @param webLinkId The ID of the web link. Example: "12345"
81
   * @param headers Headers of getWebLinkById method
82
   */
83
  public WebLink getWebLinkById(String webLinkId, GetWebLinkByIdHeaders headers) {
84
    Map<String, String> headersMap =
1✔
85
        prepareParams(
1✔
86
            mergeMaps(
1✔
87
                mapOf(entryOf("boxapi", convertToString(headers.getBoxapi()))),
1✔
88
                headers.getExtraHeaders()));
1✔
89
    FetchResponse response =
1✔
90
        this.networkSession
91
            .getNetworkClient()
1✔
92
            .fetch(
1✔
93
                new FetchOptions.Builder(
94
                        String.join(
1✔
95
                            "",
96
                            this.networkSession.getBaseUrls().getBaseUrl(),
1✔
97
                            "/2.0/web_links/",
98
                            convertToString(webLinkId)),
1✔
99
                        "GET")
100
                    .headers(headersMap)
1✔
101
                    .responseFormat(ResponseFormat.JSON)
1✔
102
                    .auth(this.auth)
1✔
103
                    .networkSession(this.networkSession)
1✔
104
                    .build());
1✔
105
    return JsonManager.deserialize(response.getData(), WebLink.class);
1✔
106
  }
107

108
  /**
109
   * Updates a web link object.
110
   *
111
   * @param webLinkId The ID of the web link. Example: "12345"
112
   */
113
  public WebLink updateWebLinkById(String webLinkId) {
114
    return updateWebLinkById(
×
115
        webLinkId, new UpdateWebLinkByIdRequestBody(), new UpdateWebLinkByIdHeaders());
116
  }
117

118
  /**
119
   * Updates a web link object.
120
   *
121
   * @param webLinkId The ID of the web link. Example: "12345"
122
   * @param requestBody Request body of updateWebLinkById method
123
   */
124
  public WebLink updateWebLinkById(String webLinkId, UpdateWebLinkByIdRequestBody requestBody) {
125
    return updateWebLinkById(webLinkId, requestBody, new UpdateWebLinkByIdHeaders());
1✔
126
  }
127

128
  /**
129
   * Updates a web link object.
130
   *
131
   * @param webLinkId The ID of the web link. Example: "12345"
132
   * @param headers Headers of updateWebLinkById method
133
   */
134
  public WebLink updateWebLinkById(String webLinkId, UpdateWebLinkByIdHeaders headers) {
135
    return updateWebLinkById(webLinkId, new UpdateWebLinkByIdRequestBody(), headers);
×
136
  }
137

138
  /**
139
   * Updates a web link object.
140
   *
141
   * @param webLinkId The ID of the web link. Example: "12345"
142
   * @param requestBody Request body of updateWebLinkById method
143
   * @param headers Headers of updateWebLinkById method
144
   */
145
  public WebLink updateWebLinkById(
146
      String webLinkId,
147
      UpdateWebLinkByIdRequestBody requestBody,
148
      UpdateWebLinkByIdHeaders headers) {
149
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
1✔
150
    FetchResponse response =
1✔
151
        this.networkSession
152
            .getNetworkClient()
1✔
153
            .fetch(
1✔
154
                new FetchOptions.Builder(
155
                        String.join(
1✔
156
                            "",
157
                            this.networkSession.getBaseUrls().getBaseUrl(),
1✔
158
                            "/2.0/web_links/",
159
                            convertToString(webLinkId)),
1✔
160
                        "PUT")
161
                    .headers(headersMap)
1✔
162
                    .data(JsonManager.serialize(requestBody))
1✔
163
                    .contentType("application/json")
1✔
164
                    .responseFormat(ResponseFormat.JSON)
1✔
165
                    .auth(this.auth)
1✔
166
                    .networkSession(this.networkSession)
1✔
167
                    .build());
1✔
168
    return JsonManager.deserialize(response.getData(), WebLink.class);
1✔
169
  }
170

171
  /**
172
   * Deletes a web link.
173
   *
174
   * @param webLinkId The ID of the web link. Example: "12345"
175
   */
176
  public void deleteWebLinkById(String webLinkId) {
177
    deleteWebLinkById(webLinkId, new DeleteWebLinkByIdHeaders());
1✔
178
  }
1✔
179

180
  /**
181
   * Deletes a web link.
182
   *
183
   * @param webLinkId The ID of the web link. Example: "12345"
184
   * @param headers Headers of deleteWebLinkById method
185
   */
186
  public void deleteWebLinkById(String webLinkId, DeleteWebLinkByIdHeaders headers) {
187
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
1✔
188
    FetchResponse response =
1✔
189
        this.networkSession
190
            .getNetworkClient()
1✔
191
            .fetch(
1✔
192
                new FetchOptions.Builder(
193
                        String.join(
1✔
194
                            "",
195
                            this.networkSession.getBaseUrls().getBaseUrl(),
1✔
196
                            "/2.0/web_links/",
197
                            convertToString(webLinkId)),
1✔
198
                        "DELETE")
199
                    .headers(headersMap)
1✔
200
                    .responseFormat(ResponseFormat.NO_CONTENT)
1✔
201
                    .auth(this.auth)
1✔
202
                    .networkSession(this.networkSession)
1✔
203
                    .build());
1✔
204
  }
1✔
205

206
  public Authentication getAuth() {
207
    return auth;
×
208
  }
209

210
  public NetworkSession getNetworkSession() {
211
    return networkSession;
×
212
  }
213

214
  public static class Builder {
215

216
    protected Authentication auth;
217

218
    protected NetworkSession networkSession;
219

220
    public Builder() {
1✔
221
      this.networkSession = new NetworkSession();
1✔
222
    }
1✔
223

224
    public Builder auth(Authentication auth) {
225
      this.auth = auth;
1✔
226
      return this;
1✔
227
    }
228

229
    public Builder networkSession(NetworkSession networkSession) {
230
      this.networkSession = networkSession;
1✔
231
      return this;
1✔
232
    }
233

234
    public WebLinksManager build() {
235
      return new WebLinksManager(this);
1✔
236
    }
237
  }
238
}
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