Skip to content

Commit d7894b9

Browse files
committed
chore: add KDoc documentation for API-related classes and methods
1 parent 4a8dd84 commit d7894b9

File tree

14 files changed

+209
-23
lines changed

14 files changed

+209
-23
lines changed

.github/workflows/generate-publish-sdk.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ jobs:
3232
export KOTLIN_POST_PROCESS_FILE="npm run --prefix src/main/resources/post-processor process"
3333
gradle openApiGenerate
3434
35-
- name: Publish Snapshots
35+
- name: Publish Snapshot
3636
working-directory: xap-sdk
3737
env:
3838
GPG_PASSPHRASE: ${{ secrets.GPG_PRIVATE_KEY_PASSPHRASE }}
3939
GPG_SECRET: ${{ secrets.GPG_PRIVATE_KEY }}
4040
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
4141
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
42-
run: gradle publishSnapshots
42+
run: gradle publishSnapshot

generator/tasks/lambdas.gradle.kts

Lines changed: 0 additions & 2 deletions
This file was deleted.

xap-sdk/build.gradle.kts

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -56,25 +56,6 @@ ktlint {
5656
)
5757
}
5858

59-
tasks.register("publishSnapshots") {
60-
val snapshotModules =
61-
rootProject.subprojects.filter { project ->
62-
project.version.toString().contains("-SNAPSHOT") && project.tasks.names.contains("publish")
63-
}
64-
65-
if (snapshotModules.isNotEmpty()) {
66-
dependsOn(snapshotModules.map { ":${it.name}:publish" })
67-
}
68-
69-
doLast {
70-
if (snapshotModules.isEmpty()) {
71-
println("❌ No snapshot modules to publish.")
72-
} else {
73-
println("📦 Successfully published snapshots for: ${snapshotModules.map { it.name }}")
74-
}
75-
}
76-
}
77-
7859
apply("$rootDir/gradle-tasks/publish.gradle.kts")
7960
apply("$rootDir/gradle-tasks/signing.gradle.kts")
8061
apply("$rootDir/gradle-tasks/snapshot.gradle.kts")

xap-sdk/src/main/kotlin/com/expediagroup/sdk/xap/client/AsyncXapClient.kt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ import com.expediagroup.sdk.xap.configuration.XAP_OBJECT_MAPPER
1313
import com.expediagroup.sdk.xap.core.AsyncRequestExecutor
1414
import java.util.concurrent.CompletableFuture
1515

