Requests and responses
To send a request to the Telnyx API, build an instance of someParams class and pass it to the corresponding client method. When the response is received, it will be deserialized into an instance of a Java class.
For example, client.calls().dial(...) should be called with an instance of CallDialParams, and it will return an instance of CallDialResponse.
Immutability
Each class in the SDK has an associated builder or factory method for constructing it. Each class is immutable once constructed. If the class has an associated builder, then it has atoBuilder() method, which can be used to convert it back to a builder for making a modified copy.
Because each class is immutable, builder modification will never affect already built class instances.
File uploads
The SDK defines methods that accept files. To upload a file, pass aPath:
InputStream:
byte[] array:
Path its filename is unknown so it will not be included in the request. To manually set a filename, pass a MultipartField:
Binary responses
The SDK defines methods that return binary responses, which are used for API responses that shouldn’t necessarily be parsed, like non-JSON data. These methods returnHttpResponse:
Files.copy(...) method:
OutputStream:
Raw responses
The SDK defines methods that deserialize responses into instances of Java classes. However, these methods don’t provide access to the response headers, status code, or the raw response body. To access this data, prefix any HTTP method call on a client or service withwithRawResponse():
Pagination
The SDK defines methods that return a paginated lists of results. It provides convenient ways to access the results either one page at a time or item-by-item across all pages.Auto-pagination
To iterate through all results across all pages, use theautoPager() method, which automatically fetches more pages as needed.
When using the synchronous client, the method returns an Iterable
AsyncStreamResponse:
Manual pagination
To access individual page items and manually request the next page, use theitems(),
hasNextPage(), and nextPage() methods: