ExFattureincloud.Pagination (ExFattureincloud v0.1.0)

Copy Markdown View Source

Lazy pagination for list operations with page/per_page parameters.

stream/3 emits {:ok, item} tuples. On failure it emits one {:error, error} and halts, so partial results cannot look like a successful complete collection. stream!/3 emits items directly and raises on an error. No page is fetched until consumption. Enum.take/2 stops requests as soon as enough items are available.

Pagination.stream!(client, :list_clients,
  path: [company_id: 123], query: [per_page: 100])
|> Enum.take(10)

Summary

Functions

Lazily emits tagged results and halts after the first error.

Lazily emits items and raises ExFattureincloud.Error when a page fails.

Functions

stream(client, operation, options \\ [])

Lazily emits tagged results and halts after the first error.

Accepts the same path and query options as ExFattureincloud.API.call/3. The initial page defaults to 1. Raises ArgumentError if the operation does not support pagination or the initial page is invalid.

stream!(client, operation, options \\ [])

Lazily emits items and raises ExFattureincloud.Error when a page fails.