CorvoNfse.Resources.Credits (Corvo NFS-e v0.1.1)

Copy Markdown View Source

Credit balance, purchasable plans and the credit ledger.

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

Summary

Functions

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

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

Lazily iterates every credit transaction across pages.

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

Types

list_option()

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

Functions

balance(client)

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

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

history(client, opts \\ [])

@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(client, opts \\ [])

@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(client, opts \\ [])

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

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