11package io .apimatic .core .configurations .http .client ;
22
3+ import io .apimatic .coreinterfaces .http .proxy .ProxyConfiguration ;
34import java .util .Arrays ;
45import java .util .HashSet ;
56import java .util .Set ;
@@ -122,6 +123,12 @@ public final class CoreHttpClientConfiguration implements ClientConfiguration {
122123 */
123124 private final boolean skipSslCertVerification ;
124125
126+ /**
127+ * The proxy configuration used to route network requests through a proxy server.
128+ * Contains details such as address, port, and optional authentication credentials.
129+ */
130+ private final ProxyConfiguration proxyConfiguration ;
131+
125132 /**
126133 * @param timeout
127134 * @param numberOfRetries
@@ -140,7 +147,7 @@ private CoreHttpClientConfiguration(final long timeout, final int numberOfRetrie
140147 final boolean skipSslCertVerification , final Set <Integer > httpStatusCodesToRetry ,
141148 final Set <Method > httpMethodsToRetry , final long maximumRetryWaitTime ,
142149 final boolean shouldRetryOnTimeout , final okhttp3 .OkHttpClient httpClientInstance ,
143- final boolean overrideHttpClientConfigurations ) {
150+ final boolean overrideHttpClientConfigurations , final ProxyConfiguration proxyConfiguration ) {
144151 this .timeout = timeout ;
145152 this .numberOfRetries = numberOfRetries ;
146153 this .backOffFactor = backOffFactor ;
@@ -152,6 +159,7 @@ private CoreHttpClientConfiguration(final long timeout, final int numberOfRetrie
152159 this .httpClientInstance = httpClientInstance ;
153160 this .overrideHttpClientConfigurations = overrideHttpClientConfigurations ;
154161 this .skipSslCertVerification = skipSslCertVerification ;
162+ this .proxyConfiguration = proxyConfiguration ;
155163 }
156164
157165 /**
@@ -243,6 +251,14 @@ public boolean skipSslCertVerification() {
243251 return skipSslCertVerification ;
244252 }
245253
254+ /**
255+ * Returns the proxy configuration used to route requests through a proxy server.
256+ * This includes the proxy address, port, and any authentication credentials.
257+ *
258+ * @return the {@link ProxyConfiguration}, or {@code null} if no proxy is configured
259+ */
260+ public ProxyConfiguration getProxyConfiguration () { return proxyConfiguration ; }
261+
246262 /**
247263 * Converts this HttpClientConfiguration into string format.
248264 * @return String representation of this class.
@@ -255,7 +271,8 @@ public String toString() {
255271 + ", httpMethodsToRetry=" + httpMethodsToRetry + ", maximumRetryWaitTime="
256272 + maximumRetryWaitTime + ", shouldRetryOnTimeout=" + shouldRetryOnTimeout
257273 + ", httpClientInstance=" + httpClientInstance
258- + ", overrideHttpClientConfigurations=" + overrideHttpClientConfigurations + "]" ;
274+ + ", overrideHttpClientConfigurations=" + overrideHttpClientConfigurations
275+ + ", proxy=" + proxyConfiguration + "]" ;
259276 }
260277
261278 /**
@@ -269,7 +286,8 @@ public Builder newBuilder() {
269286 .httpStatusCodesToRetry (httpStatusCodesToRetry )
270287 .httpMethodsToRetry (httpMethodsToRetry ).maximumRetryWaitTime (maximumRetryWaitTime )
271288 .shouldRetryOnTimeout (shouldRetryOnTimeout )
272- .httpClientInstance (httpClientInstance , overrideHttpClientConfigurations );
289+ .httpClientInstance (httpClientInstance , overrideHttpClientConfigurations )
290+ .proxyConfiguration (proxyConfiguration );
273291 }
274292
275293 /**
@@ -322,6 +340,11 @@ public static class Builder {
322340 * Skip Ssl certification.
323341 */
324342 private boolean skipSslCertVerification ;
343+ /**
344+ * The proxy configuration used to route network requests through a proxy server.
345+ * Contains details such as address, port, and optional authentication credentials.
346+ */
347+ private ProxyConfiguration proxyConfiguration ;
325348
326349 /**
327350 * Default Constructor to initiate builder with default properties.
@@ -463,6 +486,17 @@ public Builder skipSslCertVerification(boolean skipSslCertVerification) {
463486 return this ;
464487 }
465488
489+ /**
490+ * Sets the proxy configuration to be used for routing requests through a proxy server.
491+ *
492+ * @param proxyConfiguration the {@link ProxyConfiguration} instance to use
493+ * @return the builder instance
494+ */
495+ public Builder proxyConfiguration (ProxyConfiguration proxyConfiguration ) {
496+ this .proxyConfiguration = proxyConfiguration ;
497+ return this ;
498+ }
499+
466500 /**
467501 * Builds a new HttpClientConfiguration object using the set fields.
468502 * @return {@link CoreHttpClientConfiguration}.
@@ -471,7 +505,7 @@ public CoreHttpClientConfiguration build() {
471505 return new CoreHttpClientConfiguration (timeout , numberOfRetries , backOffFactor ,
472506 retryInterval , skipSslCertVerification , httpStatusCodesToRetry ,
473507 httpMethodsToRetry , maximumRetryWaitTime , shouldRetryOnTimeout ,
474- httpClientInstance , overrideHttpClientConfigurations );
508+ httpClientInstance , overrideHttpClientConfigurations , proxyConfiguration );
475509 }
476510 }
477511}
0 commit comments