telnyx v0.3.0 Telnyx.Client behaviour View Source
Uses Mojito by default, but can be swapped out for any HTTP client you'd like.
To use a different HTTP client, create a new module like MyApp.TelnyxClient
which implements get/2
, post/3
, patch/3
, and delete/2
and uses the @behaviour Telnyx.Client
behaviour.
For a reference on how simple the file can be, see the Telnyx.Client.Mojito module.
The success response of those functions must return a :body
key, with a JSON value, and a :status_code
key with an integer HTTP status.
Then, you'll need to add the following to config.exs
:
config :telnyx, client: MyApp.TelnyxClient
Depending on your HTTP client, you may need to do some work to translate headers or other parts into something your client expects. For example, the post/3 callback has an order of (url, headers, body), but HTTPoison needs them in the order (url, body, headers).
Link to this section Summary
Callbacks
Callback to initialize api client
Link to this section Types
Link to this section Functions
Link to this section Callbacks
Callback to initialize api client