Synctera.HTTP (Synctera v1.0.0)

Copy Markdown View Source

Low-level request executor built on Erlang/OTP's built-in :httpc (part of :inets) — no third-party HTTP client dependency required. Handles auth, idempotency key resolution, device-info headers, retries with backoff, and error mapping.

Summary

Functions

Executes a single API call. path is the request path (e.g. "/persons"). Returns {:ok, decoded_json} or {:error, %Synctera.Error{}} (or {:error, {:connection_error, reason}} for transport-level failures after retries are exhausted).

Types

method()

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

request_opts()

@type request_opts() :: [
  query: [{String.t(), term()}],
  body: term(),
  idempotency_tier: Synctera.Idempotency.tier(),
  idempotency_key: String.t() | nil,
  device_info: Synctera.DeviceInfo.t() | nil
]

Functions

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

@spec request(Synctera.Client.t(), method(), String.t(), request_opts()) ::
  {:ok, Synctera.JSON.json()}
  | {:error, Synctera.Error.t() | {:connection_error, term()}}

Executes a single API call. path is the request path (e.g. "/persons"). Returns {:ok, decoded_json} or {:error, %Synctera.Error{}} (or {:error, {:connection_error, reason}} for transport-level failures after retries are exhausted).