1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237
|
package Net::GitHub::V3::Users;
use Moo;
our $VERSION = '1.05';
our $AUTHORITY = 'cpan:FAYLAND';
use URI::Escape;
with 'Net::GitHub::V3::Query';
sub show {
my ( $self, $user ) = @_;
my $u = $user ? "/users/" . uri_escape($user) : '/user';
return $self->query($u);
}
sub update {
my $self = shift;
my $data = @_ % 2 ? shift @_ : { @_ };
return $self->query('PATCH', '/user', $data);
}
sub add_email {
(shift)->query( 'POST', '/user/emails', [ @_ ] );
}
sub remove_email {
(shift)->query( 'DELETE', '/user/emails', [ @_ ] );
}
sub followers {
my ($self, $user) = @_;
my $u = $user ? "/users/" . uri_escape($user) . '/followers' : '/user/followers';
return $self->query($u);
}
sub next_follower {
my ($self, $user) = @_;
my $u = $user ? "/users/" . uri_escape($user) . '/followers' : '/user/followers';
return $self->next($u);
}
sub close_follower {
my ($self, $user) = @_;
my $u = $user ? "/users/" . uri_escape($user) . '/followers' : '/user/followers';
return $self->close($u);
}
sub following {
my ($self, $user) = @_;
my $u = $user ? "/users/" . uri_escape($user) . '/following' : '/user/following';
return $self->query($u);
}
sub next_following {
my ($self, $user) = @_;
my $u = $user ? "/users/" . uri_escape($user) . '/following' : '/user/following';
return $self->next($u);
}
sub close_following {
my ($self, $user) = @_;
my $u = $user ? "/users/" . uri_escape($user) . '/following' : '/user/following';
return $self->close($u);
}
## build methods on fly
my %__methods = (
emails => { url => "/user/emails", paginate => 1 },
is_following => { url => "/user/following/%s", check_status => 204 },
follow => { url => "/user/following/%s", method => 'PUT', check_status => 204 },
unfollow => { url => "/user/following/%s", method => 'DELETE', check_status => 204 },
keys => { url => "/user/keys", paginate => 1 },
key => { url => "/user/keys/%s" },
create_key => { url => "/user/keys", method => 'POST', args => 1 },
update_key => { url => "/user/keys/%s", method => 'PATCH', args => 1 },
delete_key => { url => "/user/keys/%s", method => 'DELETE', check_status => 204 },
);
__build_methods(__PACKAGE__, %__methods);
## DEPERCATED
sub contributions {
die "contributions_calender_data is no longer available";
}
no Moo;
1;
__END__
=head1 NAME
Net::GitHub::V3::Users - GitHub Users API
=head1 SYNOPSIS
use Net::GitHub::V3;
my $gh = Net::GitHub::V3->new; # read L<Net::GitHub::V3> to set right authentication info
my $user = $gh->user;
=head1 DESCRIPTION
=head2 METHODS
=head3 Users
L<http://developer.github.com/v3/users/>
=over 4
=item show
my $uinfo = $user->show(); # /user
my $uinfo = $user->show( 'nothingmuch' ); # /users/:user
=item update
$user->update(
bio => 'another Perl programmer and Father',
);
=back
=head3 Emails
L<http://developer.github.com/v3/users/emails/>
=over 4
=item emails
=item add_email
=item remove_email
$user->add_email( 'another@email.com' );
$user->add_email( 'batch1@email.com', 'batch2@email.com' );
my $emails = $user->emails;
while ($email = $user->next_email) { ...; }
$user->remove_email( 'another@email.com' );
$user->remove_email( 'batch1@email.com', 'batch2@email.com' );
=back
=head3 Followers
L<http://developer.github.com/v3/users/followers/>
=over 4
=item followers
=item following
=item next_follower
=item next_following
my $followers = $user->followers;
my $followers = $user->followers($user);
my $following = $user->following;
my $following = $user->following($user);
my $next_follower = $user->next_follower
my $next_follower = $user->next_follower($user)
my $next_following = $user->next_following
my $next_following = $user->next_following($user)
=item is_following
my $is_following = $user->is_following($user);
=item follow
=item unfollow
$user->follow( 'nothingmuch' );
$user->unfollow( 'nothingmuch' );
=back
=head3 Keys
L<http://developer.github.com/v3/users/keys/>
=over 4
=item keys
=item key
=item create_key
=item update_key
=item delete_key
my $keys = $user->keys;
while (my $key = $user->next_key) { ...; }
my $key = $user->key($key_id); # get key
$user->create_key({
title => 'title',
key => $key
});
$user->update_key($key_id, {
title => $title,
key => $key
});
$user->delete_key($key_id);
=item contributions
my $contributions = $user->contributions($username);
# $contributions = ( ..., ['2013/09/22', 3], [ '2013/09/23', 2 ] )
Unpublished GitHub API used to build the 'Public contributions' graph on a
users' profile page. The data structure is a list of 365 arrayrefs, one per day.
Each array has two elements, the date in YYYY/MM/DD format is the first element,
the second is the number of contrubtions for that day.stree .
=back
=head1 AUTHOR & COPYRIGHT & LICENSE
Refer L<Net::GitHub>
|