# `CorvoNfse.Resources.Credits`
[🔗](https://github.com/corvo-technology/corvo-nfse-elixir/blob/main/lib/corvo_nfse/resources/credits.ex#L1)

Credit balance, purchasable plans and the credit ledger.

    CorvoNfse.Resources.Credits.balance(client)
    CorvoNfse.Resources.Credits.history(client, limit: 50)

# `list_option`

```elixir
@type list_option() :: {:limit, pos_integer()} | {:cursor, String.t()}
```

# `balance`

```elixir
@spec balance(CorvoNfse.Client.t()) :: {:ok, map()} | {:error, CorvoNfse.Error.t()}
```

Reads the credit balance (`GET /v1/credits`).

# `history`

```elixir
@spec history(CorvoNfse.Client.t(), [list_option()]) ::
  {:ok, CorvoNfse.Types.Common.page()} | {:error, CorvoNfse.Error.t()}
```

Lists credit transactions (`GET /v1/credits/history`).

# `iterate_history`

```elixir
@spec iterate_history(CorvoNfse.Client.t(), [list_option()]) ::
  {:ok, Enumerable.t()} | {:error, CorvoNfse.Error.t()}
```

Lazily iterates every credit transaction across pages.

The first page is fetched eagerly: `{:error, error}` means it failed and
nothing was produced; `{:ok, stream}` yields transactions one by one. A
failure in a later page raises the `%CorvoNfse.Error{}` while consuming the
stream.

# `plans`

```elixir
@spec plans(CorvoNfse.Client.t(), [list_option()]) ::
  {:ok, CorvoNfse.Types.Common.page()} | {:error, CorvoNfse.Error.t()}
```

Lists credit plans (`GET /v1/credits/plans`).

---

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