# `ExFattureincloud.Usage`
[🔗](https://github.com/elchemista/ex_fattureincloud/blob/v0.1.0/lib/ex_fattureincloud/usage.ex#L26)

Reads actual company plan limits instead of hardcoding commercial plans.

`documents/2` returns the annual document quota, consumption and remaining
capacity. This is the plan's document counter, not a dedicated SDI sending
counter. `plan/3` also supports clients, suppliers and products (global quotas).
`invoice_capacity/3` combines the document counter with company plan features,
license date and invoice permissions. It performs two GETs and never creates
or sends an invoice. `api/2` retrieves detailed API counters (one additional
request); ordinary responses already expose counters in `rate_limit` for free.

These are point-in-time checks: another user or app can consume the same quota
after a check. An unknown/null limit does not mean unlimited. Availability for
creating a document does not guarantee SDI acceptance or permission to send an
existing document. The provider remains authoritative for every write.

# `api`

```elixir
@spec api(ExFattureincloud.Client.t(), integer() | String.t()) ::
  ExFattureincloud.Response.result()
```

Retrieves hourly/monthly API usage, including custom limits and remaining counts. Consumes one request.

# `can_create_documents?`

```elixir
@spec can_create_documents?(
  ExFattureincloud.Client.t(),
  integer() | String.t(),
  pos_integer()
) ::
  {:ok, boolean() | :unknown} | {:error, ExFattureincloud.Error.t()}
```

Checks document quota for count new documents; returns :unknown when the counter is unavailable.

# `documents`

```elixir
@spec documents(ExFattureincloud.Client.t(), integer() | String.t()) ::
  {:ok, ExFattureincloud.Usage.Quota.t()} | {:error, ExFattureincloud.Error.t()}
```

Reads the annual document quota and computes remaining capacity.

# `invoice_capacity`

```elixir
@spec invoice_capacity(
  ExFattureincloud.Client.t(),
  integer() | String.t(),
  pos_integer()
) ::
  {:ok, map()} | {:error, ExFattureincloud.Error.t()}
```

Returns document quota, plan, license and invoice feature/permission checks (two API requests).

# `plan`

```elixir
@spec plan(ExFattureincloud.Client.t(), integer() | String.t(), atom() | String.t()) ::
  {:ok, ExFattureincloud.Usage.Quota.t()} | {:error, ExFattureincloud.Error.t()}
```

Reads a plan quota for :documents, :clients, :suppliers or :products.

---

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