SudregEx.Request (sudreg_ex v0.1.0)

Copy Markdown View Source

The generic GET pipeline every endpoint wrapper calls.

Handles bearer authentication, base_url + path joining, query-param encoding (booleans → "1"/"0", nil values dropped), the response-format request header, and normalisation of the result into {:ok, %SudregEx.Response{}} | {:error, %SudregEx.Error{}}.

Per-endpoint parameter validation is layered on top in the endpoint wrappers; this module passes whatever :params it is given straight through.

Summary

Functions

Performs a GET against path (joined onto client.base_url).

Functions

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

@spec request(SudregEx.Client.t(), String.t(), keyword()) ::
  {:ok, SudregEx.Response.t()} | {:error, SudregEx.Error.t()}

Performs a GET against path (joined onto client.base_url).

Options:

  • :params — keyword list (preferred; stable order) or map of query params. true/false become "1"/"0"; nil values are dropped.
  • :format:json (default) or :xml; selects the response-format request header.
  • :token — a bearer token string to use directly, bypassing the cache.
  • :token_cache — the SudregEx.TokenCache server to fetch from (default SudregEx.TokenCache) when :token is not given.

Auto-retry is disabled by default (retry: false) so failures surface promptly with predictable latency rather than Req's default exponential backoff — important for the rate-limited endpoints (throttling is handled separately). Re-enable it per client via req_options: [retry: :safe_transient].