RingCentral.HTTPClient behaviour (RingCentral v0.2.1) View Source
HTTPClient behaviour for RingCentral
Build your own HTTP client:
defmodule MyApp.AwesomeHTTPClient do
@behaviour RingCentral.HTTPClient
@impl true
def request(method, url, body, headers \ []) do
if success
{:ok,
%Response{
status: response.status,
headers: response.headers,
body: response.body,
data: nil
}}
else
{:error, error} ->
{:error,
%Error{
code: :server_error,
detail: error
}
}
end
end
end
Then Use the custom HTTP while building the client:
ringcentral =
RingCentral.build(
client_id: "my-client-id",
client_secret: "my-client-secret",
http_client: MyApp.AwesomeHTTPClient
)
See RingCentral.HTTPClient.DefaultClient
for a reference implementation.
Link to this section Summary
Link to this section Types
Specs
Specs
http_method() :: :delete | :get | :post | :put
Link to this section Callbacks
Specs
request( method :: http_method(), url :: String.t(), body :: String.t(), headers :: http_headers() ) :: {:ok, RingCentral.Response.t()} | {:error, RingCentral.Error.t()}