.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" ======================================================================== .\" .IX Title "Pithub::Result 3pm" .TH Pithub::Result 3pm "2018-03-17" "perl v5.26.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Pithub::Result \- Github v3 result object .SH "VERSION" .IX Header "VERSION" version 0.01034 .SH "DESCRIPTION" .IX Header "DESCRIPTION" Every method call which maps directly to a Github \s-1API\s0 call returns a Pithub::Result object. Once you got the result object, you can set attributes on them or call methods. .SH "ATTRIBUTES" .IX Header "ATTRIBUTES" .SS "auto_pagination" .IX Subsection "auto_pagination" If you set this to true and use the \*(L"next\*(R" method to iterate over the result rows, it will call automatically \*(L"next_page\*(R" for you until you got all the results. Be careful using this feature, if there are 100 pages, this will make 100 \s-1API\s0 calls. By default it's off. Instead of setting it per Pithub::Result you can also set it directly on any of the Pithub \s-1API\s0 objects. .PP Examples: .PP .Vb 2 \& my $r = Pithub::Repos\->new; \& my $result = $r\->list( user => \*(Aqrjbs\*(Aq ); \& \& # This would just show the first 30 by default \& while ( my $row = $result\->next ) { \& printf "%s: %s\en", $row\->{name}, $row\->{description}; \& } \& \& # Let\*(Aqs do the same thing using auto_pagination to fetch all \& $result = $r\->list( user => \*(Aqrjbs\*(Aq ); \& $result\->auto_pagination(1); \& while ( my $row = $result\->next ) { \& printf "%s: %s\en", $row\->{name}, $row\->{description}; \& } \& \& # Turn auto_pagination on for all L objects \& my $p = Pithub::Repos\->new( auto_pagination => 1 ); \& my $result = $p\->list( user => \*(Aqrjbs\*(Aq ); \& while ( my $row = $result\->next ) { \& printf "%s: %s\en", $row\->{name}, $row\->{description}; \& } .Ve .SS "content" .IX Subsection "content" The decoded \s-1JSON\s0 response. May be an arrayref or hashref, depending on the \s-1API\s0 call. For some calls there is no content at all. .SS "first_page_uri" .IX Subsection "first_page_uri" The extracted value from the \f(CW\*(C`Link\*(C'\fR header for the first page. This can return undef. .SS "last_page_uri" .IX Subsection "last_page_uri" The extracted value from the \f(CW\*(C`Link\*(C'\fR header for the last page. This can return undef. .SS "next_page_uri" .IX Subsection "next_page_uri" The extracted value from the \f(CW\*(C`Link\*(C'\fR header for the next page. This can return undef. .SS "prev_page_uri" .IX Subsection "prev_page_uri" The extracted value from the \f(CW\*(C`Link\*(C'\fR header for the previous page. This can return undef. .SS "response" .IX Subsection "response" The HTTP::Response object. .SS "utf8" .IX Subsection "utf8" This can set utf8 flag. .SH "METHODS" .IX Header "METHODS" .SS "raw_content" .IX Subsection "raw_content" Returns the content of the \s-1API\s0 response as a string, it will probably be \s-1JSON.\s0 .SS "request" .IX Subsection "request" Returns the HTTP::Request object used to make the \s-1API\s0 call. .SS "code" .IX Subsection "code" Returns the \s-1HTTP\s0 code from the \s-1API\s0 call. .SS "success" .IX Subsection "success" Returns whether the \s-1API\s0 call was successful. .SS "count" .IX Subsection "count" Returns the count of the elements in \*(L"content\*(R". If the result is not an arrayref but a hashref, it will still return \f(CW1\fR. Some calls return an empty hashref, for those calls it returns \f(CW0\fR. .SS "first" .IX Subsection "first" Return the first element from \*(L"content\*(R" if \*(L"content\*(R" is an arrayref. If it's a hashref, it returns just that. .SS "first_page" .IX Subsection "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). .SS "get_page" .IX Subsection "get_page" Get the Pithub::Result for a specific page. The parameter is not validated, if you hit a page that does not exist, the Github \s-1API\s0 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. .SS "last_page" .IX Subsection "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). .SS "next" .IX Subsection "next" Most of the results returned by the Github \s-1API\s0 calls are arrayrefs of hashrefs. The data structures can be retrieved directly by calling \*(L"content\*(R". Besides that it's possible to iterate over the results using this method. .PP Examples: .PP .Vb 2 \& my $r = Pithub::Repos\->new; \& my $result = $r\->list( user => \*(Aqrjbs\*(Aq ); \& \& while ( my $row = $result\->next ) { \& printf "%s: %s\en", $row\->{name}, $row\->{description}; \& } .Ve .SS "next_page" .IX Subsection "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). .PP Examples: .IP "\(bu" 4 List all followers in order, from the first one on the first page to the last one on the last page. See also \&\*(L"auto_pagination\*(R". .Sp .Vb 9 \& my $followers = Pithub\->new\->users\->followers; \& my $result = $followers\->list( user => \*(Aqrjbs\*(Aq ); \& do { \& if ( $result\->success ) { \& while ( my $row = $result\->next ) { \& printf "%s\en", $row\->{login}; \& } \& } \& } while $result = $result\->next_page; .Ve .Sp The nature of the implementation requires you here to do a \&\f(CW\*(C`do { ... } while ...\*(C'\fR loop. If you're going to fetch all results of all pages, I suggest to use the \&\*(L"auto_pagination\*(R" feature, it's much more convenient. .SS "prev_page" .IX Subsection "prev_page" Get the Pithub::Result of the previous page. Returns undef if there is no previous page (you're on the first page). .PP Examples: .IP "\(bu" 4 List all followers in reverse order, from the last one on the last page to the first one on the first page. See also \&\*(L"auto_pagination\*(R". .Sp .Vb 9 \& my $followers = Pithub\->new\->users\->followers; \& my $result = $followers\->list( user => \*(Aqrjbs\*(Aq )\->last_page; # this makes two requests! \& do { \& if ( $result\->success ) { \& while ( my $row = $result\->next ) { \& printf "%s\en", $row\->{login}; \& } \& } \& } while $result = $result\->prev_page; .Ve .SS "etag" .IX Subsection "etag" Returns the value of the \f(CW\*(C`ETag\*(C'\fR http header. .SS "ratelimit" .IX Subsection "ratelimit" Returns the value of the \f(CW\*(C`X\-Ratelimit\-Limit\*(C'\fR http header. .SS "ratelimit_remaining" .IX Subsection "ratelimit_remaining" Returns the value of the \f(CW\*(C`X\-Ratelimit\-Remaining\*(C'\fR http header. .SH "AUTHOR" .IX Header "AUTHOR" Johannes Plunien .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is copyright (c) 2011 by Johannes Plunien. .PP This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.