Core HTTP client for all Xero API requests.
Handles:
- Authenticated requests with Bearer token injection
- Automatic token refresh on 401 responses
- Rate limit header tracking and
Retry-Afterrespect - Telemetry emission for every request
- JSON encode/decode (transparent)
- Request ID injection (
x-correlation-id) If-Modified-Sinceheader injection for incremental sync- Multi-part form posting for OAuth token endpoints
Summary
Types
Raw {:ok, adapter_response} | {:error, term()} as returned by the underlying Req call.
Normalised HTTP response shape used internally, regardless of adapter (Req/Finch).
Functions
Authenticated DELETE request.
Authenticated GET request.
Authenticated POST request with JSON body.
Form-encoded POST for OAuth token endpoints (no auth token required).
Authenticated PUT request with JSON body.
Types
@type method() :: :get | :post | :put | :delete
Raw {:ok, adapter_response} | {:error, term()} as returned by the underlying Req call.
@type response() :: %{ status: pos_integer(), body: term(), headers: [{String.t(), String.t()}] }
Normalised HTTP response shape used internally, regardless of adapter (Req/Finch).
@type result() :: {:ok, response()} | {:error, Xero.Error.t()}
Functions
@spec delete(String.t(), Xero.Auth.Token.t(), list(), opts()) :: result()
Authenticated DELETE request.
@spec get(String.t(), Xero.Auth.Token.t(), list(), opts()) :: result()
Authenticated GET request.
Authenticated POST request with JSON body.
Form-encoded POST for OAuth token endpoints (no auth token required).
Authenticated PUT request with JSON body.