# `ExFattureincloud.Client`
[🔗](https://github.com/elchemista/ex_fattureincloud/blob/v0.1.0/lib/ex_fattureincloud/client.ex#L1)

Immutable configuration for one integration/account.

Options to `new/1`:

  * `:token` — access token or zero-arity provider returning the current token,
    `{:ok, token}` or `{:error, %ExFattureincloud.Error{}}`. Omit for OAuth
    calls; authenticated requests then return an error.
  * `:base_url` — defaults to `https://api-v2.fattureincloud.it`.
  * `:user_agent` — defaults to `FattureInCloud/2.1.3/Go-SDK`, matching the
    official Go SDK's compatibility header. Override for your integration.
  * `:receive_timeout` — milliseconds, default 15,000.
  * `:max_retries` — additional attempts for GET/HEAD only, default 2.
  * `:retry_delay` — initial backoff in milliseconds, default 500, with jitter.
  * `:max_retry_delay` — maximum permitted wait, default 30,000 ms. A server
    `Retry-After` above this budget returns the error without retrying early.
  * `:req_options` — Req options, e.g. `connect_options`, `finch`, `plug` or
    a custom `adapter`. Redirects and Req's own retries are always disabled.

Token providers are evaluated once per outgoing attempt. Clients keep no global
credentials. Optional managed renewal is available through
`ExFattureincloud.OAuth.TokenManager`; applications supply its storage callbacks.
Inspection of the client excludes credentials and Req options.

# `t`

```elixir
@type t() :: %ExFattureincloud.Client{
  base_url: String.t(),
  max_retries: non_neg_integer(),
  max_retry_delay: non_neg_integer(),
  receive_timeout: pos_integer(),
  req_options: keyword(),
  retry_delay: non_neg_integer(),
  token: nil | String.t() | token_provider(),
  user_agent: String.t()
}
```

# `token_provider`

```elixir
@type token_provider() :: (-&gt; token_result())
```

A zero-arity provider evaluated before each outgoing HTTP attempt.

# `token_result`

```elixir
@type token_result() ::
  String.t() | {:ok, String.t()} | {:error, ExFattureincloud.Error.t()}
```

A token provider's result, including structured authorization failures.

# `new`

```elixir
@spec new(keyword()) :: t()
```

Creates and validates an immutable client configuration. Invalid options raise `ArgumentError`.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
