Skip to content

Commit d22a5fa

Browse files
Merge pull request #313 from OneBusAway/release-please--branches--main--changes--next
release: 0.1.0-alpha.72
2 parents 0c1cc5d + 0ee6d02 commit d22a5fa

File tree

126 files changed

+1703
-51
lines changed

Some content is hidden

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

126 files changed

+1703
-51
lines changed

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "0.1.0-alpha.71"
2+
".": "0.1.0-alpha.72"
33
}

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Changelog
22

3+
## 0.1.0-alpha.72 (2025-06-13)
4+
5+
Full Changelog: [v0.1.0-alpha.71...v0.1.0-alpha.72](https://github.com/OneBusAway/kotlin-sdk/compare/v0.1.0-alpha.71...v0.1.0-alpha.72)
6+
7+
### Features
8+
9+
* **client:** add a `withOptions` method ([10fb83f](https://github.com/OneBusAway/kotlin-sdk/commit/10fb83fbc9d18ac7965672431fa7ba0d3fc68af5))
10+
* **client:** implement per-endpoint base URL support ([3c2b9e1](https://github.com/OneBusAway/kotlin-sdk/commit/3c2b9e1a1ce967946ffa26d0378fe718318c410a))
11+
312
## 0.1.0-alpha.71 (2025-05-22)
413

514
Full Changelog: [v0.1.0-alpha.70...v0.1.0-alpha.71](https://github.com/OneBusAway/kotlin-sdk/compare/v0.1.0-alpha.70...v0.1.0-alpha.71)

README.md

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
<!-- x-release-please-start-version -->
44

5-
[![Maven Central](https://img.shields.io/maven-central/v/org.onebusaway/onebusaway-sdk-kotlin)](https://central.sonatype.com/artifact/org.onebusaway/onebusaway-sdk-kotlin/0.1.0-alpha.71)
6-
[![javadoc](https://javadoc.io/badge2/org.onebusaway/onebusaway-sdk-kotlin/0.1.0-alpha.71/javadoc.svg)](https://javadoc.io/doc/org.onebusaway/onebusaway-sdk-kotlin/0.1.0-alpha.71)
5+
[![Maven Central](https://img.shields.io/maven-central/v/org.onebusaway/onebusaway-sdk-kotlin)](https://central.sonatype.com/artifact/org.onebusaway/onebusaway-sdk-kotlin/0.1.0-alpha.72)
6+
[![javadoc](https://javadoc.io/badge2/org.onebusaway/onebusaway-sdk-kotlin/0.1.0-alpha.72/javadoc.svg)](https://javadoc.io/doc/org.onebusaway/onebusaway-sdk-kotlin/0.1.0-alpha.72)
77

88
<!-- x-release-please-end -->
99

@@ -15,7 +15,7 @@ It is generated with [Stainless](https://www.stainless.com/).
1515

1616
<!-- x-release-please-start-version -->
1717

18-
The REST API documentation can be found on [developer.onebusaway.org](https://developer.onebusaway.org). KDocs are available on [javadoc.io](https://javadoc.io/doc/org.onebusaway/onebusaway-sdk-kotlin/0.1.0-alpha.71).
18+
The REST API documentation can be found on [developer.onebusaway.org](https://developer.onebusaway.org). KDocs are available on [javadoc.io](https://javadoc.io/doc/org.onebusaway/onebusaway-sdk-kotlin/0.1.0-alpha.72).
1919

2020
<!-- x-release-please-end -->
2121

@@ -26,7 +26,7 @@ The REST API documentation can be found on [developer.onebusaway.org](https://de
2626
### Gradle
2727

2828
```kotlin
29-
implementation("org.onebusaway:onebusaway-sdk-kotlin:0.1.0-alpha.71")
29+
implementation("org.onebusaway:onebusaway-sdk-kotlin:0.1.0-alpha.72")
3030
```
3131

3232
### Maven
@@ -35,7 +35,7 @@ implementation("org.onebusaway:onebusaway-sdk-kotlin:0.1.0-alpha.71")
3535
<dependency>
3636
<groupId>org.onebusaway</groupId>
3737
<artifactId>onebusaway-sdk-kotlin</artifactId>
38-
<version>0.1.0-alpha.71</version>
38+
<version>0.1.0-alpha.72</version>
3939
</dependency>
4040
```
4141

@@ -106,6 +106,21 @@ See this table for the available options:
106106
> Don't create more than one client in the same application. Each client has a connection pool and
107107
> thread pools, which are more efficient to share between requests.
108108
109+
### Modifying configuration
110+
111+
To temporarily use a modified client configuration, while reusing the same connection and thread pools, call `withOptions()` on any client or service:
112+
113+
```kotlin
114+
import org.onebusaway.client.OnebusawaySdkClient
115+
116+
val clientWithOptions: OnebusawaySdkClient = client.withOptions {
117+
it.baseUrl("https://example.com")
118+
it.maxRetries(42)
119+
}
120+
```
121+
122+
The `withOptions()` method does not affect the original client or service.
123+
109124
## Requests and responses
110125

111126
To send a request to the Onebusaway SDK API, build an instance of some `Params` class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Kotlin class.

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ repositories {
88

99
allprojects {
1010
group = "org.onebusaway"
11-
version = "0.1.0-alpha.71" // x-release-please-version
11+
version = "0.1.0-alpha.72" // x-release-please-version
1212
}
1313

1414
subprojects {

onebusaway-sdk-kotlin-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OkHttpClient.kt

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import java.time.Duration
77
import kotlinx.coroutines.suspendCancellableCoroutine
88
import okhttp3.Call
99
import okhttp3.Callback
10-
import okhttp3.HttpUrl
1110
import okhttp3.HttpUrl.Companion.toHttpUrl
1211
import okhttp3.MediaType
1312
import okhttp3.MediaType.Companion.toMediaType
@@ -19,7 +18,6 @@ import okhttp3.logging.HttpLoggingInterceptor
1918
import okio.BufferedSink
2019
import org.onebusaway.core.RequestOptions
2120
import org.onebusaway.core.Timeout
22-
import org.onebusaway.core.checkRequired
2321
import org.onebusaway.core.http.Headers
2422
import org.onebusaway.core.http.HttpClient
2523
import org.onebusaway.core.http.HttpMethod
@@ -28,8 +26,7 @@ import org.onebusaway.core.http.HttpRequestBody
2826
import org.onebusaway.core.http.HttpResponse
2927
import org.onebusaway.errors.OnebusawaySdkIoException
3028

31-
class OkHttpClient
32-
private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val baseUrl: HttpUrl) :
29+
class OkHttpClient private constructor(private val okHttpClient: okhttp3.OkHttpClient) :
3330
HttpClient {
3431

3532
override fun execute(request: HttpRequest, requestOptions: RequestOptions): HttpResponse {
@@ -146,11 +143,7 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val
146143
}
147144

148145
private fun HttpRequest.toUrl(): String {
149-
url?.let {
150-
return it
151-
}
152-
153-
val builder = baseUrl.newBuilder()
146+
val builder = baseUrl.toHttpUrl().newBuilder()
154147
pathSegments.forEach(builder::addPathSegment)
155148
queryParams.keys().forEach { key ->
156149
queryParams.values(key).forEach { builder.addQueryParameter(key, it) }
@@ -200,12 +193,9 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val
200193

201194
class Builder internal constructor() {
202195

203-
private var baseUrl: HttpUrl? = null
204196
private var timeout: Timeout = Timeout.default()
205197
private var proxy: Proxy? = null
206198

207-
fun baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl.toHttpUrl() }
208-
209199
fun timeout(timeout: Timeout) = apply { this.timeout = timeout }
210200

211201
fun timeout(timeout: Duration) = timeout(Timeout.builder().request(timeout).build())
@@ -220,8 +210,7 @@ private constructor(private val okHttpClient: okhttp3.OkHttpClient, private val
220210
.writeTimeout(timeout.write())
221211
.callTimeout(timeout.request())
222212
.proxy(proxy)
223-
.build(),
224-
checkRequired("baseUrl", baseUrl),
213+
.build()
225214
)
226215
}
227216
}

onebusaway-sdk-kotlin-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClient.kt

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -163,13 +163,7 @@ class OnebusawaySdkOkHttpClient private constructor() {
163163
fun build(): OnebusawaySdkClient =
164164
OnebusawaySdkClientImpl(
165165
clientOptions
166-
.httpClient(
167-
OkHttpClient.builder()
168-
.baseUrl(clientOptions.baseUrl())
169-
.timeout(timeout)
170-
.proxy(proxy)
171-
.build()
172-
)
166+
.httpClient(OkHttpClient.builder().timeout(timeout).proxy(proxy).build())
173167
.build()
174168
)
175169
}

onebusaway-sdk-kotlin-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClientAsync.kt

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,7 @@ class OnebusawaySdkOkHttpClientAsync private constructor() {
164164
fun build(): OnebusawaySdkClientAsync =
165165
OnebusawaySdkClientAsyncImpl(
166166
clientOptions
167-
.httpClient(
168-
OkHttpClient.builder()
169-
.baseUrl(clientOptions.baseUrl())
170-
.timeout(timeout)
171-
.proxy(proxy)
172-
.build()
173-
)
167+
.httpClient(OkHttpClient.builder().timeout(timeout).proxy(proxy).build())
174168
.build()
175169
)
176170
}

onebusaway-sdk-kotlin-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClient.kt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
package org.onebusaway.client
44

5+
import org.onebusaway.core.ClientOptions
56
import org.onebusaway.services.blocking.AgenciesWithCoverageService
67
import org.onebusaway.services.blocking.AgencyService
78
import org.onebusaway.services.blocking.ArrivalAndDepartureService
@@ -60,6 +61,13 @@ interface OnebusawaySdkClient {
6061
*/
6162
fun withRawResponse(): WithRawResponse
6263

64+
/**
65+
* Returns a view of this service with the given option modifications applied.
66+
*
67+
* The original service is not modified.
68+
*/
69+
fun withOptions(modifier: (ClientOptions.Builder) -> Unit): OnebusawaySdkClient
70+
6371
fun agenciesWithCoverage(): AgenciesWithCoverageService
6472

6573
fun agency(): AgencyService
@@ -134,6 +142,15 @@ interface OnebusawaySdkClient {
134142
*/
135143
interface WithRawResponse {
136144

145+
/**
146+
* Returns a view of this service with the given option modifications applied.
147+
*
148+
* The original service is not modified.
149+
*/
150+
fun withOptions(
151+
modifier: (ClientOptions.Builder) -> Unit
152+
): OnebusawaySdkClient.WithRawResponse
153+
137154
fun agenciesWithCoverage(): AgenciesWithCoverageService.WithRawResponse
138155

139156
fun agency(): AgencyService.WithRawResponse

onebusaway-sdk-kotlin-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClientAsync.kt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
package org.onebusaway.client
44

5+
import org.onebusaway.core.ClientOptions
56
import org.onebusaway.services.async.AgenciesWithCoverageServiceAsync
67
import org.onebusaway.services.async.AgencyServiceAsync
78
import org.onebusaway.services.async.ArrivalAndDepartureServiceAsync
@@ -60,6 +61,13 @@ interface OnebusawaySdkClientAsync {
6061
*/
6162
fun withRawResponse(): WithRawResponse
6263

64+
/**
65+
* Returns a view of this service with the given option modifications applied.
66+
*
67+
* The original service is not modified.
68+
*/
69+
fun withOptions(modifier: (ClientOptions.Builder) -> Unit): OnebusawaySdkClientAsync
70+
6371
fun agenciesWithCoverage(): AgenciesWithCoverageServiceAsync
6472

6573
fun agency(): AgencyServiceAsync
@@ -135,6 +143,15 @@ interface OnebusawaySdkClientAsync {
135143
*/
136144
interface WithRawResponse {
137145

146+
/**
147+
* Returns a view of this service with the given option modifications applied.
148+
*
149+
* The original service is not modified.
150+
*/
151+
fun withOptions(
152+
modifier: (ClientOptions.Builder) -> Unit
153+
): OnebusawaySdkClientAsync.WithRawResponse
154+
138155
fun agenciesWithCoverage(): AgenciesWithCoverageServiceAsync.WithRawResponse
139156

140157
fun agency(): AgencyServiceAsync.WithRawResponse

onebusaway-sdk-kotlin-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClientAsyncImpl.kt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,9 @@ class OnebusawaySdkClientAsyncImpl(private val clientOptions: ClientOptions) :
191191

192192
override fun withRawResponse(): OnebusawaySdkClientAsync.WithRawResponse = withRawResponse
193193

194+
override fun withOptions(modifier: (ClientOptions.Builder) -> Unit): OnebusawaySdkClientAsync =
195+
OnebusawaySdkClientAsyncImpl(clientOptions.toBuilder().apply(modifier).build())
196+
194197
override fun agenciesWithCoverage(): AgenciesWithCoverageServiceAsync = agenciesWithCoverage
195198

196199
override fun agency(): AgencyServiceAsync = agency
@@ -366,6 +369,13 @@ class OnebusawaySdkClientAsyncImpl(private val clientOptions: ClientOptions) :
366369
ShapeServiceAsyncImpl.WithRawResponseImpl(clientOptions)
367370
}
368371

372+
override fun withOptions(
373+
modifier: (ClientOptions.Builder) -> Unit
374+
): OnebusawaySdkClientAsync.WithRawResponse =
375+
OnebusawaySdkClientAsyncImpl.WithRawResponseImpl(
376+
clientOptions.toBuilder().apply(modifier).build()
377+
)
378+
369379
override fun agenciesWithCoverage(): AgenciesWithCoverageServiceAsync.WithRawResponse =
370380
agenciesWithCoverage
371381

0 commit comments

Comments
 (0)