NAME

Twilio::Page - Base class for a page of results

SYNOPSIS

my $page = $client->messages->page({}, 50);

while (my $message = $page->next) {
  say $message->body;
}

my $next = $page->next_page;

DESCRIPTION

Reads a page of a list, in the two formats Twilio uses: next_page_uri in the 2010 API, and meta.next_page_url with the list named in meta.key in product APIs. Asking for a page past the end gives an empty page, not an error, and fields this class does not know about are ignored.

Each resource has a subclass that implements "build_instance".

METHODS

new

my $page = Twilio::Page->new($version, $response, \%solution);

Reads a Twilio::Http::Response. It throws Twilio::Exceptions::RestException on an error response, and Twilio::Exceptions::DeserializeException if the response has no recognisable list of records. %solution holds the path values that resources on this page need, such as the account SID.

build_instance

my $instance = $page->build_instance($payload);

Subclasses must implement this. It receives one record and returns its object.

records_key

Returns the name of the list of records in the response. Subclasses may implement this. Otherwise the name comes from meta.key, or is the only list in the response.

next

my $record = $page->next;

Returns the next record, or nothing at the end of this page.

rewind

$page->rewind;

Makes "next" start again from the first record of this page.

records

my @records = $page->records;

Returns all the records of this page.

next_page

previous_page

my $page = $page->next_page;

Fetch and return the next or previous page, or nothing if there is none.

get_next_page_url

get_previous_page_url

Return the URL of the next or previous page, or nothing if there is none.

instance_for

my $instance = $page->instance_for($record);

Returns the instance for one record of the list. It calls build_instance, and exists so that a subclass can prepare a record first.

has_meta

my $found = $page->has_meta('key');

Returns true if the meta object of the response has this key.

get_meta

my $value = $page->get_meta('key', $default);

Returns a value from the meta object of the response.

process_response

load_page

get_response

create_page

The steps of reading a page, which subclasses may override. "process_response" checks a response and returns its content, "load_page" returns the list of records, "get_response" fetches a URL, and "create_page" builds a page of the same class from a response.

get_version

Returns the Twilio::Version.

LICENSE

Copyright (c) 2026 Francisco Zarabozo. Released under the MIT License.