Twilio.Page (twilio_elixir v0.1.1)

Copy Markdown View Source

Paginated result from a Twilio list endpoint.

Handles both pagination formats transparently:

  • Meta wrapper (v1/v2/v3): meta.next_page_url, meta.key
  • Flat format (v2010): next_page_uri at top level, no meta

Summary

Functions

Parse a raw API response into a Page struct.

Check if there are more pages.

Auto-page through all results as a lazy stream.

Types

t()

@type t() :: %Twilio.Page{
  first_page_url: String.t() | nil,
  items: [map()],
  key: String.t(),
  next_page_url: String.t() | nil,
  page: non_neg_integer() | nil,
  page_size: non_neg_integer() | nil,
  previous_page_url: String.t() | nil,
  url: String.t() | nil
}

Functions

from_response(data, key)

@spec from_response(map(), String.t()) :: t()

Parse a raw API response into a Page struct.

Auto-detects the pagination format:

  • If a "meta" key is present -> v1/v2/v3 meta wrapper format
  • Otherwise -> v2010 flat format (uses *_uri instead of *_url)

has_next?(page)

@spec has_next?(t()) :: boolean()

Check if there are more pages.

stream(fetch_fn, key)

@spec stream((map() -> {:ok, t()} | {:error, term()}), String.t()) :: Enumerable.t()

Auto-page through all results as a lazy stream.