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
// Note: you can also call fromEnv() from the client builder, for example if you need to set additional properties
@@ -77,8 +80,7 @@ Read the documentation for more configuration options.
77
80
78
81
### Example: creating a resource
79
82
80
-
To create a new current time, first use the `CurrentTimeRetrieveParams` builder to specify attributes,
81
-
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.
To make a request to the Onebusaway SDK API, you generally build an instance of the appropriate `Params` class.
98
100
99
-
In [Example: creating a resource](#example-creating-a-resource) above, we used the `CurrentTimeRetrieveParams.builder()` to pass to
100
-
the `retrieve` method of the `currentTime` service.
101
+
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.
101
102
102
-
Sometimes, the API may support other properties that are not yet supported in the Java SDK types. In that case,
103
-
you can attach them using the `putAdditionalProperty` method.
103
+
Sometimes, the API may support other properties that are not yet supported in the Java SDK types. In that case, you can attach them using the `putAdditionalProperty` method.
When receiving a response, the Onebusaway SDK Java SDK will deserialize it into instances of the typed model classes. In rare cases, the API may return a response property that doesn't match the expected Java type. If you directly access the mistaken property, the SDK will throw an unchecked `OnebusawaySdkInvalidDataException` at runtime. If you would prefer to check in advance that that response is completely well-typed, call `.validate()` on the returned model.
In rare cases, you may want to access the underlying JSON value for a response property rather than using the typed version provided by
126
-
this SDK. Each model property has a corresponding JSON version, with an underscore before the method name, which returns a `JsonField` value.
129
+
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.
127
130
128
131
```java
132
+
importjava.util.Optional;
133
+
importorg.onebusaway.core.JsonField;
134
+
129
135
JsonField field = responseObj._field();
130
136
131
137
if (field.isMissing()) {
@@ -147,6 +153,8 @@ if (field.isMissing()) {
147
153
Sometimes, the server response may include additional properties that are not yet available in this library's types. You can access them using the model's `_additionalProperties` method:
@@ -160,31 +168,33 @@ This library throws exceptions in a single hierarchy for easy handling:
160
168
161
169
-**`OnebusawaySdkException`** - Base exception for all exceptions
162
170
163
-
-**`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.
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.
-**`OnebusawaySdkInvalidDataException`** - any other exceptions on the client side, e.g.:
185
+
- We failed to serialize the request body
186
+
- We failed to parse the response body (has access to response code and body)
179
187
180
188
## Network options
181
189
182
190
### Retries
183
191
184
-
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.
185
-
You can provide a `maxRetries` on the client builder to configure this:
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. You can provide a `maxRetries` on the client builder to configure this:
This library is typed for convenient access to the documented API. If you need to access undocumented
222
-
params or response properties, the library can still be used.
237
+
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.
223
238
224
239
### Undocumented request params
225
240
226
-
To make requests using undocumented parameters, you can provide or override parameters on the params object
227
-
while building it.
241
+
To make requests using undocumented parameters, you can provide or override parameters on the params object while building it.
To access undocumented response properties, you can use `res._additionalProperties()` on a response object to
239
-
get a map of untyped fields of type `Map<String, JsonValue>`. You can then access fields like
240
-
`._additionalProperties().get("secret_prop").asString()` or use other helpers defined on the `JsonValue` class
241
-
to extract it to a desired type.
252
+
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 `._additionalProperties().get("secret_prop").asString()` or use other helpers defined on the `JsonValue` class to extract it to a desired type.
0 commit comments