Advanced concepts
BaseModel
All parameter and response objects inherit fromTelnyx::Internal::Type::BaseModel, which provides several conveniences, including:
-
All fields, including unknown ones, are accessible with
obj[:prop]syntax, and can be destructured withobj => {prop: prop}or pattern-matching syntax. - Structural equivalence for equality; if two API calls return the same values, comparing the responses with == will return true.
- Both instances and the classes themselves can be pretty-printed.
-
Helpers such as
#to_h,#deep_to_h,#to_json, and#to_yaml.
Making custom or undocumented requests
Undocumented properties
You can send undocumented parameters to any endpoint, and read undocumented response properties, like so: Note: theextra_ parameters of the same name overrides the documented parameters.
Undocumented request params
If you want to explicitly send an extra param, you can do so with theextra_query, extra_body, and extra_headers under the request_options: parameter when making a request, as seen in the examples above.
Undocumented endpoints
To make requests to undocumented endpoints while retaining the benefit of auth, retries, and so on, you can make requests usingclient.request, like so:
Concurrency & connection pooling
TheTelnyx::Client instances are threadsafe, but are only are fork-safe when there are no in-flight HTTP requests.
Each instance of Telnyx::Client has its own HTTP connection pool with a default size of 99. As such, we recommend instantiating the client once per application in most settings.
When all available connections from the pool are checked out, requests wait for a new connection to become available, with queue time counting towards the request timeout.
Unless otherwise specified, other classes in the SDK do not have locks protecting their underlying data structure.
Sorbet
This library provides comprehensive RBI definitions, and has no dependency on sorbet-runtime. You can provide typesafe request parameters like so:Enums
Since this library does not depend onsorbet-runtime, it cannot provide T::Enum instances. Instead, we provide “tagged symbols” instead, which is always a primitive at runtime:
Versioning
This package follows SemVer conventions. As the library is in initial development and has a major version of0, APIs may change at any time.
This package considers improvements to the (non-runtime) *.rbi and *.rbs type definitions to be non-breaking changes.