Claudex.Page (Claudex v0.6.1)

Copy Markdown View Source

One page of results from a list endpoint.

data holds the items. The API has two cursor styles and this struct carries both, so the fields the endpoint doesn't use are nil:

  • Models and Message Batches use id cursors — go forward with after_id: page.last_id, back with before_id: page.first_id, and check has_more to know whether there is a next page.
  • Files uses an opaque cursor — pass page: page.next_page to get the next page, and stop when next_page is nil.

Summary

Types

t()

@type t() :: t(term())

t(item)

@type t(item) :: %Claudex.Page{
  data: [item],
  first_id: String.t() | nil,
  has_more: boolean() | nil,
  last_id: String.t() | nil,
  next_page: String.t() | nil
}