NAME

Pithub::Result

VERSION

version 0.01000

ATTRIBUTES

content

The decoded JSON response. May be an arrayref or hashref, depending on the API call.

first_page_uri

The extracted value from the Link header for the first page. This can return undef.

last_page_uri

The extracted value from the Link header for the last page. This can return undef.

next_page_uri

The extracted value from the Link header for the next page. This can return undef.

prev_page_uri

The extracted value from the Link header for the previous page. This can return undef.

response

The Pithub::Response object. There are following delegate methods installed for convenience:

  • code: response->code

  • raw_content: response->content

  • request: response->request

  • success: response->success

METHODS

first_page

Get the Pithub::Result of the first page. Returns undef if there is no first page (if you're on the first page already or if there is no pages at all).

last_page

Get the Pithub::Result of the last page. Returns undef if there is no last page (if you're on the last page already or if there is only one page or no pages at all).

next_page

Get the Pithub::Result of the next page. Returns undef if there is no next page (there's only one page at all).

Examples:

  • List all followers in order, from the first one on the first page to the last one on the last page.

    $followers = Pithub->new->users->followers;
    $result = $followers->list( user => 'rjbs' );
    do {
        if ( $result->success ) {
            foreach my $row ( @{ $result->content } ) {
                printf "%s\n", $row->{login};
            }
        }
    } while $result = $result->next_page;

    The nature of the implementation requires you here to do a do { ... } while ... loop.

prev_page

Get the Pithub::Result of the previous page. Returns undef if there is no previous page (you're on the first page).

Examples:

  • List all followers in reverse order, from the last one on the last page to the first one on the first page.

    $followers = Pithub->new->users->followers;
    $result = $followers->list( user => 'rjbs' )->last_page;    # this makes two requests!
    do {
        if ( $result->success ) {
            foreach my $row ( reverse @{ $result->content } ) {
                printf "%s\n", $row->{login};
            }
        }
    } while $result = $result->prev_page;

ratelimit

Returns the value of the X-Ratelimit-Limit http header.

ratelimit_remaining

Returns the value of the X-Ratelimit-Remaining http header.