File Coverage

blib/lib/Net/GitHub/V3/Users.pm
Criterion Covered Total %
statement 9 36 25.0
branch 0 16 0.0
condition n/a
subroutine 3 14 21.4
pod 9 11 81.8
total 21 77 27.2


line stmt bran cond sub pod time code
1             package Net::GitHub::V3::Users;
2              
3 1     1   6 use Moo;
  1         2  
  1         7  
4              
5             our $VERSION = '1.03';
6             our $AUTHORITY = 'cpan:FAYLAND';
7              
8 1     1   624 use URI::Escape;
  1         1230  
  1         534  
9              
10             with 'Net::GitHub::V3::Query';
11              
12             sub show {
13 0     0 1   my ( $self, $user ) = @_;
14              
15 0 0         my $u = $user ? "/users/" . uri_escape($user) : '/user';
16 0           return $self->query($u);
17             }
18              
19             sub update {
20 0     0 1   my $self = shift;
21 0 0         my $data = @_ % 2 ? shift @_ : { @_ };
22              
23 0           return $self->query('PATCH', '/user', $data);
24             }
25              
26             sub add_email {
27 0     0 1   (shift)->query( 'POST', '/user/emails', [ @_ ] );
28             }
29             sub remove_email {
30 0     0 1   (shift)->query( 'DELETE', '/user/emails', [ @_ ] );
31             }
32              
33             sub followers {
34 0     0 1   my ($self, $user) = @_;
35              
36 0 0         my $u = $user ? "/users/" . uri_escape($user) . '/followers' : '/user/followers';
37 0           return $self->query($u);
38             }
39              
40             sub next_follower {
41 0     0 1   my ($self, $user) = @_;
42              
43 0 0         my $u = $user ? "/users/" . uri_escape($user) . '/followers' : '/user/followers';
44 0           return $self->next($u);
45             }
46              
47             sub close_follower {
48 0     0 0   my ($self, $user) = @_;
49              
50 0 0         my $u = $user ? "/users/" . uri_escape($user) . '/followers' : '/user/followers';
51 0           return $self->close($u);
52             }
53              
54              
55             sub following {
56 0     0 1   my ($self, $user) = @_;
57              
58 0 0         my $u = $user ? "/users/" . uri_escape($user) . '/following' : '/user/following';
59 0           return $self->query($u);
60             }
61              
62             sub next_following {
63 0     0 1   my ($self, $user) = @_;
64              
65 0 0         my $u = $user ? "/users/" . uri_escape($user) . '/following' : '/user/following';
66 0           return $self->next($u);
67             }
68              
69             sub close_following {
70 0     0 0   my ($self, $user) = @_;
71              
72 0 0         my $u = $user ? "/users/" . uri_escape($user) . '/following' : '/user/following';
73 0           return $self->close($u);
74             }
75              
76             ## build methods on fly
77             my %__methods = (
78              
79             emails => { url => "/user/emails", paginate => 1 },
80              
81             is_following => { url => "/user/following/%s", check_status => 204 },
82             follow => { url => "/user/following/%s", method => 'PUT', check_status => 204 },
83             unfollow => { url => "/user/following/%s", method => 'DELETE', check_status => 204 },
84              
85             keys => { url => "/user/keys", paginate => 1 },
86             key => { url => "/user/keys/%s" },
87             create_key => { url => "/user/keys", method => 'POST', args => 1 },
88             update_key => { url => "/user/keys/%s", method => 'PATCH', args => 1 },
89             delete_key => { url => "/user/keys/%s", method => 'DELETE', check_status => 204 },
90             );
91             __build_methods(__PACKAGE__, %__methods);
92              
93             ## DEPERCATED
94             sub contributions {
95 0     0 1   die "contributions_calender_data is no longer available";
96             }
97              
98 1     1   8 no Moo;
  1         2  
  1         6  
99              
100             1;
101             __END__