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
+65-59Lines changed: 65 additions & 59 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,30 +1,30 @@
1
1
# Onebusaway SDK Kotlin API Library
2
2
3
-
The Onebusaway SDK Kotlin SDK provides convenient access to the Onebusaway SDK REST API from applications written in Kotlin. It includes helper classes with helpful types and documentation for every request and response property.
4
-
5
-
The Onebusaway SDK Kotlin SDK is similar to the Onebusaway SDK Java SDK but with minor differences that make it more ergonomic for use in Kotlin, such as nullable values instead of `Optional`, `Sequence` instead of `Stream`, and suspend functions instead of `CompletableFuture`.
3
+
<!-- x-release-please-start-version -->
6
4
7
-
It is generated with [Stainless](https://www.stainlessapi.com/).
The REST API documentation can be found on [developer.onebusaway.org](https://developer.onebusaway.org).
9
+
The Onebusaway SDK Kotlin SDK provides convenient access to the Onebusaway SDK REST API from applications written in Kotlin.
12
10
13
-
---
11
+
The Onebusaway SDK Kotlin SDK is similar to the Onebusaway SDK Java SDK but with minor differences that make it more ergonomic for use in Kotlin, such as nullable values instead of `Optional`, `Sequence` instead of `Stream`, and suspend functions instead of `CompletableFuture`.
14
12
15
-
## Getting started
13
+
It is generated with [Stainless](https://www.stainlessapi.com/).
16
14
17
-
### Install dependencies
15
+
The REST API documentation can be found on [developer.onebusaway.org](https://developer.onebusaway.org).
@@ -75,8 +80,7 @@ Read the documentation for more configuration options.
75
80
76
81
### Example: creating a resource
77
82
78
-
To create a new current time, first use the `CurrentTimeRetrieveParams` builder to specify attributes,
79
-
then pass that to the `retrieve` method of the `currentTime` service.
83
+
To create a new current time, first use the `CurrentTimeRetrieveParams` builder to specify attributes, then pass that to the `retrieve` method of the `currentTime` service.
See [Undocumented request params](#undocumented-request-params) for how to send arbitrary parameters.
113
102
114
103
## Responses
115
104
@@ -125,8 +114,7 @@ val currentTime: CurrentTimeRetrieveResponse = client.currentTime().retrieve().v
125
114
126
115
### Response properties as JSON
127
116
128
-
In rare cases, you may want to access the underlying JSON value for a response property rather than using the typed version provided by
129
-
this SDK. Each model property has a corresponding JSON version, with an underscore before the method name, which returns a `JsonField` value.
117
+
In rare cases, you may want to access the underlying JSON value for a response property rather than using the typed version provided by this SDK. Each model property has a corresponding JSON version, with an underscore before the method name, which returns a `JsonField` value.
130
118
131
119
```kotlin
132
120
importjava.util.Optional
@@ -166,31 +154,30 @@ val secret: JsonValue = references._additionalProperties().get("secret_field")
166
154
167
155
This library throws exceptions in a single hierarchy for easy handling:
168
156
169
-
-**`OnebusawaySdkException`** - Base exception for all exceptions
157
+
-**`OnebusawaySdkException`** - Base exception for all exceptions
170
158
171
-
-**`OnebusawaySdkServiceException`** - HTTP errors with a well-formed response body we were able to parse. The exception message and the `.debuggingRequestId()` will be set by the server.
159
+
-**`OnebusawaySdkServiceException`** - HTTP errors with a well-formed response body we were able to parse. The exception message and the `.debuggingRequestId()` will be set by the server.
-**`OnebusawaySdkInvalidDataException`** - any other exceptions on the client side, e.g.:
173
+
- We failed to serialize the request body
174
+
- We failed to parse the response body (has access to response code and body)
187
175
188
176
## Network options
189
177
190
178
### Retries
191
179
192
-
Requests that experience certain errors are automatically retried 2 times by default, with a short exponential backoff. Connection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict, 429 Rate Limit, and >=500 Internal errors will all be retried by default.
193
-
You can provide a `maxRetries` on the client builder to configure this:
180
+
Requests that experience certain errors are automatically retried 2 times by default, with a short exponential backoff. Connection errors (for example, due to a network connectivity problem), 408 Request Timeout, 409 Conflict, 429 Rate Limit, and >=500 Internal errors will all be retried by default. You can provide a `maxRetries` on the client builder to configure this:
194
181
195
182
```kotlin
196
183
importorg.onebusaway.client.OnebusawaySdkClient
@@ -222,21 +209,44 @@ val client: OnebusawaySdkClient = OnebusawaySdkOkHttpClient.builder()
222
209
Requests can be routed through a proxy. You can configure this on the client builder:
This library is typed for convenient access to the documented API. If you need to access undocumented params or response properties, the library can still be used.
226
+
227
+
### Undocumented request params
228
+
229
+
In [Example: creating a resource](#example-creating-a-resource) above, we used the `CurrentTimeRetrieveParams.builder()` to pass to the `retrieve` method of the `currentTime` service.
230
+
231
+
Sometimes, the API may support other properties that are not yet supported in the Kotlin SDK types. In that case, you can attach them using raw setters:
You can also use the `putAdditionalProperty` method on nested headers, query params, or body objects.
245
+
246
+
### Undocumented response properties
247
+
248
+
To access undocumented response properties, you can use `res._additionalProperties()` on a response object to get a map of untyped fields of type `Map<String, JsonValue>`. You can then access fields like `res._additionalProperties().get("secret_prop").asString()` or use other helpers defined on the `JsonValue` class to extract it to a desired type.
249
+
240
250
## Logging
241
251
242
252
We use the standard [OkHttp logging interceptor](https://github.com/square/okhttp/tree/master/okhttp-logging-interceptor).
This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) conventions, though certain backwards-incompatible changes may be released as minor versions:
259
269
260
-
1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals)_.
270
+
1. Changes to library internals which are technically public but not intended or documented for external use. _(Please open a GitHub issue to let us know if you are relying on such internals.)_
261
271
2. Changes that we do not expect to impact the vast majority of users in practice.
262
272
263
273
We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.
264
274
265
275
We are keen for your feedback; please open an [issue](https://www.github.com/OneBusAway/kotlin-sdk/issues) with questions, bugs, or suggestions.
0 commit comments