001package com.box.sdkgen.managers.hubitems; 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.hubitemsmanagerequestv2025r0.HubItemsManageRequestV2025R0; 015import com.box.sdkgen.schemas.v2025r0.hubitemsmanageresponsev2025r0.HubItemsManageResponseV2025R0; 016import com.box.sdkgen.schemas.v2025r0.hubitemsv2025r0.HubItemsV2025R0; 017import com.box.sdkgen.serialization.json.JsonManager; 018import java.util.Map; 019 020public class HubItemsManager { 021 022 public Authentication auth; 023 024 public NetworkSession networkSession; 025 026 public HubItemsManager() { 027 this.networkSession = new NetworkSession(); 028 } 029 030 protected HubItemsManager(Builder builder) { 031 this.auth = builder.auth; 032 this.networkSession = builder.networkSession; 033 } 034 035 /** 036 * Retrieves all items associated with a Box Hub. 037 * 038 * @param queryParams Query parameters of getHubItemsV2025R0 method 039 */ 040 public HubItemsV2025R0 getHubItemsV2025R0(GetHubItemsV2025R0QueryParams queryParams) { 041 return getHubItemsV2025R0(queryParams, new GetHubItemsV2025R0Headers()); 042 } 043 044 /** 045 * Retrieves all items associated with a Box Hub. 046 * 047 * @param queryParams Query parameters of getHubItemsV2025R0 method 048 * @param headers Headers of getHubItemsV2025R0 method 049 */ 050 public HubItemsV2025R0 getHubItemsV2025R0( 051 GetHubItemsV2025R0QueryParams queryParams, GetHubItemsV2025R0Headers headers) { 052 Map<String, String> queryParamsMap = 053 prepareParams( 054 mapOf( 055 entryOf("hub_id", convertToString(queryParams.getHubId())), 056 entryOf("parent_id", convertToString(queryParams.getParentId())), 057 entryOf("marker", convertToString(queryParams.getMarker())), 058 entryOf("limit", convertToString(queryParams.getLimit())))); 059 Map<String, String> headersMap = 060 prepareParams( 061 mergeMaps( 062 mapOf(entryOf("box-version", convertToString(headers.getBoxVersion()))), 063 headers.getExtraHeaders())); 064 FetchResponse response = 065 this.networkSession 066 .getNetworkClient() 067 .fetch( 068 new FetchOptions.Builder( 069 String.join( 070 "", this.networkSession.getBaseUrls().getBaseUrl(), "/2.0/hub_items"), 071 "GET") 072 .params(queryParamsMap) 073 .headers(headersMap) 074 .responseFormat(ResponseFormat.JSON) 075 .auth(this.auth) 076 .networkSession(this.networkSession) 077 .build()); 078 return JsonManager.deserialize(response.getData(), HubItemsV2025R0.class); 079 } 080 081 /** 082 * Adds and/or removes Box Hub items from a Box Hub. 083 * 084 * @param hubId The unique identifier that represent a hub. 085 * <p>The ID for any hub can be determined by visiting this hub in the web application and 086 * copying the ID from the URL. For example, for the URL `https://*.app.box.com/hubs/123` the 087 * `hub_id` is `123`. Example: "12345" 088 * @param requestBody Request body of manageHubItemsV2025R0 method 089 */ 090 public HubItemsManageResponseV2025R0 manageHubItemsV2025R0( 091 String hubId, HubItemsManageRequestV2025R0 requestBody) { 092 return manageHubItemsV2025R0(hubId, requestBody, new ManageHubItemsV2025R0Headers()); 093 } 094 095 /** 096 * Adds and/or removes Box Hub items from a Box Hub. 097 * 098 * @param hubId The unique identifier that represent a hub. 099 * <p>The ID for any hub can be determined by visiting this hub in the web application and 100 * copying the ID from the URL. For example, for the URL `https://*.app.box.com/hubs/123` the 101 * `hub_id` is `123`. Example: "12345" 102 * @param requestBody Request body of manageHubItemsV2025R0 method 103 * @param headers Headers of manageHubItemsV2025R0 method 104 */ 105 public HubItemsManageResponseV2025R0 manageHubItemsV2025R0( 106 String hubId, 107 HubItemsManageRequestV2025R0 requestBody, 108 ManageHubItemsV2025R0Headers headers) { 109 Map<String, String> headersMap = 110 prepareParams( 111 mergeMaps( 112 mapOf(entryOf("box-version", convertToString(headers.getBoxVersion()))), 113 headers.getExtraHeaders())); 114 FetchResponse response = 115 this.networkSession 116 .getNetworkClient() 117 .fetch( 118 new FetchOptions.Builder( 119 String.join( 120 "", 121 this.networkSession.getBaseUrls().getBaseUrl(), 122 "/2.0/hubs/", 123 convertToString(hubId), 124 "/manage_items"), 125 "POST") 126 .headers(headersMap) 127 .data(JsonManager.serialize(requestBody)) 128 .contentType("application/json") 129 .responseFormat(ResponseFormat.JSON) 130 .auth(this.auth) 131 .networkSession(this.networkSession) 132 .build()); 133 return JsonManager.deserialize(response.getData(), HubItemsManageResponseV2025R0.class); 134 } 135 136 public Authentication getAuth() { 137 return auth; 138 } 139 140 public NetworkSession getNetworkSession() { 141 return networkSession; 142 } 143 144 public static class Builder { 145 146 protected Authentication auth; 147 148 protected NetworkSession networkSession; 149 150 public Builder() {} 151 152 public Builder auth(Authentication auth) { 153 this.auth = auth; 154 return this; 155 } 156 157 public Builder networkSession(NetworkSession networkSession) { 158 this.networkSession = networkSession; 159 return this; 160 } 161 162 public HubItemsManager build() { 163 if (this.networkSession == null) { 164 this.networkSession = new NetworkSession(); 165 } 166 return new HubItemsManager(this); 167 } 168 } 169}