File Coverage

blib/lib/Net/GitHub/V3/Users.pm
Criterion Covered Total %
statement 9 24 37.5
branch 0 8 0.0
condition n/a
subroutine 3 10 30.0
pod 7 7 100.0
total 19 49 38.7


line stmt bran cond sub pod time code
1             package Net::GitHub::V3::Users;
2              
3 1     1   4 use Moo;
  1         1  
  1         5  
4              
5             our $VERSION = '0.60';
6             our $AUTHORITY = 'cpan:FAYLAND';
7              
8 1     1   592 use URI::Escape;
  1         921  
  1         305  
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             sub followers {
33 0     0 1   my ($self, $user) = @_;
34              
35 0 0         my $u = $user ? "/users/" . uri_escape($user) . '/followers' : '/user/followers';
36 0           return $self->query($u);
37             }
38             sub following {
39 0     0 1   my ($self, $user) = @_;
40              
41 0 0         my $u = $user ? "/users/" . uri_escape($user) . '/following' : '/user/following';
42 0           return $self->query($u);
43             }
44              
45             ## build methods on fly
46             my %__methods = (
47              
48             emails => { url => "/user/emails" },
49              
50             is_following => { url => "/user/following/%s", check_status => 204 },
51             follow => { url => "/user/following/%s", method => 'PUT', check_status => 204 },
52             unfollow => { url => "/user/following/%s", method => 'DELETE', check_status => 204 },
53              
54             keys => { url => "/user/keys" },
55             key => { url => "/user/keys/%s" },
56             create_key => { url => "/user/keys", method => 'POST', args => 1 },
57             update_key => { url => "/user/keys/%s", method => 'PATCH', args => 1 },
58             delete_key => { url => "/user/keys/%s", method => 'DELETE', check_status => 204 },
59             );
60             __build_methods(__PACKAGE__, %__methods);
61              
62             ## DEPERCATED
63             sub contributions {
64 0     0 1   die "contributions_calender_data is no longer available";
65             }
66              
67 1     1   6 no Moo;
  1         1  
  1         4  
68              
69             1;
70             __END__