You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+88-28Lines changed: 88 additions & 28 deletions
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ It is generated with [Stainless](https://www.stainless.com/).
15
15
16
16
<!-- x-release-please-start-version -->
17
17
18
-
The REST API documentation can be found on [developer.onebusaway.org](https://developer.onebusaway.org). KDocs are also available on [javadoc.io](https://javadoc.io/doc/org.onebusaway/onebusaway-sdk-kotlin/0.1.0-alpha.66).
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.69).
val parsedCurrentTime:CurrentTimeRetrieveResponse= currentTime.parse()
178
179
```
@@ -216,6 +217,17 @@ Or to `debug` for more verbose logging:
216
217
$ export ONEBUSAWAY_SDK_LOG=debug
217
218
```
218
219
220
+
## Jackson
221
+
222
+
The SDK depends on [Jackson](https://github.com/FasterXML/jackson) for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default.
223
+
224
+
The SDK throws an exception if it detects an incompatible Jackson version at runtime (e.g. if the default version was overridden in your Maven or Gradle config).
225
+
226
+
If the SDK threw an exception, but you're _certain_ the version is compatible, then disable the version check using the `checkJacksonVersionCompatibility` on [`OnebusawaySdkOkHttpClient`](onebusaway-sdk-kotlin-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClient.kt) or [`OnebusawaySdkOkHttpClientAsync`](onebusaway-sdk-kotlin-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClientAsync.kt).
227
+
228
+
> [!CAUTION]
229
+
> We make no guarantee that the SDK works correctly when the Jackson version check is disabled.
230
+
219
231
## Network options
220
232
221
233
### Retries
@@ -251,8 +263,7 @@ Requests time out after 1 minute by default.
251
263
To set a custom timeout, configure the method call using the `timeout` method:
val currentTime:CurrentTimeRetrieveResponse= client.currentTime().retrieve(RequestOptions.builder().timeout(Duration.ofSeconds(30)).build())
258
269
```
@@ -290,6 +301,42 @@ val client: OnebusawaySdkClient = OnebusawaySdkOkHttpClient.builder()
290
301
.build()
291
302
```
292
303
304
+
### Custom HTTP client
305
+
306
+
The SDK consists of three artifacts:
307
+
308
+
-`onebusaway-sdk-kotlin-core`
309
+
- Contains core SDK logic
310
+
- Does not depend on [OkHttp](https://square.github.io/okhttp)
311
+
- Exposes [`OnebusawaySdkClient`](onebusaway-sdk-kotlin-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClient.kt), [`OnebusawaySdkClientAsync`](onebusaway-sdk-kotlin-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClientAsync.kt), [`OnebusawaySdkClientImpl`](onebusaway-sdk-kotlin-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClientImpl.kt), and [`OnebusawaySdkClientAsyncImpl`](onebusaway-sdk-kotlin-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClientAsyncImpl.kt), all of which can work with any HTTP client
312
+
-`onebusaway-sdk-kotlin-client-okhttp`
313
+
- Depends on [OkHttp](https://square.github.io/okhttp)
314
+
- Exposes [`OnebusawaySdkOkHttpClient`](onebusaway-sdk-kotlin-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClient.kt) and [`OnebusawaySdkOkHttpClientAsync`](onebusaway-sdk-kotlin-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClientAsync.kt), which provide a way to construct [`OnebusawaySdkClientImpl`](onebusaway-sdk-kotlin-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClientImpl.kt) and [`OnebusawaySdkClientAsyncImpl`](onebusaway-sdk-kotlin-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClientAsyncImpl.kt), respectively, using OkHttp
315
+
-`onebusaway-sdk-kotlin`
316
+
- Depends on and exposes the APIs of both `onebusaway-sdk-kotlin-core` and `onebusaway-sdk-kotlin-client-okhttp`
317
+
- Does not have its own logic
318
+
319
+
This structure allows replacing the SDK's default HTTP client without pulling in unnecessary dependencies.
> Try the available [network options](#network-options) before replacing the default client.
325
+
326
+
To use a customized `OkHttpClient`:
327
+
328
+
1. Replace your [`onebusaway-sdk-kotlin` dependency](#installation) with `onebusaway-sdk-kotlin-core`
329
+
2. Copy `onebusaway-sdk-kotlin-client-okhttp`'s [`OkHttpClient`](onebusaway-sdk-kotlin-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OkHttpClient.kt) class into your code and customize it
330
+
3. Construct [`OnebusawaySdkClientImpl`](onebusaway-sdk-kotlin-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClientImpl.kt) or [`OnebusawaySdkClientAsyncImpl`](onebusaway-sdk-kotlin-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClientAsyncImpl.kt), similarly to [`OnebusawaySdkOkHttpClient`](onebusaway-sdk-kotlin-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClient.kt) or [`OnebusawaySdkOkHttpClientAsync`](onebusaway-sdk-kotlin-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClientAsync.kt), using your customized client
331
+
332
+
### Completely custom HTTP client
333
+
334
+
To use a completely custom HTTP client:
335
+
336
+
1. Replace your [`onebusaway-sdk-kotlin` dependency](#installation) with `onebusaway-sdk-kotlin-core`
337
+
2. Write a class that implements the [`HttpClient`](onebusaway-sdk-kotlin-core/src/main/kotlin/org/onebusaway/core/http/HttpClient.kt) interface
338
+
3. Construct [`OnebusawaySdkClientImpl`](onebusaway-sdk-kotlin-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClientImpl.kt) or [`OnebusawaySdkClientAsyncImpl`](onebusaway-sdk-kotlin-core/src/main/kotlin/org/onebusaway/client/OnebusawaySdkClientAsyncImpl.kt), similarly to [`OnebusawaySdkOkHttpClient`](onebusaway-sdk-kotlin-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClient.kt) or [`OnebusawaySdkOkHttpClientAsync`](onebusaway-sdk-kotlin-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClientAsync.kt), using your new client class
339
+
293
340
## Undocumented API functionality
294
341
295
342
The SDK is typed for convenient usage of the documented API. However, it also supports working with undocumented or not yet supported parts of the API.
@@ -300,7 +347,7 @@ To set undocumented parameters, call the `putAdditionalHeader`, `putAdditionalQu
val params:CurrentTimeRetrieveParams=CurrentTimeRetrieveParams.builder()
306
353
.putAdditionalHeader("Secret-Header", "42")
@@ -314,7 +361,7 @@ These can be accessed on the built object later using the `_additionalHeaders()`
314
361
To set a documented parameter or property to an undocumented or not yet supported _value_, pass a [`JsonValue`](onebusaway-sdk-kotlin-core/src/main/kotlin/org/onebusaway/core/Values.kt) object to its setter:
val params:CurrentTimeRetrieveParams=CurrentTimeRetrieveParams.builder().build()
320
367
```
@@ -354,6 +401,20 @@ val complexValue: JsonValue = JsonValue.from(mapOf(
354
401
))
355
402
```
356
403
404
+
Normally a `Builder` class's `build` method will throw [`IllegalStateException`](https://docs.oracle.com/javase/8/docs/api/java/lang/IllegalStateException.html) if any required parameter or property is unset.
405
+
406
+
To forcibly omit a required parameter or property, pass [`JsonMissing`](onebusaway-sdk-kotlin-core/src/main/kotlin/org/onebusaway/core/Values.kt):
Copy file name to clipboardExpand all lines: onebusaway-sdk-kotlin-client-okhttp/src/main/kotlin/org/onebusaway/client/okhttp/OnebusawaySdkOkHttpClient.kt
+12-5Lines changed: 12 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -29,13 +29,20 @@ class OnebusawaySdkOkHttpClient private constructor() {
0 commit comments