Skip to content

Commit a56a07e

Browse files
authored
Merge branch 'v2-dev' into v2/delete-old-code
2 parents 23c0239 + b7c5afe commit a56a07e

File tree

350 files changed

+39465
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

350 files changed

+39465
-0
lines changed

xap-sdk/pom.xml

Lines changed: 874 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
* Copyright (C) 2022 Expedia, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.expediagroup.sdk.core.client
17+
18+
import com.expediagroup.sdk.core.configuration.RapidClientConfiguration
19+
import com.expediagroup.sdk.core.configuration.collector.ConfigurationCollector
20+
import com.expediagroup.sdk.core.configuration.provider.ConfigurationProvider
21+
import com.expediagroup.sdk.core.configuration.provider.RapidConfigurationProvider
22+
import com.expediagroup.sdk.core.plugin.authentication.strategy.AuthenticationStrategy
23+
import io.ktor.client.HttpClient
24+
import io.ktor.client.engine.HttpClientEngine
25+
import io.ktor.client.engine.okhttp.OkHttp
26+
27+
/**
28+
* The integration point between the SDK Core and the product SDKs.
29+
*
30+
* @param httpClientEngine The HTTP client engine to use.
31+
* @param clientConfiguration The configuration for the client.
32+
*/
33+
abstract class BaseRapidClient(
34+
namespace: String,
35+
clientConfiguration: RapidClientConfiguration,
36+
httpClientEngine: HttpClientEngine = DEFAULT_HTTP_CLIENT_ENGINE
37+
) : Client(namespace) {
38+
private val _configurationProvider: ConfigurationProvider =
39+
ConfigurationCollector.create(
40+
clientConfiguration.toProvider(),
41+
RapidConfigurationProvider
42+
)
43+
44+
private val engine: HttpClientEngine =
45+
_configurationProvider.okHttpClient?.let {
46+
OkHttp.create {
47+
config {
48+
preconfigured = it
49+
dispatcher(it.dispatcher)
50+
}
51+
}
52+
} ?: httpClientEngine
53+
54+
private val _httpClient: HttpClient = buildHttpClient(_configurationProvider, AuthenticationStrategy.AuthenticationType.SIGNATURE, engine)
55+
56+
init {
57+
finalize()
58+
}
59+
60+
override val configurationProvider: ConfigurationProvider
61+
get() = _configurationProvider
62+
63+
override val httpClient: HttpClient
64+
get() = _httpClient
65+
66+
/** A [BaseRapidClient] builder. */
67+
@Suppress("unused", "UnnecessaryAbstractClass") // This is used by the generated SDK clients.
68+
abstract class Builder<SELF : Builder<SELF>> : HttpConfigurableBuilder<SELF>()
69+
70+
/** A [BaseRapidClient] builder with ability to pass a custom okhttp client. */
71+
@Suppress("unused", "UnnecessaryAbstractClass") // This is used by the generated SDK clients.
72+
abstract class BuilderWithHttpClient<SELF : Client.BuilderWithHttpClient<SELF>> : Client.BuilderWithHttpClient<SELF>()
73+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
* Copyright (C) 2022 Expedia, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.expediagroup.sdk.core.client
17+
18+
import com.expediagroup.sdk.core.configuration.XapClientConfiguration
19+
import com.expediagroup.sdk.core.configuration.collector.ConfigurationCollector
20+
import com.expediagroup.sdk.core.configuration.provider.ConfigurationProvider
21+
import com.expediagroup.sdk.core.configuration.provider.XapConfigurationProvider
22+
import com.expediagroup.sdk.core.plugin.authentication.strategy.AuthenticationStrategy
23+
import io.ktor.client.HttpClient
24+
import io.ktor.client.engine.HttpClientEngine
25+
import io.ktor.client.engine.okhttp.OkHttp
26+
27+
/**
28+
* The integration point between the SDK Core and the product SDKs.
29+
*
30+
* @param httpClientEngine The HTTP client engine to use.
31+
* @param clientConfiguration The configuration for the client.
32+
*/
33+
abstract class BaseXapClient(
34+
namespace: String,
35+
clientConfiguration: XapClientConfiguration,
36+
httpClientEngine: HttpClientEngine = DEFAULT_HTTP_CLIENT_ENGINE
37+
) : Client(namespace) {
38+
private val _configurationProvider: ConfigurationProvider =
39+
ConfigurationCollector.create(
40+
clientConfiguration.toProvider(),
41+
XapConfigurationProvider
42+
)
43+
44+
private val engine: HttpClientEngine =
45+
_configurationProvider.okHttpClient?.let {
46+
OkHttp.create {
47+
config {
48+
preconfigured = it
49+
dispatcher(it.dispatcher)
50+
}
51+
}
52+
} ?: httpClientEngine
53+
54+
private val _httpClient: HttpClient = buildHttpClient(_configurationProvider, AuthenticationStrategy.AuthenticationType.BASIC, engine)
55+
56+
init {
57+
finalize()
58+
}
59+
60+
override val configurationProvider: ConfigurationProvider
61+
get() = _configurationProvider
62+
63+
override val httpClient: HttpClient
64+
get() = _httpClient
65+
66+
/** A [BaseXapClient] builder. */
67+
@Suppress("unused", "UnnecessaryAbstractClass") // This is used by the generated SDK clients.
68+
abstract class Builder<SELF : Builder<SELF>> : HttpConfigurableBuilder<SELF>()
69+
70+
/** A [BaseXapClient] builder with ability to pass a custom okhttp client. */
71+
@Suppress("unused", "UnnecessaryAbstractClass") // This is used by the generated SDK clients.
72+
abstract class BuilderWithHttpClient<SELF : Client.BuilderWithHttpClient<SELF>> : Client.BuilderWithHttpClient<SELF>()
73+
}

0 commit comments

Comments
 (0)