Cursor-based pagination for Lithic list endpoints.
Fetching a single page
{:ok, page} = Lithic.Cards.list(page_size: 10)
page.data #=> [%{...}, ...]
page.has_more #=> true
page.next_cursor #=> "tok_..."Fetching the next page
{:ok, next_page} = Lithic.Page.next(page)Streaming all records lazily
Lithic.Cards.stream()
|> Stream.filter(&(&1["state"] == "OPEN"))
|> Enum.take(100)Collecting all records eagerly (use with care)
{:ok, all_cards} = Lithic.Page.collect_all(page)
Summary
Functions
Collect all items across all pages into a single list.
Wrap a raw decoded response body into a Page struct.
Fetch the next page. Returns {:ok, nil} when there are no more pages.
Lazily stream every item across all pages.
Types
@type t(item) :: %Lithic.Page{ client: Lithic.Client.t(), data: [item], has_more: boolean(), next_cursor: String.t() | nil, params: keyword(), path: String.t() }
Functions
@spec collect_all(t(map())) :: {:ok, [map()]} | {:error, Lithic.Error.t()}
Collect all items across all pages into a single list.
Wrap a raw decoded response body into a Page struct.
@spec next(t(map())) :: {:ok, t(map()) | nil} | {:error, Lithic.Error.t()}
Fetch the next page. Returns {:ok, nil} when there are no more pages.
@spec stream(t(map())) :: Enumerable.t()
Lazily stream every item across all pages.