|
| 1 | +package com.box.sdkgen.managers.enterpriseconfigurations; |
| 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.v2025r0.enterpriseconfigurationv2025r0.EnterpriseConfigurationV2025R0; |
| 15 | +import com.box.sdkgen.serialization.json.JsonManager; |
| 16 | +import java.util.Map; |
| 17 | + |
| 18 | +public class EnterpriseConfigurationsManager { |
| 19 | + |
| 20 | + public Authentication auth; |
| 21 | + |
| 22 | + public NetworkSession networkSession; |
| 23 | + |
| 24 | + public EnterpriseConfigurationsManager() { |
| 25 | + this.networkSession = new NetworkSession(); |
| 26 | + } |
| 27 | + |
| 28 | + protected EnterpriseConfigurationsManager(Builder builder) { |
| 29 | + this.auth = builder.auth; |
| 30 | + this.networkSession = builder.networkSession; |
| 31 | + } |
| 32 | + |
| 33 | + /** |
| 34 | + * Retrieves the configuration for an enterprise. |
| 35 | + * |
| 36 | + * @param enterpriseId The ID of the enterprise. Example: "3442311" |
| 37 | + * @param queryParams Query parameters of getEnterpriseConfigurationByIdV2025R0 method |
| 38 | + */ |
| 39 | + public EnterpriseConfigurationV2025R0 getEnterpriseConfigurationByIdV2025R0( |
| 40 | + String enterpriseId, GetEnterpriseConfigurationByIdV2025R0QueryParams queryParams) { |
| 41 | + return getEnterpriseConfigurationByIdV2025R0( |
| 42 | + enterpriseId, queryParams, new GetEnterpriseConfigurationByIdV2025R0Headers()); |
| 43 | + } |
| 44 | + |
| 45 | + /** |
| 46 | + * Retrieves the configuration for an enterprise. |
| 47 | + * |
| 48 | + * @param enterpriseId The ID of the enterprise. Example: "3442311" |
| 49 | + * @param queryParams Query parameters of getEnterpriseConfigurationByIdV2025R0 method |
| 50 | + * @param headers Headers of getEnterpriseConfigurationByIdV2025R0 method |
| 51 | + */ |
| 52 | + public EnterpriseConfigurationV2025R0 getEnterpriseConfigurationByIdV2025R0( |
| 53 | + String enterpriseId, |
| 54 | + GetEnterpriseConfigurationByIdV2025R0QueryParams queryParams, |
| 55 | + GetEnterpriseConfigurationByIdV2025R0Headers headers) { |
| 56 | + Map<String, String> queryParamsMap = |
| 57 | + prepareParams(mapOf(entryOf("categories", convertToString(queryParams.getCategories())))); |
| 58 | + Map<String, String> headersMap = |
| 59 | + prepareParams( |
| 60 | + mergeMaps( |
| 61 | + mapOf(entryOf("box-version", convertToString(headers.getBoxVersion()))), |
| 62 | + headers.getExtraHeaders())); |
| 63 | + FetchResponse response = |
| 64 | + this.networkSession |
| 65 | + .getNetworkClient() |
| 66 | + .fetch( |
| 67 | + new FetchOptions.Builder( |
| 68 | + String.join( |
| 69 | + "", |
| 70 | + this.networkSession.getBaseUrls().getBaseUrl(), |
| 71 | + "/2.0/enterprise_configurations/", |
| 72 | + convertToString(enterpriseId)), |
| 73 | + "GET") |
| 74 | + .params(queryParamsMap) |
| 75 | + .headers(headersMap) |
| 76 | + .responseFormat(ResponseFormat.JSON) |
| 77 | + .auth(this.auth) |
| 78 | + .networkSession(this.networkSession) |
| 79 | + .build()); |
| 80 | + return JsonManager.deserialize(response.getData(), EnterpriseConfigurationV2025R0.class); |
| 81 | + } |
| 82 | + |
| 83 | + public Authentication getAuth() { |
| 84 | + return auth; |
| 85 | + } |
| 86 | + |
| 87 | + public NetworkSession getNetworkSession() { |
| 88 | + return networkSession; |
| 89 | + } |
| 90 | + |
| 91 | + public static class Builder { |
| 92 | + |
| 93 | + protected Authentication auth; |
| 94 | + |
| 95 | + protected NetworkSession networkSession; |
| 96 | + |
| 97 | + public Builder() { |
| 98 | + this.networkSession = new NetworkSession(); |
| 99 | + } |
| 100 | + |
| 101 | + public Builder auth(Authentication auth) { |
| 102 | + this.auth = auth; |
| 103 | + return this; |
| 104 | + } |
| 105 | + |
| 106 | + public Builder networkSession(NetworkSession networkSession) { |
| 107 | + this.networkSession = networkSession; |
| 108 | + return this; |
| 109 | + } |
| 110 | + |
| 111 | + public EnterpriseConfigurationsManager build() { |
| 112 | + return new EnterpriseConfigurationsManager(this); |
| 113 | + } |
| 114 | + } |
| 115 | +} |
0 commit comments