File Coverage

blib/lib/Pithub/Repos/Keys.pm
Criterion Covered Total %
statement 21 21 100.0
branch 6 6 100.0
condition n/a
subroutine 6 6 100.0
pod 4 4 100.0
total 37 37 100.0


line stmt bran cond sub pod time code
1             package Pithub::Repos::Keys;
2             our $AUTHORITY = 'cpan:PLU';
3             our $VERSION = '0.01039';
4             # ABSTRACT: Github v3 Repo Keys API
5              
6 15     15   91 use Moo;
  15         28  
  15         70  
7 15     15   5670 use Carp qw( croak );
  15         38  
  15         4915  
8             extends 'Pithub::Base';
9              
10              
11             sub create {
12 4     4 1 8191 my ( $self, %args ) = @_;
13 4 100       28 croak 'Missing key in parameters: data (hashref)' unless ref $args{data} eq 'HASH';
14 3         28 $self->_validate_user_repo_args( \%args );
15             return $self->request(
16             method => 'POST',
17 3         34 path => sprintf( '/repos/%s/%s/keys', delete $args{user}, delete $args{repo} ),
18             %args,
19             );
20             }
21              
22              
23             sub delete {
24 4     4 1 3560 my ( $self, %args ) = @_;
25 4 100       23 croak 'Missing key in parameters: key_id' unless $args{key_id};
26 3         14 $self->_validate_user_repo_args( \%args );
27             return $self->request(
28             method => 'DELETE',
29 3         29 path => sprintf( '/repos/%s/%s/keys/%s', delete $args{user}, delete $args{repo}, delete $args{key_id} ),
30             %args,
31             );
32             }
33              
34              
35             sub get {
36 4     4 1 3511 my ( $self, %args ) = @_;
37 4 100       26 croak 'Missing key in parameters: key_id' unless $args{key_id};
38 3         15 $self->_validate_user_repo_args( \%args );
39             return $self->request(
40             method => 'GET',
41 3         28 path => sprintf( '/repos/%s/%s/keys/%s', delete $args{user}, delete $args{repo}, delete $args{key_id} ),
42             %args,
43             );
44             }
45              
46              
47             sub list {
48 19     19 1 2325 my ( $self, %args ) = @_;
49 19         65 $self->_validate_user_repo_args( \%args );
50             return $self->request(
51             method => 'GET',
52 13         78 path => sprintf( '/repos/%s/%s/keys', delete $args{user}, delete $args{repo} ),
53             %args,
54             );
55             }
56              
57             1;
58              
59             __END__