View Source Kadena.Chainweb.Request (Kadena v0.19.1)

A module to work with Chainweb requests. Requests are composed in a functional manner. The request does not happen until it is configured and passed to perform/1.

Link to this section Summary

Link to this section Types

@type api_type() :: :pact | :p2p
@type body() :: String.t() | nil
@type chain_id() :: 0..19 | String.t() | nil
@type encoded_query() :: String.t() | nil
@type endpoint() :: String.t() | nil
@type headers() :: [{binary(), binary()}]
@type location() :: String.t() | nil
@type method() :: :get | :post | :put
@type network_id() :: :testnet04 | :mainnet01
@type opts() :: Keyword.t()
@type params() :: Keyword.t()
@type parsed_response() :: {:ok, struct()} | {:error, Kadena.Chainweb.Error.t()}
@type path() :: String.t() | nil
@type query() :: Keyword.t()
@type response() :: {:ok, map()} | {:error, Kadena.Chainweb.Error.t()}
@type segment() :: String.t() | nil
@type t() :: %Kadena.Chainweb.Request{
  api_type: api_type(),
  body: body(),
  chain_id: chain_id(),
  encoded_query: encoded_query(),
  endpoint: endpoint(),
  headers: headers(),
  location: location(),
  method: method(),
  network_id: network_id(),
  path: path(),
  query: query(),
  segment: segment(),
  segment_path: path()
}

Link to this section 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)

View Source
@spec add_query(request :: t(), params :: params()) :: t()
@spec new(method :: method(), opts :: opts()) :: t()
@spec perform(request :: t()) :: response()
@spec results(response :: response(), opts :: opts()) :: parsed_response()
Link to this function

set_chain_id(request, chain_id)

View Source
@spec set_chain_id(t(), chain_id :: chain_id()) :: t()
Link to this function

set_location(request, location)

View Source
@spec set_location(t(), location :: location()) :: t()
Link to this function

set_network(request, network)

View Source
@spec set_network(t(), network :: network_id()) :: t()