Stellar.Horizon.Request (Elixir Stellar SDK v0.5.0) View Source

A module for working with requests to the Horizon API.

Requests are composed in a functional manner. The request does not happen until it is configured and passed to perform/1.

Generally intended to be used internally, but can also be used by end-users to work around missing endpoints (if any).

At a minimum, a request must have the endpoint and method specified to be valid.

Link to this section Summary

Link to this section Types

Specs

body() :: Keyword.t()

Specs

encoded_query() :: String.t() | nil

Specs

endpoint() :: String.t() | nil

Specs

headers() :: [{binary(), binary()}, ...] | []

Specs

method() :: :get | :post

Specs

opts() :: Keyword.t()

Specs

params() :: Keyword.t()

Specs

parsed_response() :: {:ok, struct()} | {:error, Stellar.Horizon.Error.t()}

Specs

path() :: String.t() | nil

Specs

query() :: Keyword.t()

Specs

query_params() :: [atom()]

Specs

response() :: {:ok, map()} | {:error, Stellar.Horizon.Error.t()}

Specs

segment() :: String.t() | nil

Specs

t() :: %Stellar.Horizon.Request{
  body: body(),
  encoded_query: encoded_query(),
  endpoint: endpoint(),
  headers: headers(),
  method: method(),
  path: path(),
  query: query(),
  segment: segment(),
  segment_path: path()
}

Link to this section Functions

Specs

add_body(request :: t(), body :: body()) :: t()
Link to this function

add_headers(request, headers)

View Source

Specs

add_headers(request :: t(), headers :: headers()) :: t()
Link to this function

add_query(request, params \\ [], opts \\ [])

View Source

Specs

add_query(request :: t(), params :: params(), opts :: opts()) :: t()
Link to this function

new(method, endpoint, opts \\ [])

View Source

Specs

new(method :: method(), endpoint :: endpoint(), opts :: opts()) :: t()

Specs

perform(request :: t()) :: response()
Link to this function

results(error, resource)

View Source

Specs

results(response :: response(), resource :: function()) :: parsed_response()