Pithub::Result(3pm) | User Contributed Perl Documentation | Pithub::Result(3pm) |
Pithub::Result - Github v3 result object
version 0.01040
Every method call which maps directly to a Github API call returns a Pithub::Result object. Once you got the result object, you can set attributes on them or call methods.
If you set this to true and use the "next" method to iterate over the result rows, it will call automatically "next_page" for you until you got all the results. Be careful using this feature, if there are 100 pages, this will make 100 API calls. By default it's off. Instead of setting it per Pithub::Result you can also set it directly on any of the Pithub API objects.
Examples:
my $r = Pithub::Repos->new; my $result = $r->list( user => 'rjbs' ); # This would just show the first 30 by default while ( my $row = $result->next ) { printf "%s: %s\n", $row->{name}, $row->{description}; } # Let's do the same thing using auto_pagination to fetch all $result = $r->list( user => 'rjbs' ); $result->auto_pagination(1); while ( my $row = $result->next ) { printf "%s: %s\n", $row->{name}, $row->{description}; } # Turn auto_pagination on for all L<Pithub::Result> objects my $p = Pithub::Repos->new( auto_pagination => 1 ); my $result = $p->list( user => 'rjbs' ); while ( my $row = $result->next ) { printf "%s: %s\n", $row->{name}, $row->{description}; }
The decoded JSON response. May be an arrayref or hashref, depending on the API call. For some calls there is no content at all.
The extracted value from the "Link" header for the first page. This can return undef.
The extracted value from the "Link" header for the last page. This can return undef.
The extracted value from the "Link" header for the next page. This can return undef.
The extracted value from the "Link" header for the previous page. This can return undef.
The HTTP::Response object.
This can set utf8 flag.
Returns the content of the API response as a string, it will probably be JSON.
Returns the HTTP::Request object used to make the API call.
Returns the HTTP code from the API call.
Returns whether the API call was successful.
Returns the count of the elements in "content". If the result is not an arrayref but a hashref, it will still return 1. Some calls return an empty hashref, for those calls it returns 0.
Return the first element from "content" if "content" is an arrayref. If it's a hashref, it returns just that.
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).
Get the Pithub::Result for a specific page. The parameter is not validated, if you hit a page that does not exist, the Github API will tell you so. If there is only one page, this method will return undef, no matter which page you ask for, even for page 1.
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).
Most of the results returned by the Github API calls are arrayrefs of hashrefs. The data structures can be retrieved directly by calling "content". Besides that it's possible to iterate over the results using this method.
Examples:
my $r = Pithub::Repos->new; my $result = $r->list( user => 'rjbs' ); while ( my $row = $result->next ) { printf "%s: %s\n", $row->{name}, $row->{description}; }
Get the Pithub::Result of the next page. Returns undef if there is no next page (there's only one page at all).
Examples:
my $followers = Pithub->new->users->followers; my $result = $followers->list( user => 'rjbs' ); do { if ( $result->success ) { while ( my $row = $result->next ) { printf "%s\n", $row->{login}; } } } while $result = $result->next_page;
The nature of the implementation requires you here to do a "do { ... } while ..." loop. If you're going to fetch all results of all pages, I suggest to use the "auto_pagination" feature, it's much more convenient.
Get the Pithub::Result of the previous page. Returns undef if there is no previous page (you're on the first page).
Examples:
my $followers = Pithub->new->users->followers; my $result = $followers->list( user => 'rjbs' )->last_page; # this makes two requests! do { if ( $result->success ) { while ( my $row = $result->next ) { printf "%s\n", $row->{login}; } } } while $result = $result->prev_page;
Returns the value of the "ETag" http header.
Returns the value of the "X-Ratelimit-Limit" http header.
Returns the value of the "X-Ratelimit-Remaining" http header.
Johannes Plunien <plu@cpan.org>
This software is copyright (c) 2011 by Johannes Plunien.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
2022-10-04 | perl v5.34.0 |