From 2f270d84fae36df3e0e4db16645a6855ae99f999 Mon Sep 17 00:00:00 2001 From: Dana AlTayeh Date: Tue, 26 Nov 2024 16:00:50 +0300 Subject: [PATCH] update BaseXapClient --- .../sdk/core/client/BaseXapClient.kt | 19 ++++++++++++++++++- .../sdk/core/client/OkHttpEventListener.kt | 1 - 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/core/src/main/kotlin/com/expediagroup/sdk/core/client/BaseXapClient.kt b/core/src/main/kotlin/com/expediagroup/sdk/core/client/BaseXapClient.kt index 74cd8c78b..607dae8f3 100644 --- a/core/src/main/kotlin/com/expediagroup/sdk/core/client/BaseXapClient.kt +++ b/core/src/main/kotlin/com/expediagroup/sdk/core/client/BaseXapClient.kt @@ -22,7 +22,8 @@ import com.expediagroup.sdk.core.configuration.provider.XapConfigurationProvider import com.expediagroup.sdk.core.plugin.authentication.strategy.AuthenticationStrategy import io.ktor.client.HttpClient import io.ktor.client.engine.HttpClientEngine -import io.ktor.client.engine.okhttp.* +import io.ktor.client.engine.okhttp.OkHttp +import okhttp3.OkHttpClient /** * The integration point between the SDK Core and the product SDKs. @@ -62,4 +63,20 @@ abstract class BaseXapClient( /** A [BaseXapClient] builder. */ @Suppress("unused", "UnnecessaryAbstractClass") // This is used by the generated SDK clients. abstract class Builder> : HttpConfigurableBuilder() + + /** A [BaseXapClient] builder with ability to pass a custom okhttp client. */ + @Suppress("unused", "UnnecessaryAbstractClass") // This is used by the generated SDK clients. + abstract class BuilderWithHttpClient> : Client.Builder() { + protected var okHttpClient: OkHttpClient? = null + + @Suppress("UNCHECKED_CAST") + override fun self(): SELF = this as SELF + + /** Sets the [OkHttpClient] to use for the [BaseXapClient]. */ + fun okHttpClient(okHttpClient: OkHttpClient): SELF { + this.okHttpClient = okHttpClient + return self() + } + + } } diff --git a/core/src/main/kotlin/com/expediagroup/sdk/core/client/OkHttpEventListener.kt b/core/src/main/kotlin/com/expediagroup/sdk/core/client/OkHttpEventListener.kt index 72d09ca6c..3374e9347 100644 --- a/core/src/main/kotlin/com/expediagroup/sdk/core/client/OkHttpEventListener.kt +++ b/core/src/main/kotlin/com/expediagroup/sdk/core/client/OkHttpEventListener.kt @@ -27,7 +27,6 @@ import okhttp3.EventListener import java.io.IOException import java.net.InetSocketAddress import java.net.Proxy -import java.util.UUID import java.util.concurrent.atomic.AtomicReference /**