Skip to content

Commit

Permalink
update BaseXapClient
Browse files Browse the repository at this point in the history
  • Loading branch information
dtayeh committed Nov 26, 2024
1 parent f16b78c commit 2f270d8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -62,4 +63,20 @@ abstract class BaseXapClient(
/** A [BaseXapClient] builder. */
@Suppress("unused", "UnnecessaryAbstractClass") // This is used by the generated SDK clients.
abstract class Builder<SELF : Builder<SELF>> : HttpConfigurableBuilder<SELF>()

/** 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<SELF : Client.Builder<SELF>> : Client.Builder<SELF>() {
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()
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
Expand Down

0 comments on commit 2f270d8

Please sign in to comment.