001package com.box.sdkgen.managers.enterpriseconfigurations;
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.enterpriseconfigurationv2025r0.EnterpriseConfigurationV2025R0;
015import com.box.sdkgen.serialization.json.JsonManager;
016import java.util.Map;
017
018public class EnterpriseConfigurationsManager {
019
020  public Authentication auth;
021
022  public NetworkSession networkSession;
023
024  public EnterpriseConfigurationsManager() {
025    this.networkSession = new NetworkSession();
026  }
027
028  protected EnterpriseConfigurationsManager(Builder builder) {
029    this.auth = builder.auth;
030    this.networkSession = builder.networkSession;
031  }
032
033  /**
034   * Retrieves the configuration for an enterprise.
035   *
036   * @param enterpriseId The ID of the enterprise. Example: "3442311"
037   * @param queryParams Query parameters of getEnterpriseConfigurationByIdV2025R0 method
038   */
039  public EnterpriseConfigurationV2025R0 getEnterpriseConfigurationByIdV2025R0(
040      String enterpriseId, GetEnterpriseConfigurationByIdV2025R0QueryParams queryParams) {
041    return getEnterpriseConfigurationByIdV2025R0(
042        enterpriseId, queryParams, new GetEnterpriseConfigurationByIdV2025R0Headers());
043  }
044
045  /**
046   * Retrieves the configuration for an enterprise.
047   *
048   * @param enterpriseId The ID of the enterprise. Example: "3442311"
049   * @param queryParams Query parameters of getEnterpriseConfigurationByIdV2025R0 method
050   * @param headers Headers of getEnterpriseConfigurationByIdV2025R0 method
051   */
052  public EnterpriseConfigurationV2025R0 getEnterpriseConfigurationByIdV2025R0(
053      String enterpriseId,
054      GetEnterpriseConfigurationByIdV2025R0QueryParams queryParams,
055      GetEnterpriseConfigurationByIdV2025R0Headers headers) {
056    Map<String, String> queryParamsMap =
057        prepareParams(mapOf(entryOf("categories", convertToString(queryParams.getCategories()))));
058    Map<String, String> headersMap =
059        prepareParams(
060            mergeMaps(
061                mapOf(entryOf("box-version", convertToString(headers.getBoxVersion()))),
062                headers.getExtraHeaders()));
063    FetchResponse response =
064        this.networkSession
065            .getNetworkClient()
066            .fetch(
067                new FetchOptions.Builder(
068                        String.join(
069                            "",
070                            this.networkSession.getBaseUrls().getBaseUrl(),
071                            "/2.0/enterprise_configurations/",
072                            convertToString(enterpriseId)),
073                        "GET")
074                    .params(queryParamsMap)
075                    .headers(headersMap)
076                    .responseFormat(ResponseFormat.JSON)
077                    .auth(this.auth)
078                    .networkSession(this.networkSession)
079                    .build());
080    return JsonManager.deserialize(response.getData(), EnterpriseConfigurationV2025R0.class);
081  }
082
083  public Authentication getAuth() {
084    return auth;
085  }
086
087  public NetworkSession getNetworkSession() {
088    return networkSession;
089  }
090
091  public static class Builder {
092
093    protected Authentication auth;
094
095    protected NetworkSession networkSession;
096
097    public Builder() {}
098
099    public Builder auth(Authentication auth) {
100      this.auth = auth;
101      return this;
102    }
103
104    public Builder networkSession(NetworkSession networkSession) {
105      this.networkSession = networkSession;
106      return this;
107    }
108
109    public EnterpriseConfigurationsManager build() {
110      if (this.networkSession == null) {
111        this.networkSession = new NetworkSession();
112      }
113      return new EnterpriseConfigurationsManager(this);
114    }
115  }
116}