TruelayerClient.HTTP (truelayer_client v1.0.0)

Copy Markdown View Source

Instrumented HTTP client wrapping Req.

Handles:

  • JSON encoding/decoding
  • RFC 7807 problem+json error body parsing
  • Tl-Trace-Id and Tl-Should-Retry response header extraction
  • Telemetry events (:start, :stop, :exception)
  • TLS 1.2+ enforcement via transport options

Summary

Functions

Execute an application/x-www-form-urlencoded POST request.

Execute a JSON request.

Functions

build_client(config)

@spec build_client(TruelayerClient.Config.t()) :: Req.Request.t()

Build a Req.Request base client from a TruelayerClient.Config.

form_post(req, url, params)

@spec form_post(Req.Request.t(), String.t(), map()) ::
  {:ok, map()} | {:error, TruelayerClient.Error.t()}

Execute an application/x-www-form-urlencoded POST request.

Used exclusively for OAuth2 token-endpoint calls.

json_request(req, config, opts)

@spec json_request(Req.Request.t(), TruelayerClient.Config.t(), keyword()) ::
  {:ok, term()} | {:error, TruelayerClient.Error.t()}

Execute a JSON request.

Returns {:ok, decoded_body} for 2xx responses or {:error, %TruelayerClient.Error{}} for errors.