Rapyd.HTTP.Client (rapyd v1.0.0)

Copy Markdown View Source

Default HTTP transport for the Rapyd SDK.

Responsibilities:

  • Attaches Rapyd HMAC-SHA256 auth headers to every request
  • Encodes request bodies as JSON
  • Decodes and validates Rapyd response envelopes
  • Implements full-jitter exponential backoff on retryable failures
  • Enforces a configurable per-request timeout

This module implements the Rapyd.HTTP.Behaviour contract, making it trivially swappable for test doubles via Mox.

Summary

Functions

Execute a signed API request with automatic retry.

Functions

request(client, method, path, body \\ nil, opts \\ [])

@spec request(Rapyd.Client.t(), atom(), String.t(), map() | nil, keyword()) ::
  {:ok, term()} | {:error, Rapyd.Error.t()}

Execute a signed API request with automatic retry.

path must start with /, e.g. "/v1/payments". body is any JSON-serialisable term, or nil for requests without a body.

Returns {:ok, decoded_data} where decoded_data is the "data" field from the Rapyd response envelope, or {:error, %Rapyd.Error{}}.