Dnsimple.Client (dnsimple v9.0.0)

View Source

HTTP client configuration and request helpers for the DNSimple API.

Build a struct with new_from_env/0 or %Dnsimple.Client{}, then pass it to functions in Dnsimple.* modules that perform API calls.

Summary

Types

Request body accepted by post/4, patch/4, and put/4.

t()

Functions

Issues a DELETE request to the given url.

Returns the representation of an empty body in a request.

Issues a GET request to the given url.

Initializes a new client from the application environment.

Issues a PATCH request to the given url.

Issues a POST request to the given url.

Issues a PUT request to the given url.

Prepends the correct API version to path.

Types

body()

@type body() ::
  nil
  | binary()
  | map()
  | {:form, [{atom(), any()}]}
  | {:file, binary()}
  | Keyword.t()

Request body accepted by post/4, patch/4, and put/4.

Includes nil for empty bodies (see empty_body/0) and map/0 for JSON payloads encoded via Poison.encode!/1.

headers()

@type headers() :: [{binary(), binary()}] | %{required(binary()) => binary()}

t()

@type t() :: %Dnsimple.Client{
  access_token: String.t(),
  base_url: String.t(),
  user_agent: String.t()
}

Functions

delete(client, url, options \\ [])

@spec delete(t(), binary(), Keyword.t()) ::
  {:ok | :error, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()}

Issues a DELETE request to the given url.

empty_body()

@spec empty_body() :: nil

Returns the representation of an empty body in a request.

Examples

iex> Dnsimple.Client.empty_body() nil

execute(client, method, url, body \\ "", all_options \\ [])

get(client, url, options \\ [])

@spec get(t(), binary(), Keyword.t()) ::
  {:ok | :error, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()}

Issues a GET request to the given url.

new_from_env()

@spec new_from_env() :: t()

Initializes a new client from the application environment.

Examples

client = Dnsimple.Client.new_from_env()

patch(client, url, body, options \\ [])

@spec patch(t(), binary(), body(), Keyword.t()) ::
  {:ok | :error, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()}

Issues a PATCH request to the given url.

post(client, url, body, options \\ [])

@spec post(t(), binary(), body(), Keyword.t()) ::
  {:ok | :error, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()}

Issues a POST request to the given url.

put(client, url, body, options \\ [])

@spec put(t(), binary(), body(), Keyword.t()) ::
  {:ok | :error, HTTPoison.Response.t() | HTTPoison.AsyncResponse.t()}

Issues a PUT request to the given url.

versioned(path)

@spec versioned(String.t()) :: String.t()

Prepends the correct API version to path.

Examples

iex> Dnsimple.Client.versioned "/whoami"
"/v2/whoami"