Triple.Client (triple v1.0.0)

Copy Markdown View Source

Low-level HTTP plumbing for the Triple API, built on Req.

Most callers won't need this directly — use the context modules (Triple.Enrich, Triple.Brands, Triple.Feedback, Triple.Stocks, Triple.Cryptos, Triple.TLS) or the top-level Triple delegates instead. It's exposed publicly for advanced use: inspecting/extending the underlying Req.Request, or calling an endpoint this library doesn't wrap yet.

Summary

Functions

Builds a %Req.Request{} pre-configured with auth headers, timeouts, and retry behaviour for the given config and host, without performing a request. Handy if you want to compose additional Req steps yourself.

Performs a request against the Triple API and normalizes the result.

Functions

build(config, host \\ :api)

@spec build(Triple.Config.t(), :api | :control) :: Req.Request.t()

Builds a %Req.Request{} pre-configured with auth headers, timeouts, and retry behaviour for the given config and host, without performing a request. Handy if you want to compose additional Req steps yourself.

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

@spec request(Triple.Config.t(), atom(), String.t(), keyword()) ::
  {:ok, Req.Response.t()} | {:error, Triple.Error.t()}

Performs a request against the Triple API and normalizes the result.

path is relative to the configured host (e.g. "/v1/brands/#{id}/"). opts are merged into the Req.request/2 call (:json, :params, etc), plus the library-specific :host option — :api (default) or :control, selecting between config.base_url and config.control_base_url.

Returns {:ok, %Req.Response{}} for any 2xx response, or {:error, %Triple.Error{}} for non-2xx responses and transport failures. Emits [:triple, :request, *] telemetry events around the call — see Triple.Telemetry.