Skip to content

Commit

Permalink
chore(rapid): Remove Rapid Logic
Browse files Browse the repository at this point in the history
  • Loading branch information
mohnoor94 committed Dec 13, 2022
1 parent e07149f commit eac8b8d
Show file tree
Hide file tree
Showing 11 changed files with 10 additions and 536 deletions.
3 changes: 2 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,6 @@
<exclude>**/constant/**</exclude>

<exclude>**/client/openapi/OpenApiStub*</exclude>
<exclude>**/client/openapi/RapidOpenApiStub*</exclude>
<exclude>**/client/Client*</exclude>
<exclude>**/client/openapi/OpenApiStub*</exclude>
<exclude>**/client/Client*</exclude>
Expand All @@ -440,6 +439,8 @@
<exclude>**/authentication/AuthenticationConfiguration*</exclude>
<exclude>**/authentication/AuthenticationHook*</exclude>
<exclude>**/authentication/AuthenticationPlugin*</exclude>
<exclude>**/authentication/AuthenticationStrategy*</exclude>
<exclude>**/authentication/strategies/**</exclude>

<exclude>**/logging/**</exclude>
<exclude>**/serialization/**</exclude>
Expand Down
15 changes: 5 additions & 10 deletions src/main/kotlin/com/expediagroup/sdk/core/client/Client.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import com.expediagroup.sdk.core.plugin.Hooks
import com.expediagroup.sdk.core.plugin.authentication.AuthenticationConfiguration
import com.expediagroup.sdk.core.plugin.authentication.AuthenticationHook
import com.expediagroup.sdk.core.plugin.authentication.AuthenticationPlugin
import com.expediagroup.sdk.core.plugin.authentication.strategies.AuthenticationStrategy.AuthenticationType
import com.expediagroup.sdk.core.plugin.encoding.EncodingConfiguration
import com.expediagroup.sdk.core.plugin.encoding.EncodingPlugin
import com.expediagroup.sdk.core.plugin.hooks
Expand All @@ -46,12 +45,10 @@ import io.ktor.client.engine.HttpClientEngine
*
* @param httpClientEngine The HTTP client engine to use.
* @param clientConfiguration The configuration for the client.
* @param isRapid If the client is RapidApi
*/
class Client private constructor(
httpClientEngine: HttpClientEngine,
clientConfiguration: ClientConfiguration,
isRapid: Boolean
clientConfiguration: ClientConfiguration
) {
/**
* The HTTP client to perform requests with.
Expand All @@ -69,11 +66,11 @@ class Client private constructor(
val authenticationConfiguration = AuthenticationConfiguration.from(
this,
Credentials.from(configurationCollector.key, configurationCollector.secret),
configurationCollector.authEndpoint,
AuthenticationType.from(isRapid)
configurationCollector.authEndpoint
)

plugins {
use(LoggingPlugin).with(LoggingConfiguration.from(this))
use(LoggingPlugin).with(LoggingConfiguration.from(this))
use(SerializationPlugin).with(SerializationConfiguration.from(this))
use(AuthenticationPlugin).with(authenticationConfiguration)
Expand All @@ -95,15 +92,13 @@ class Client private constructor(
*
* @param httpClientEngine The HttpClientEngine to use.
* @param clientConfiguration The ClientConfiguration to use.
* @param isRapid If the client is RapidApi
* @return A Client.
*/
@JvmOverloads
fun from(
httpClientEngine: HttpClientEngine,
clientConfiguration: ClientConfiguration = ClientConfiguration.EMPTY,
isRapid: Boolean
): Client = Client(httpClientEngine, clientConfiguration, isRapid)
clientConfiguration: ClientConfiguration = ClientConfiguration.EMPTY
): Client = Client(httpClientEngine, clientConfiguration)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ abstract class OpenApiStub(
/**
* Create a new [Client] instance to be used by the generated OpenAPI APIs.
*/
protected open fun createClient(): Client = Client.from(OkHttp.create(), clientConfiguration, false)
protected open fun createClient(): Client = Client.from(OkHttp.create(), clientConfiguration)

protected fun collectionDelimiter(format: String): String {
return when (format) {
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,5 @@ internal interface AuthenticationStrategy {
enum class AuthenticationType {
BEARER,
SIGNATURE;

companion object {
fun from(isRapid: Boolean) = if (isRapid) SIGNATURE else BEARER
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ internal object ClientFactory {
.authEndpoint(DefaultConfigurationProvider.authEndpoint)
.build()

fun createClient(): Client = Client.from(MockEngineFactory.createDefaultEngine(), configuration, false)
fun createClient(): Client = Client.from(MockEngineFactory.createDefaultEngine(), configuration)

fun createClient(mockEngine: HttpClientEngine): Client = Client.from(mockEngine, configuration, false)

fun createRapidClient(): Client = Client.from(MockEngineFactory.createEmptyResponseEngine(), configuration, true)
fun createClient(mockEngine: HttpClientEngine): Client = Client.from(mockEngine, configuration)
}
Loading

0 comments on commit eac8b8d

Please sign in to comment.