001package com.box.sdkgen.managers.hubcollaborations; 002 003import static com.box.sdkgen.internal.utils.UtilsManager.convertToString; 004import static com.box.sdkgen.internal.utils.UtilsManager.entryOf; 005import static com.box.sdkgen.internal.utils.UtilsManager.mapOf; 006import static com.box.sdkgen.internal.utils.UtilsManager.mergeMaps; 007import static com.box.sdkgen.internal.utils.UtilsManager.prepareParams; 008 009import com.box.sdkgen.networking.auth.Authentication; 010import com.box.sdkgen.networking.fetchoptions.FetchOptions; 011import com.box.sdkgen.networking.fetchoptions.ResponseFormat; 012import com.box.sdkgen.networking.fetchresponse.FetchResponse; 013import com.box.sdkgen.networking.network.NetworkSession; 014import com.box.sdkgen.schemas.v2025r0.hubcollaborationcreaterequestv2025r0.HubCollaborationCreateRequestV2025R0; 015import com.box.sdkgen.schemas.v2025r0.hubcollaborationsv2025r0.HubCollaborationsV2025R0; 016import com.box.sdkgen.schemas.v2025r0.hubcollaborationupdaterequestv2025r0.HubCollaborationUpdateRequestV2025R0; 017import com.box.sdkgen.schemas.v2025r0.hubcollaborationv2025r0.HubCollaborationV2025R0; 018import com.box.sdkgen.serialization.json.JsonManager; 019import java.util.Map; 020 021public class HubCollaborationsManager { 022 023 public Authentication auth; 024 025 public NetworkSession networkSession; 026 027 public HubCollaborationsManager() { 028 this.networkSession = new NetworkSession(); 029 } 030 031 protected HubCollaborationsManager(Builder builder) { 032 this.auth = builder.auth; 033 this.networkSession = builder.networkSession; 034 } 035 036 /** 037 * Retrieves all collaborations for a Box Hub. 038 * 039 * @param queryParams Query parameters of getHubCollaborationsV2025R0 method 040 */ 041 public HubCollaborationsV2025R0 getHubCollaborationsV2025R0( 042 GetHubCollaborationsV2025R0QueryParams queryParams) { 043 return getHubCollaborationsV2025R0(queryParams, new GetHubCollaborationsV2025R0Headers()); 044 } 045 046 /** 047 * Retrieves all collaborations for a Box Hub. 048 * 049 * @param queryParams Query parameters of getHubCollaborationsV2025R0 method 050 * @param headers Headers of getHubCollaborationsV2025R0 method 051 */ 052 public HubCollaborationsV2025R0 getHubCollaborationsV2025R0( 053 GetHubCollaborationsV2025R0QueryParams queryParams, 054 GetHubCollaborationsV2025R0Headers headers) { 055 Map<String, String> queryParamsMap = 056 prepareParams( 057 mapOf( 058 entryOf("hub_id", convertToString(queryParams.getHubId())), 059 entryOf("marker", convertToString(queryParams.getMarker())), 060 entryOf("limit", convertToString(queryParams.getLimit())))); 061 Map<String, String> headersMap = 062 prepareParams( 063 mergeMaps( 064 mapOf(entryOf("box-version", convertToString(headers.getBoxVersion()))), 065 headers.getExtraHeaders())); 066 FetchResponse response = 067 this.networkSession 068 .getNetworkClient() 069 .fetch( 070 new FetchOptions.Builder( 071 String.join( 072 "", 073 this.networkSession.getBaseUrls().getBaseUrl(), 074 "/2.0/hub_collaborations"), 075 "GET") 076 .params(queryParamsMap) 077 .headers(headersMap) 078 .responseFormat(ResponseFormat.JSON) 079 .auth(this.auth) 080 .networkSession(this.networkSession) 081 .build()); 082 return JsonManager.deserialize(response.getData(), HubCollaborationsV2025R0.class); 083 } 084 085 /** 086 * Adds a collaboration for a single user or a single group to a Box Hub. 087 * 088 * <p>Collaborations can be created using email address, user IDs, or group IDs. 089 * 090 * @param requestBody Request body of createHubCollaborationV2025R0 method 091 */ 092 public HubCollaborationV2025R0 createHubCollaborationV2025R0( 093 HubCollaborationCreateRequestV2025R0 requestBody) { 094 return createHubCollaborationV2025R0(requestBody, new CreateHubCollaborationV2025R0Headers()); 095 } 096 097 /** 098 * Adds a collaboration for a single user or a single group to a Box Hub. 099 * 100 * <p>Collaborations can be created using email address, user IDs, or group IDs. 101 * 102 * @param requestBody Request body of createHubCollaborationV2025R0 method 103 * @param headers Headers of createHubCollaborationV2025R0 method 104 */ 105 public HubCollaborationV2025R0 createHubCollaborationV2025R0( 106 HubCollaborationCreateRequestV2025R0 requestBody, 107 CreateHubCollaborationV2025R0Headers headers) { 108 Map<String, String> headersMap = 109 prepareParams( 110 mergeMaps( 111 mapOf(entryOf("box-version", convertToString(headers.getBoxVersion()))), 112 headers.getExtraHeaders())); 113 FetchResponse response = 114 this.networkSession 115 .getNetworkClient() 116 .fetch( 117 new FetchOptions.Builder( 118 String.join( 119 "", 120 this.networkSession.getBaseUrls().getBaseUrl(), 121 "/2.0/hub_collaborations"), 122 "POST") 123 .headers(headersMap) 124 .data(JsonManager.serialize(requestBody)) 125 .contentType("application/json") 126 .responseFormat(ResponseFormat.JSON) 127 .auth(this.auth) 128 .networkSession(this.networkSession) 129 .build()); 130 return JsonManager.deserialize(response.getData(), HubCollaborationV2025R0.class); 131 } 132 133 /** 134 * Retrieves details for a Box Hub collaboration by collaboration ID. 135 * 136 * @param hubCollaborationId The ID of the hub collaboration. Example: "1234" 137 */ 138 public HubCollaborationV2025R0 getHubCollaborationByIdV2025R0(String hubCollaborationId) { 139 return getHubCollaborationByIdV2025R0( 140 hubCollaborationId, new GetHubCollaborationByIdV2025R0Headers()); 141 } 142 143 /** 144 * Retrieves details for a Box Hub collaboration by collaboration ID. 145 * 146 * @param hubCollaborationId The ID of the hub collaboration. Example: "1234" 147 * @param headers Headers of getHubCollaborationByIdV2025R0 method 148 */ 149 public HubCollaborationV2025R0 getHubCollaborationByIdV2025R0( 150 String hubCollaborationId, GetHubCollaborationByIdV2025R0Headers headers) { 151 Map<String, String> headersMap = 152 prepareParams( 153 mergeMaps( 154 mapOf(entryOf("box-version", convertToString(headers.getBoxVersion()))), 155 headers.getExtraHeaders())); 156 FetchResponse response = 157 this.networkSession 158 .getNetworkClient() 159 .fetch( 160 new FetchOptions.Builder( 161 String.join( 162 "", 163 this.networkSession.getBaseUrls().getBaseUrl(), 164 "/2.0/hub_collaborations/", 165 convertToString(hubCollaborationId)), 166 "GET") 167 .headers(headersMap) 168 .responseFormat(ResponseFormat.JSON) 169 .auth(this.auth) 170 .networkSession(this.networkSession) 171 .build()); 172 return JsonManager.deserialize(response.getData(), HubCollaborationV2025R0.class); 173 } 174 175 /** 176 * Updates a Box Hub collaboration. Can be used to change the Box Hub role. 177 * 178 * @param hubCollaborationId The ID of the hub collaboration. Example: "1234" 179 * @param requestBody Request body of updateHubCollaborationByIdV2025R0 method 180 */ 181 public HubCollaborationV2025R0 updateHubCollaborationByIdV2025R0( 182 String hubCollaborationId, HubCollaborationUpdateRequestV2025R0 requestBody) { 183 return updateHubCollaborationByIdV2025R0( 184 hubCollaborationId, requestBody, new UpdateHubCollaborationByIdV2025R0Headers()); 185 } 186 187 /** 188 * Updates a Box Hub collaboration. Can be used to change the Box Hub role. 189 * 190 * @param hubCollaborationId The ID of the hub collaboration. Example: "1234" 191 * @param requestBody Request body of updateHubCollaborationByIdV2025R0 method 192 * @param headers Headers of updateHubCollaborationByIdV2025R0 method 193 */ 194 public HubCollaborationV2025R0 updateHubCollaborationByIdV2025R0( 195 String hubCollaborationId, 196 HubCollaborationUpdateRequestV2025R0 requestBody, 197 UpdateHubCollaborationByIdV2025R0Headers headers) { 198 Map<String, String> headersMap = 199 prepareParams( 200 mergeMaps( 201 mapOf(entryOf("box-version", convertToString(headers.getBoxVersion()))), 202 headers.getExtraHeaders())); 203 FetchResponse response = 204 this.networkSession 205 .getNetworkClient() 206 .fetch( 207 new FetchOptions.Builder( 208 String.join( 209 "", 210 this.networkSession.getBaseUrls().getBaseUrl(), 211 "/2.0/hub_collaborations/", 212 convertToString(hubCollaborationId)), 213 "PUT") 214 .headers(headersMap) 215 .data(JsonManager.serialize(requestBody)) 216 .contentType("application/json") 217 .responseFormat(ResponseFormat.JSON) 218 .auth(this.auth) 219 .networkSession(this.networkSession) 220 .build()); 221 return JsonManager.deserialize(response.getData(), HubCollaborationV2025R0.class); 222 } 223 224 /** 225 * Deletes a single Box Hub collaboration. 226 * 227 * @param hubCollaborationId The ID of the hub collaboration. Example: "1234" 228 */ 229 public void deleteHubCollaborationByIdV2025R0(String hubCollaborationId) { 230 deleteHubCollaborationByIdV2025R0( 231 hubCollaborationId, new DeleteHubCollaborationByIdV2025R0Headers()); 232 } 233 234 /** 235 * Deletes a single Box Hub collaboration. 236 * 237 * @param hubCollaborationId The ID of the hub collaboration. Example: "1234" 238 * @param headers Headers of deleteHubCollaborationByIdV2025R0 method 239 */ 240 public void deleteHubCollaborationByIdV2025R0( 241 String hubCollaborationId, DeleteHubCollaborationByIdV2025R0Headers headers) { 242 Map<String, String> headersMap = 243 prepareParams( 244 mergeMaps( 245 mapOf(entryOf("box-version", convertToString(headers.getBoxVersion()))), 246 headers.getExtraHeaders())); 247 FetchResponse response = 248 this.networkSession 249 .getNetworkClient() 250 .fetch( 251 new FetchOptions.Builder( 252 String.join( 253 "", 254 this.networkSession.getBaseUrls().getBaseUrl(), 255 "/2.0/hub_collaborations/", 256 convertToString(hubCollaborationId)), 257 "DELETE") 258 .headers(headersMap) 259 .responseFormat(ResponseFormat.NO_CONTENT) 260 .auth(this.auth) 261 .networkSession(this.networkSession) 262 .build()); 263 } 264 265 public Authentication getAuth() { 266 return auth; 267 } 268 269 public NetworkSession getNetworkSession() { 270 return networkSession; 271 } 272 273 public static class Builder { 274 275 protected Authentication auth; 276 277 protected NetworkSession networkSession; 278 279 public Builder() {} 280 281 public Builder auth(Authentication auth) { 282 this.auth = auth; 283 return this; 284 } 285 286 public Builder networkSession(NetworkSession networkSession) { 287 this.networkSession = networkSession; 288 return this; 289 } 290 291 public HubCollaborationsManager build() { 292 if (this.networkSession == null) { 293 this.networkSession = new NetworkSession(); 294 } 295 return new HubCollaborationsManager(this); 296 } 297 } 298}