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

Link to this section Types

Link to this section Functions

Link to this function

delete(api_key, path)

View Source
delete(String.t(), String.t()) :: {:ok, map()} | {:error, any()}
Link to this function

get(api_key, path)

View Source
get(String.t(), String.t()) :: {:ok, map()} | {:error, any()}
Link to this function

patch(api_key, params, path)

View Source
patch(String.t(), map(), String.t()) :: {:ok, map()} | {:error, any()}
Link to this function

post(api_key, params, path)

View Source
post(String.t(), map(), String.t()) :: {:ok, map()} | {:error, any()}

Link to this section Callbacks

Link to this callback

delete(url, headers)

View Source
delete(url(), headers()) :: {:ok, response()} | {:error, any()}
Link to this callback

get(url, headers)

View Source
get(url(), headers()) :: {:ok, response()} | {:error, any()}
Link to this callback

init()

View Source (optional)
init() :: :ok

Callback to initialize api client

Link to this callback

patch(url, headers, body)

View Source
patch(url(), headers(), body()) :: {:ok, response()} | {:error, any()}
Link to this callback

post(url, headers, body)

View Source
post(url(), headers(), body()) :: {:ok, response()} | {:error, any()}