• 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

83.93
/src/main/java/com/box/sdkgen/managers/invites/InvitesManager.java
1
package com.box.sdkgen.managers.invites;
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.invite.Invite;
15
import com.box.sdkgen.serialization.json.JsonManager;
16
import java.util.Map;
17

18
public class InvitesManager {
19

20
  public Authentication auth;
21

22
  public NetworkSession networkSession;
23

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

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

33
  /**
34
   * Invites an existing external user to join an enterprise.
35
   *
36
   * <p>The existing user can not be part of another enterprise and must already have a Box account.
37
   * Once invited, the user will receive an email and are prompted to accept the invitation within
38
   * the Box web application.
39
   *
40
   * <p>This method requires the "Manage An Enterprise" scope enabled for the application, which can
41
   * be enabled within the developer console.
42
   *
43
   * @param requestBody Request body of createInvite method
44
   */
45
  public Invite createInvite(CreateInviteRequestBody requestBody) {
46
    return createInvite(requestBody, new CreateInviteQueryParams(), new CreateInviteHeaders());
1✔
47
  }
48

49
  /**
50
   * Invites an existing external user to join an enterprise.
51
   *
52
   * <p>The existing user can not be part of another enterprise and must already have a Box account.
53
   * Once invited, the user will receive an email and are prompted to accept the invitation within
54
   * the Box web application.
55
   *
56
   * <p>This method requires the "Manage An Enterprise" scope enabled for the application, which can
57
   * be enabled within the developer console.
58
   *
59
   * @param requestBody Request body of createInvite method
60
   * @param queryParams Query parameters of createInvite method
61
   */
62
  public Invite createInvite(
63
      CreateInviteRequestBody requestBody, CreateInviteQueryParams queryParams) {
64
    return createInvite(requestBody, queryParams, new CreateInviteHeaders());
×
65
  }
66

67
  /**
68
   * Invites an existing external user to join an enterprise.
69
   *
70
   * <p>The existing user can not be part of another enterprise and must already have a Box account.
71
   * Once invited, the user will receive an email and are prompted to accept the invitation within
72
   * the Box web application.
73
   *
74
   * <p>This method requires the "Manage An Enterprise" scope enabled for the application, which can
75
   * be enabled within the developer console.
76
   *
77
   * @param requestBody Request body of createInvite method
78
   * @param headers Headers of createInvite method
79
   */
80
  public Invite createInvite(CreateInviteRequestBody requestBody, CreateInviteHeaders headers) {
81
    return createInvite(requestBody, new CreateInviteQueryParams(), headers);
×
82
  }
83

84
  /**
85
   * Invites an existing external user to join an enterprise.
86
   *
87
   * <p>The existing user can not be part of another enterprise and must already have a Box account.
88
   * Once invited, the user will receive an email and are prompted to accept the invitation within
89
   * the Box web application.
90
   *
91
   * <p>This method requires the "Manage An Enterprise" scope enabled for the application, which can
92
   * be enabled within the developer console.
93
   *
94
   * @param requestBody Request body of createInvite method
95
   * @param queryParams Query parameters of createInvite method
96
   * @param headers Headers of createInvite method
97
   */
98
  public Invite createInvite(
99
      CreateInviteRequestBody requestBody,
100
      CreateInviteQueryParams queryParams,
101
      CreateInviteHeaders headers) {
102
    Map<String, String> queryParamsMap =
1✔
103
        prepareParams(mapOf(entryOf("fields", convertToString(queryParams.getFields()))));
1✔
104
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
1✔
105
    FetchResponse response =
1✔
106
        this.networkSession
107
            .getNetworkClient()
1✔
108
            .fetch(
1✔
109
                new FetchOptions.Builder(
110
                        String.join(
1✔
111
                            "", this.networkSession.getBaseUrls().getBaseUrl(), "/2.0/invites"),
1✔
112
                        "POST")
113
                    .params(queryParamsMap)
1✔
114
                    .headers(headersMap)
1✔
115
                    .data(JsonManager.serialize(requestBody))
1✔
116
                    .contentType("application/json")
1✔
117
                    .responseFormat(ResponseFormat.JSON)
1✔
118
                    .auth(this.auth)
1✔
119
                    .networkSession(this.networkSession)
1✔
120
                    .build());
1✔
121
    return JsonManager.deserialize(response.getData(), Invite.class);
1✔
122
  }
123

124
  /**
125
   * Returns the status of a user invite.
126
   *
127
   * @param inviteId The ID of an invite. Example: "213723"
128
   */
129
  public Invite getInviteById(String inviteId) {
130
    return getInviteById(inviteId, new GetInviteByIdQueryParams(), new GetInviteByIdHeaders());
1✔
131
  }
132

133
  /**
134
   * Returns the status of a user invite.
135
   *
136
   * @param inviteId The ID of an invite. Example: "213723"
137
   * @param queryParams Query parameters of getInviteById method
138
   */
139
  public Invite getInviteById(String inviteId, GetInviteByIdQueryParams queryParams) {
140
    return getInviteById(inviteId, queryParams, new GetInviteByIdHeaders());
×
141
  }
142

143
  /**
144
   * Returns the status of a user invite.
145
   *
146
   * @param inviteId The ID of an invite. Example: "213723"
147
   * @param headers Headers of getInviteById method
148
   */
149
  public Invite getInviteById(String inviteId, GetInviteByIdHeaders headers) {
150
    return getInviteById(inviteId, new GetInviteByIdQueryParams(), headers);
×
151
  }
152

153
  /**
154
   * Returns the status of a user invite.
155
   *
156
   * @param inviteId The ID of an invite. Example: "213723"
157
   * @param queryParams Query parameters of getInviteById method
158
   * @param headers Headers of getInviteById method
159
   */
160
  public Invite getInviteById(
161
      String inviteId, GetInviteByIdQueryParams queryParams, GetInviteByIdHeaders headers) {
162
    Map<String, String> queryParamsMap =
1✔
163
        prepareParams(mapOf(entryOf("fields", convertToString(queryParams.getFields()))));
1✔
164
    Map<String, String> headersMap = prepareParams(mergeMaps(mapOf(), headers.getExtraHeaders()));
1✔
165
    FetchResponse response =
1✔
166
        this.networkSession
167
            .getNetworkClient()
1✔
168
            .fetch(
1✔
169
                new FetchOptions.Builder(
170
                        String.join(
1✔
171
                            "",
172
                            this.networkSession.getBaseUrls().getBaseUrl(),
1✔
173
                            "/2.0/invites/",
174
                            convertToString(inviteId)),
1✔
175
                        "GET")
176
                    .params(queryParamsMap)
1✔
177
                    .headers(headersMap)
1✔
178
                    .responseFormat(ResponseFormat.JSON)
1✔
179
                    .auth(this.auth)
1✔
180
                    .networkSession(this.networkSession)
1✔
181
                    .build());
1✔
182
    return JsonManager.deserialize(response.getData(), Invite.class);
1✔
183
  }
184

185
  public Authentication getAuth() {
186
    return auth;
×
187
  }
188

189
  public NetworkSession getNetworkSession() {
190
    return networkSession;
×
191
  }
192

193
  public static class Builder {
194

195
    protected Authentication auth;
196

197
    protected NetworkSession networkSession;
198

199
    public Builder() {
1✔
200
      this.networkSession = new NetworkSession();
1✔
201
    }
1✔
202

203
    public Builder auth(Authentication auth) {
204
      this.auth = auth;
1✔
205
      return this;
1✔
206
    }
207

208
    public Builder networkSession(NetworkSession networkSession) {
209
      this.networkSession = networkSession;
1✔
210
      return this;
1✔
211
    }
212

213
    public InvitesManager build() {
214
      return new InvitesManager(this);
1✔
215
    }
216
  }
217
}
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