Skip to main content

Logging

The SDK uses the standard OkHttp logging interceptor. Enable logging by setting the TELNYX_LOG environment variable to info:
Or to debug for more verbose logging:

ProGuard and R8

Although the SDK uses reflection, it is still usable with ProGuard and R8 because telnyx-java-core is published with a configuration file containing keep rules. ProGuard and R8 should automatically detect and use the published rules, but you can also manually copy the keep rules if necessary.

Jackson

The SDK depends on Jackson for JSON serialization/deserialization. It is compatible with version 2.13.4 or higher, but depends on version 2.18.2 by default. 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). If the SDK threw an exception, but you’re certain the version is compatible, then disable the version check using the checkJacksonVersionCompatibility on TelnyxOkHttpClient or TelnyxOkHttpClientAsync.
[!CAUTION] We make no guarantee that the SDK works correctly when the Jackson version check is disabled.

Undocumented API functionality

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.

Parameters

To set undocumented parameters, call the putAdditionalHeader, putAdditionalQueryParam, or putAdditionalBodyProperty methods on any Params class:
These can be accessed on the built object later using the _additionalHeaders(), _additionalQueryParams(), and _additionalBodyProperties() methods. To set undocumented parameters on nested headers, query params, or body classes, call the putAdditionalProperty method on the nested class:
These properties can be accessed on the nested built object later using the _additionalProperties() method. To set a documented parameter or property to an undocumented or not yet supported value, pass a JsonValue object to its setter:
The most straightforward way to create a JsonValue is using its from(...) method:
Normally a Builder class’s build method will throw IllegalStateException if any required parameter or property is unset. To forcibly omit a required parameter or property, pass JsonMissing:

Response properties

To access undocumented response properties, call the _additionalProperties() method:
To access a property’s raw JSON value, which may be undocumented, call its _ prefixed method:

Response validation

In rare cases, the API may return a response that doesn’t match the expected type. For example, the SDK may expect a property to contain a String, but the API could return something else. By default, the SDK will not throw an exception in this case. It will throw TelnyxInvalidDataException only if you directly access the property. If you would prefer to check that the response is completely well-typed upfront, then either call validate():
Or configure the method call to validate the response using the responseValidation method:
Or configure the default for all method calls at the client level:

FAQ

Why don’t you use plain enum classes?

Java enum classes are not trivially forwards compatible. Using them in the SDK could cause runtime exceptions if the API is updated to respond with a new enum value.

Why do you represent fields using JsonField<T> instead of just plain T?

Using JsonField<T> enables a few features:

Why don’t you use data classes?

It is not backwards compatible to add new fields to a data class and we don’t want to introduce a breaking change every time we add a field to a class.

Why don’t you use checked exceptions?

Checked exceptions are widely considered a mistake in the Java programming language. In fact, they were omitted from Kotlin for this reason. Checked exceptions:
  • Are verbose to handle
  • Encourage error handling at the wrong level of abstraction, where nothing can be done about the error
  • Are tedious to propagate due to the function coloring problem
  • Don’t play well with lambdas (also due to the function coloring problem)

Semantic versioning

This package generally follows SemVer conventions, though certain backwards-incompatible changes may be released as minor versions:
  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.)
  2. Changes that we do not expect to impact the vast majority of users in practice.
We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience. We are keen for your feedback; please open an issue with questions, bugs, or suggestions.