NAME

Finance::Robinhood::Utils::Paginated - Represent paginated data in an iterative object

SYNOPSIS

use Finance::Robinhood;

my $rh = Finance::Robinhood->new();

my $instruments = $rh->instruments();

while(my $instrument = $instruments->next()) {
    # Do something fun here
}

METHODS

Some data returned by Robinhood's API is so exhaustive that it is broken up into pages.

This class wraps that data in a friendly way.

next( )

while (my $record = $paginator->next()) { ... }

Returns the next record in the current page. If all records have been exhausted then the next page will automatically be loaded. This way if you want to ignore pagination you can just call next( ) over and over again to walk through all the records.

When we're out of pages and items, an undefined value is returned.

next_page( )

while (my $records = $paginator->next_page()) { ... }

Returns an array ref of records for the next page.

all

my $records = $paginator->all();

This is rolls through every page building one giant array ref of all records.