OpenPayments.Types.PageInfo (open_payments_elixir v1.0.0)

Copy Markdown View Source

Pagination metadata shared by incoming- and outgoing-payment lists.

Follows the pinned page-info schema: required boolean has_next_page and has_previous_page, plus optional nonempty string start_cursor and end_cursor. No additional fields are permitted. Missing cursors become nil and are omitted on export; explicit JSON null and empty strings are invalid. Page flags are never defaulted.

Cursors are opaque UTF-8 strings whose spelling is preserved. This codec does not require UUIDs, URLs, a particular encoding, both cursors together or a relationship between cursors and page flags. It does not fetch pages, validate pagination request arguments, infer ordering or compare cursors with results.

Inspection exposes only the page flags. Explicit map/JSON exports include cursors. Errors contain safe field paths without rejected values. Validate modified structs with validate/1; to_map/1 converts without validating.

Summary

Functions

Decodes strict pagination metadata without supplying missing flags or cursors.

Converts to protocol fields, including cursors, without validating.

Revalidates flags and cursors, treating nil optional cursors as omitted.

Types

t()

@type t() :: %OpenPayments.Types.PageInfo{
  end_cursor: String.t() | nil,
  has_next_page: boolean(),
  has_previous_page: boolean(),
  start_cursor: String.t() | nil
}

Functions

from_map(data)

@spec from_map(map()) :: {:ok, t()} | {:error, OpenPayments.Error.t()}

Decodes strict pagination metadata without supplying missing flags or cursors.

to_map(page)

@spec to_map(t()) :: map()

Converts to protocol fields, including cursors, without validating.

validate(page)

@spec validate(t()) :: :ok | {:error, OpenPayments.Error.t()}

Revalidates flags and cursors, treating nil optional cursors as omitted.