Skip to content

Commit 03218b9

Browse files
feat(client): propagate headers/query params methods to client builders (#374)
1 parent 406f833 commit 03218b9

3 files changed

Lines changed: 40 additions & 4 deletions

File tree

lithic-java-client-okhttp/src/main/kotlin/com/lithic/api/client/okhttp/LithicOkHttpClient.kt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,24 @@ class LithicOkHttpClient private constructor() {
5454

5555
fun removeHeader(name: String) = apply { clientOptions.removeHeader(name) }
5656

57+
fun queryParams(queryParams: Map<String, Iterable<String>>) = apply {
58+
clientOptions.queryParams(queryParams)
59+
}
60+
61+
fun putQueryParam(key: String, value: String) = apply {
62+
clientOptions.putQueryParam(key, value)
63+
}
64+
65+
fun putQueryParams(key: String, values: Iterable<String>) = apply {
66+
clientOptions.putQueryParams(key, values)
67+
}
68+
69+
fun putAllQueryParams(queryParams: Map<String, Iterable<String>>) = apply {
70+
clientOptions.putAllQueryParams(queryParams)
71+
}
72+
73+
fun removeQueryParam(key: String) = apply { clientOptions.removeQueryParam(key) }
74+
5775
fun timeout(timeout: Duration) = apply { this.timeout = timeout }
5876

5977
fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) }

lithic-java-client-okhttp/src/main/kotlin/com/lithic/api/client/okhttp/LithicOkHttpClientAsync.kt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,24 @@ class LithicOkHttpClientAsync private constructor() {
5454

5555
fun removeHeader(name: String) = apply { clientOptions.removeHeader(name) }
5656

57+
fun queryParams(queryParams: Map<String, Iterable<String>>) = apply {
58+
clientOptions.queryParams(queryParams)
59+
}
60+
61+
fun putQueryParam(key: String, value: String) = apply {
62+
clientOptions.putQueryParam(key, value)
63+
}
64+
65+
fun putQueryParams(key: String, values: Iterable<String>) = apply {
66+
clientOptions.putQueryParams(key, values)
67+
}
68+
69+
fun putAllQueryParams(queryParams: Map<String, Iterable<String>>) = apply {
70+
clientOptions.putAllQueryParams(queryParams)
71+
}
72+
73+
fun removeQueryParam(key: String) = apply { clientOptions.removeQueryParam(key) }
74+
5775
fun timeout(timeout: Duration) = apply { this.timeout = timeout }
5876

5977
fun maxRetries(maxRetries: Int) = apply { clientOptions.maxRetries(maxRetries) }

lithic-java-core/src/main/kotlin/com/lithic/api/core/ClientOptions.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,17 +95,17 @@ private constructor(
9595
putAllQueryParams(queryParams)
9696
}
9797

98-
fun putQueryParam(name: String, value: String) = apply { queryParams.put(name, value) }
98+
fun putQueryParam(key: String, value: String) = apply { queryParams.put(key, value) }
9999

100-
fun putQueryParams(name: String, values: Iterable<String>) = apply {
101-
queryParams.putAll(name, values)
100+
fun putQueryParams(key: String, values: Iterable<String>) = apply {
101+
queryParams.putAll(key, values)
102102
}
103103

104104
fun putAllQueryParams(queryParams: Map<String, Iterable<String>>) = apply {
105105
queryParams.forEach(::putQueryParams)
106106
}
107107

108-
fun removeQueryParam(name: String) = apply { queryParams.removeAll(name) }
108+
fun removeQueryParam(key: String) = apply { queryParams.removeAll(key) }
109109

110110
fun responseValidation(responseValidation: Boolean) = apply {
111111
this.responseValidation = responseValidation

0 commit comments

Comments
 (0)