-
Notifications
You must be signed in to change notification settings - Fork 189
Expand file tree
/
Copy pathHubItemsManager.java
More file actions
169 lines (149 loc) · 6.28 KB
/
HubItemsManager.java
File metadata and controls
169 lines (149 loc) · 6.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
package com.box.sdkgen.managers.hubitems;
import static com.box.sdkgen.internal.utils.UtilsManager.convertToString;
import static com.box.sdkgen.internal.utils.UtilsManager.entryOf;
import static com.box.sdkgen.internal.utils.UtilsManager.mapOf;
import static com.box.sdkgen.internal.utils.UtilsManager.mergeMaps;
import static com.box.sdkgen.internal.utils.UtilsManager.prepareParams;
import com.box.sdkgen.networking.auth.Authentication;
import com.box.sdkgen.networking.fetchoptions.FetchOptions;
import com.box.sdkgen.networking.fetchoptions.ResponseFormat;
import com.box.sdkgen.networking.fetchresponse.FetchResponse;
import com.box.sdkgen.networking.network.NetworkSession;
import com.box.sdkgen.schemas.v2025r0.hubitemsmanagerequestv2025r0.HubItemsManageRequestV2025R0;
import com.box.sdkgen.schemas.v2025r0.hubitemsmanageresponsev2025r0.HubItemsManageResponseV2025R0;
import com.box.sdkgen.schemas.v2025r0.hubitemsv2025r0.HubItemsV2025R0;
import com.box.sdkgen.serialization.json.JsonManager;
import java.util.Map;
public class HubItemsManager {
public Authentication auth;
public NetworkSession networkSession;
public HubItemsManager() {
this.networkSession = new NetworkSession();
}
protected HubItemsManager(Builder builder) {
this.auth = builder.auth;
this.networkSession = builder.networkSession;
}
/**
* Retrieves all items associated with a Box Hub.
*
* @param queryParams Query parameters of getHubItemsV2025R0 method
*/
public HubItemsV2025R0 getHubItemsV2025R0(GetHubItemsV2025R0QueryParams queryParams) {
return getHubItemsV2025R0(queryParams, new GetHubItemsV2025R0Headers());
}
/**
* Retrieves all items associated with a Box Hub.
*
* @param queryParams Query parameters of getHubItemsV2025R0 method
* @param headers Headers of getHubItemsV2025R0 method
*/
public HubItemsV2025R0 getHubItemsV2025R0(
GetHubItemsV2025R0QueryParams queryParams, GetHubItemsV2025R0Headers headers) {
Map<String, String> queryParamsMap =
prepareParams(
mapOf(
entryOf("hub_id", convertToString(queryParams.getHubId())),
entryOf("parent_id", convertToString(queryParams.getParentId())),
entryOf("marker", convertToString(queryParams.getMarker())),
entryOf("limit", convertToString(queryParams.getLimit()))));
Map<String, String> headersMap =
prepareParams(
mergeMaps(
mapOf(entryOf("box-version", convertToString(headers.getBoxVersion()))),
headers.getExtraHeaders()));
FetchResponse response =
this.networkSession
.getNetworkClient()
.fetch(
new FetchOptions.Builder(
String.join(
"", this.networkSession.getBaseUrls().getBaseUrl(), "/2.0/hub_items"),
"GET")
.params(queryParamsMap)
.headers(headersMap)
.responseFormat(ResponseFormat.JSON)
.auth(this.auth)
.networkSession(this.networkSession)
.build());
return JsonManager.deserialize(response.getData(), HubItemsV2025R0.class);
}
/**
* Adds and/or removes Box Hub items from a Box Hub.
*
* @param hubId The unique identifier that represent a hub.
* <p>The ID for any hub can be determined by visiting this hub in the web application and
* copying the ID from the URL. For example, for the URL `https://*.app.box.com/hubs/123` the
* `hub_id` is `123`. Example: "12345"
* @param requestBody Request body of manageHubItemsV2025R0 method
*/
public HubItemsManageResponseV2025R0 manageHubItemsV2025R0(
String hubId, HubItemsManageRequestV2025R0 requestBody) {
return manageHubItemsV2025R0(hubId, requestBody, new ManageHubItemsV2025R0Headers());
}
/**
* Adds and/or removes Box Hub items from a Box Hub.
*
* @param hubId The unique identifier that represent a hub.
* <p>The ID for any hub can be determined by visiting this hub in the web application and
* copying the ID from the URL. For example, for the URL `https://*.app.box.com/hubs/123` the
* `hub_id` is `123`. Example: "12345"
* @param requestBody Request body of manageHubItemsV2025R0 method
* @param headers Headers of manageHubItemsV2025R0 method
*/
public HubItemsManageResponseV2025R0 manageHubItemsV2025R0(
String hubId,
HubItemsManageRequestV2025R0 requestBody,
ManageHubItemsV2025R0Headers headers) {
Map<String, String> headersMap =
prepareParams(
mergeMaps(
mapOf(entryOf("box-version", convertToString(headers.getBoxVersion()))),
headers.getExtraHeaders()));
FetchResponse response =
this.networkSession
.getNetworkClient()
.fetch(
new FetchOptions.Builder(
String.join(
"",
this.networkSession.getBaseUrls().getBaseUrl(),
"/2.0/hubs/",
convertToString(hubId),
"/manage_items"),
"POST")
.headers(headersMap)
.data(JsonManager.serialize(requestBody))
.contentType("application/json")
.responseFormat(ResponseFormat.JSON)
.auth(this.auth)
.networkSession(this.networkSession)
.build());
return JsonManager.deserialize(response.getData(), HubItemsManageResponseV2025R0.class);
}
public Authentication getAuth() {
return auth;
}
public NetworkSession getNetworkSession() {
return networkSession;
}
public static class Builder {
protected Authentication auth;
protected NetworkSession networkSession;
public Builder() {}
public Builder auth(Authentication auth) {
this.auth = auth;
return this;
}
public Builder networkSession(NetworkSession networkSession) {
this.networkSession = networkSession;
return this;
}
public HubItemsManager build() {
if (this.networkSession == null) {
this.networkSession = new NetworkSession();
}
return new HubItemsManager(this);
}
}
}