Ramp.HTTP (ramp v1.0.0)

Copy Markdown View Source

The low-level HTTP transport shared by every resource module.

Built on Erlang/OTP's built-in :httpc (+ :ssl) so the package has zero required HTTP-client dependencies. Handles:

  • bearer token attachment (via Ramp.TokenManager)
  • JSON encoding/decoding (via Jason)
  • automatic retry with exponential backoff + full jitter on network errors and retryable 429/5xx responses (honoring Retry-After)
  • automatic one-time token refresh + retry on 401
  • Idempotency-Key header propagation
  • x-trace-id propagation into errors, for support escalations
  • :telemetry events around every attempt

You won't normally call this module directly -- use the resource modules (Ramp.Cards, Ramp.Users, etc.) instead. It's public because it's useful for writing your own thin wrappers around undocumented or brand new Ramp endpoints this SDK doesn't have a typed module for yet:

Ramp.HTTP.request(client, :get, "/developer/v1/some-new-endpoint")

Summary

Functions

Performs an HTTP request against the Ramp API and returns the decoded JSON body.

Types

method()

@type method() :: :get | :post | :patch | :put | :delete

request_opt()

@type request_opt() ::
  {:query, keyword() | map()}
  | {:json, map() | list() | nil}
  | {:idempotency_key, String.t() | nil}

Functions

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

@spec request(Ramp.Client.t(), method(), String.t(), [request_opt()]) ::
  {:ok, term()} | {:error, Ramp.Error.t()}

Performs an HTTP request against the Ramp API and returns the decoded JSON body.

Options

  • :query - query parameters (keyword list or map); nil values are dropped
  • :json - request body to JSON-encode; omit/nil for no body
  • :idempotency_key - sent as the Idempotency-Key header when present

Returns {:ok, decoded_body_or_nil} on any 2xx response (nil for 204/empty bodies), or {:error, %Ramp.Error{}} otherwise.