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

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.

Summary

Types

@type body() :: Keyword.t()
@type encoded_query() :: String.t() | nil
@type endpoint() :: String.t() | nil
@type headers() :: [{binary(), binary()}, ...] | []
@type method() :: :get | :post
@type opts() :: Keyword.t()
@type params() :: Keyword.t()
@type parsed_response() :: {:ok, struct()} | {:error, struct()}
@type path() :: String.t() | nil
@type query() :: Keyword.t()
@type query_params() :: [atom()]
@type response() :: {:ok, map()} | {:error, struct()}
@type segment() :: String.t() | nil
@type server() :: Stellar.Horizon.Server.t()
@type 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(),
  server: term()
}

Functions

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

add_headers(request, headers)

View Source
@spec add_headers(request :: t(), headers :: headers()) :: t()
Link to this function

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

View Source
@spec add_query(request :: t(), params :: params(), opts :: opts()) :: t()
Link to this function

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

View Source
@spec new(
  server :: server(),
  method :: method(),
  endpoint :: endpoint(),
  opts :: opts()
) :: t()
@spec perform(request :: t()) :: response()
@spec results(response :: response(), resource :: Keyword.t()) :: parsed_response()