open_payments/request

Values

pub fn send_and_decode(
  client: client.Client,
  url: String,
  method: http.Method,
  body: option.Option(json.Json),
  token token: option.Option(String),
  decoder decoder: decode.Decoder(a),
  error_context error_context: String,
) -> Result(a, error.OpenPaymentsError)

Sends a signed request via send_request and decodes the JSON response body with decoder. A decode failure is wrapped as DecodeError with error_context <> ": " <> <the underlying decode error>, so callers get a message that both names the response and shows what went wrong parsing it.

pub fn send_request(
  client: client.Client,
  url: String,
  method: http.Method,
  body: option.Option(json.Json),
  token token: option.Option(String),
) -> Result(String, error.OpenPaymentsError)

Sends an HTTP message signed with client’s private key to url, and returns the response body. When body is given, a content-digest header is attached and covered by the signature; when token is given, it is sent as a GNAP authorization header and likewise signed.

pub fn send_unauthenticated_and_decode(
  url: String,
  decoder decoder: decode.Decoder(a),
  error_context error_context: String,
) -> Result(a, error.OpenPaymentsError)

Sends send_unauthenticated_request and decodes the JSON response body with decoder. A decode failure is wrapped as DecodeError with error_context <> ": " <> <the underlying decode error>.

pub fn send_unauthenticated_request(
  url: String,
) -> Result(String, error.OpenPaymentsError)

Sends an unsigned GET request to url and returns the response body. Used for endpoints that don’t require an access token or request signature, such as fetching wallet address details.

Search Document