16+
/**
17+
* Asynchronous client for XAP API.
18+
*
19+
* @property apiEndpoint The API endpoint for XAP.
20+
* @property restExecutor The executor for handling REST operations.
21+
*/
1622
class AsyncXapClient private constructor(
1723
config: AsyncXapClientConfiguration,
1824
) : AsyncRestClient() {
@@ -25,15 +31,36 @@ class AsyncXapClient private constructor(
2531
requestExecutor = AsyncRequestExecutor(configuration = config),
2632
)
2733

34+
/**
35+
* Executes an operation that does not expect a response body.
36+
*
37+
* @param operation The operation to execute.
38+
* @return A CompletableFuture containing the response.
39+
*/
2840
fun execute(operation: OperationNoResponseBodyTrait): CompletableFuture<Response<Nothing?>> = restExecutor.execute(operation)
2941

42+
/**
43+
* Executes an operation that expects a response body.
44+
*
45+
* @param T The type of the response body.
46+
* @param operation The operation to execute.
47+
* @return A CompletableFuture containing the response.
48+
*/
3049
fun <T : Any> execute(operation: JacksonModelOperationResponseBodyTrait<T>): CompletableFuture<Response<T>> = restExecutor.execute(operation)
3150

3251
companion object {
52+
/**
53+
* Builder for creating an instance of [AsyncXapClient].
54+
*/
3355
class Builder : AsyncClientBuilder<AsyncXapClient>() {
3456
override fun build(): AsyncXapClient = AsyncXapClient(buildConfig())
3557
}
3658

59+
/**
60+
* Creates a new builder for [AsyncXapClient].
61+
*
62+
* @return A new [Builder] instance.
63+
*/
3764
@JvmStatic
3865
fun builder() = Builder()
3966
}

xap-sdk/src/main/kotlin/com/expediagroup/sdk/xap/client/XapClient.kt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ import com.expediagroup.sdk.xap.configuration.XAP_OBJECT_MAPPER
1313
import com.expediagroup.sdk.xap.configuration.XapClientConfiguration
1414
import com.expediagroup.sdk.xap.core.RequestExecutor
1515

16+
/**
17+
* Synchronous client for XAP API.
18+
*
19+
* @property apiEndpoint The API endpoint for XAP.
20+
* @property restExecutor The executor for handling REST operations.
21+
*/
1622
class XapClient private constructor(
1723
config: XapClientConfiguration,
1824
) : RestClient() {
@@ -34,15 +40,36 @@ class XapClient private constructor(
3440
),
3541
)
3642

43+
/**
44+
* Executes an operation that does not expect a response body.
45+
*
46+
* @param operation The operation to execute.
47+
* @return The response of the operation.
48+
*/
3749
fun execute(operation: OperationNoResponseBodyTrait): Response<Nothing?> = restExecutor.execute(operation)
3850

51+
/**
52+
* Executes an operation that expects a response body.
53+
*
54+
* @param T The type of the response body.
55+
* @param operation The operation to execute.
56+
* @return The response of the operation.
57+
*/
3958
fun <T : Any> execute(operation: JacksonModelOperationResponseBodyTrait<T>): Response<T> = restExecutor.execute(operation)
4059

4160
companion object {
61+
/**
62+
* Builder for creating an instance of [XapClient].
63+
*/
4264
class Builder : ClientBuilder<XapClient>() {
4365
override fun build(): XapClient = XapClient(buildConfig())
4466
}
4567

68+
/**
69+
* Creates a new builder for [XapClient].
70+
*
71+
* @return A new [Builder] instance.
72+
*/
4673
@JvmStatic
4774
fun builder() = Builder()
4875
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
package com.expediagroup.sdk.xap.configuration
22

3+
/**
4+
* Data class representing an API endpoint.
5+
*
6+
* @property endpoint The URL of the API endpoint.
7+
*/
38
data class ApiEndpoint(
49
val endpoint: String,
510
)
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
package com.expediagroup.sdk.xap.configuration
22

3+
/**
4+
* Enum representing the client environment.
5+
*/
36
enum class ClientEnvironment {
7+
/** Production environment. */
48
PROD,
59
}

xap-sdk/src/main/kotlin/com/expediagroup/sdk/xap/configuration/EndpointProvider.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,17 @@ package com.expediagroup.sdk.xap.configuration
22

33
import com.expediagroup.sdk.core.exception.client.ExpediaGroupConfigurationException
44

5+
/**
6+
* Provides API endpoints based on the client environment.
7+
*/
58
internal object EndpointProvider {
9+
/**
10+
* Retrieves the API endpoint for the given environment.
11+
*
12+
* @param environment The client environment. Defaults to [ClientEnvironment.PROD] if not specified.
13+
* @return The [ApiEndpoint] for the specified environment.
14+
* @throws ExpediaGroupConfigurationException If the environment is unsupported.
15+
*/
616
fun getXapApiEndpoint(environment: ClientEnvironment? = null): ApiEndpoint {
717
val env = environment ?: ClientEnvironment.PROD
818

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
package com.expediagroup.sdk.xap.configuration
22

3+
/**
4+
* Enum representing the XAP API endpoints.
5+
*
6+
* @property url The URL of the API endpoint.
7+
*/
38
enum class XapApiEndpoint(
49
val url: String,
510
) {
11+
/** Production environment endpoint. */
612
PROD("https://apim.expedia.com"),
713
}

xap-sdk/src/main/kotlin/com/expediagroup/sdk/xap/configuration/XapClientConfiguration.kt

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,92 @@ import com.expediagroup.sdk.core.transport.Transport
55
import com.expediagroup.sdk.rest.AsyncRestClient
66
import com.expediagroup.sdk.rest.RestClient
77

8+
/**
9+
* Configuration data class for XAP client.
10+
*
11+
* @property key The API key.
12+
* @property secret The API secret.
13+
* @property environment The client environment. Defaults to null.
14+
* @property transport The transport mechanism. Defaults to null.
15+
*/
816
data class XapClientConfiguration(
917
val key: String,
1018
val secret: String,
1119
val environment: ClientEnvironment? = null,
1220
val transport: Transport? = null,
1321
)
1422

23+
/**
24+
* Configuration data class for asynchronous XAP client.
25+
*
26+
* @property key The API key.
27+
* @property secret The API secret.
28+
* @property environment The client environment. Defaults to null.
29+
* @property asyncTransport The asynchronous transport mechanism. Defaults to null.
30+
*/
1531
data class AsyncXapClientConfiguration(
1632
val key: String,
1733
val secret: String,
1834
val environment: ClientEnvironment? = null,
1935
val asyncTransport: AsyncTransport? = null,
2036
)
2137

38+
/**
39+
* Abstract builder class for creating instances of [RestClient].
40+
*
41+
* @param T The type of [RestClient] to build.
42+
*/
2243
abstract class ClientBuilder<T : RestClient> {
2344
private var key: String? = null
2445
private var secret: String? = null
2546
private var environment: ClientEnvironment? = null
2647
private var transport: Transport? = null
2748

49+
/**
50+
* Sets the API key.
51+
*
52+
* @param key The API key.
53+
* @return The builder instance.
54+
*/
2855
fun key(key: String) = apply { this.key = key }
2956

57+
/**
58+
* Sets the API secret.
59+
*
60+
* @param secret The API secret.
61+
* @return The builder instance.
62+
*/
3063
fun secret(secret: String) = apply { this.secret = secret }
3164

65+
/**
66+
* Sets the client environment.
67+
*
68+
* @param environment The client environment.
69+
* @return The builder instance.
70+
*/
3271
fun environment(environment: ClientEnvironment) = apply { this.environment = environment }
3372

73+
/**
74+
* Sets the transport mechanism.
75+
*
76+
* @param transport The transport mechanism.
77+
* @return The builder instance.
78+
*/
3479
fun transport(transport: Transport) = apply { this.transport = transport }
3580

81+
/**
82+
* Builds the [RestClient] instance.
83+
*
84+
* @return The built [RestClient] instance.
85+
*/
3686
abstract fun build(): T
3787

88+
/**
89+
* Builds the configuration for the XAP client.
90+
*
91+
* @return The built [XapClientConfiguration] instance.
92+
* @throws IllegalArgumentException If the key or secret is not provided.
93+
*/
3894
protected fun buildConfig(): XapClientConfiguration {
3995
require(key != null) {
4096
"key is required"
@@ -53,22 +109,62 @@ abstract class ClientBuilder<T : RestClient> {
53109
}
54110
}
55111

112+
/**
113+
* Abstract builder class for creating instances of [AsyncRestClient].
114+
*
115+
* @param T The type of [AsyncRestClient] to build.
116+
*/
56117
abstract class AsyncClientBuilder<T : AsyncRestClient> {
57118
private var key: String? = null
58119
private var secret: String? = null
59120
private var environment: ClientEnvironment? = null
60121
private var asyncTransport: AsyncTransport? = null
61122

123+
/**
124+
* Sets the API key.
125+
*
126+
* @param key The API key.
127+
* @return The builder instance.
128+
*/
62129
fun key(key: String) = apply { this.key = key }
63130

131+
/**
132+
* Sets the API secret.
133+
*
134+
* @param secret The API secret.
135+
* @return The builder instance.
136+
*/
64137
fun secret(secret: String) = apply { this.secret = secret }
65138

139+
/**
140+
* Sets the client environment.
141+
*
142+
* @param environment The client environment.
143+
* @return The builder instance.
144+
*/
66145
fun environment(environment: ClientEnvironment) = apply { this.environment = environment }
67146

147+
/**
148+
* Sets the asynchronous transport mechanism.
149+
*
150+
* @param asyncTransport The asynchronous transport mechanism.
151+
* @return The builder instance.
152+
*/
68153
fun asyncTransport(asyncTransport: AsyncTransport) = apply { this.asyncTransport = asyncTransport }
69154

155+
/**
156+
* Builds the [AsyncRestClient] instance.
157+
*
158+
* @return The built [AsyncRestClient] instance.
159+
*/
70160
abstract fun build(): T
71161

162+
/**
163+
* Builds the configuration for the asynchronous XAP client.
164+
*
165+
* @return The built [AsyncXapClientConfiguration] instance.
166+
* @throws IllegalArgumentException If the key or secret is not provided.
167+
*/
72168
protected fun buildConfig(): AsyncXapClientConfiguration {
73169
require(key != null) {
74170
"key is required"

0 commit comments

Comments
 (0)