# `SefazNfe.DistDFe`
[🔗](https://github.com/devaction-labs/sefaz_nfe/blob/v0.5.0/lib/sefaz_nfe/dist_dfe.ex#L1)

Page returned by `NFeDistribuicaoDFe` (Ambiente Nacional).

The cursor belongs to the caller (AD-002): persist `ult_nsu` and pass it back,
or the same documents arrive forever. `max_nsu` says how far the AN has gone,
so `ult_nsu < max_nsu` means there is a backlog to drain.

# `t`

```elixir
@type t() :: %SefazNfe.DistDFe{
  c_stat: pos_integer(),
  documents: [SefazNfe.DistDFe.Document.t()],
  max_nsu: String.t(),
  ult_nsu: String.t(),
  x_motivo: String.t()
}
```

# `parse`

```elixir
@spec parse(String.t()) :: {:ok, t()} | {:error, term()}
```

Parses a `retDistDFeInt` response.

Every document arrives gzipped and base64 encoded. A payload that will not
decode is an error rather than a silently dropped document (SEFAZ-07): losing
an inbound NF-e without noticing is worse than failing the whole page, since
the cursor would move past it.

`cStat` 137 (no document found) is a normal empty page, and 656 (consumo
indevido) arrives as a page too, so the caller can back off on it.

---

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