File Coverage

blib/lib/Pithub/Repos/Releases.pm
Criterion Covered Total %
statement 30 30 100.0
branch 10 10 100.0
condition n/a
subroutine 9 9 100.0
pod 6 6 100.0
total 55 55 100.0


line stmt bran cond sub pod time code
1             package Pithub::Repos::Releases;
2             our $AUTHORITY = 'cpan:PLU';
3             our $VERSION = '0.01039';
4             # ABSTRACT: Github v3 Repo Releases API
5              
6 15     15   87 use Moo;
  15         28  
  15         73  
7 15     15   4268 use Carp qw( croak );
  15         26  
  15         671  
8 15     15   5979 use Pithub::Repos::Releases::Assets;
  15         36  
  15         5579  
9             extends 'Pithub::Base';
10              
11              
12             sub assets {
13 1     1 1 516 return shift->_create_instance('Pithub::Repos::Releases::Assets', @_);
14             }
15              
16              
17             sub list {
18 2     2 1 6369 my ( $self, %args ) = @_;
19 2         23 $self->_validate_user_repo_args( \%args );
20             return $self->request(
21             method => 'GET',
22 2         32 path => sprintf( '/repos/%s/%s/releases', delete $args{user}, delete $args{repo} ),
23             %args,
24             );
25             }
26              
27              
28             sub get {
29 3     3 1 2467 my ( $self, %args ) = @_;
30 3 100       22 croak 'Missing key in parameters: release_id' unless $args{release_id};
31 2         13 $self->_validate_user_repo_args( \%args );
32             return $self->request(
33             method => 'GET',
34 2         22 path => sprintf( '/repos/%s/%s/releases/%d', delete $args{user}, delete $args{repo}, delete $args{release_id} ),
35             %args,
36             );
37             }
38              
39              
40             sub create {
41 4     4 1 4242 my ( $self, %args ) = @_;
42 4 100       46 croak 'Missing key in parameters: data (hashref)' unless ref $args{data} eq 'HASH';
43 3         27 $self->_validate_user_repo_args( \%args );
44             return $self->request(
45             method => 'POST',
46 3         29 path => sprintf( '/repos/%s/%s/releases', delete $args{user}, delete $args{repo} ),
47             %args,
48             );
49             }
50              
51              
52             sub update {
53 5     5 1 4322 my ( $self, %args ) = @_;
54 5 100       26 croak 'Missing key in parameters: release_id' unless $args{release_id};
55 4 100       23 croak 'Missing key in parameters: data (hashref)' unless ref $args{data} eq 'HASH';
56 3         16 $self->_validate_user_repo_args( \%args );
57             return $self->request(
58             method => 'PATCH',
59 3         29 path => sprintf( '/repos/%s/%s/releases/%d', delete $args{user}, delete $args{repo}, delete $args{release_id} ),
60             %args,
61             );
62             }
63              
64              
65             sub delete {
66 4     4 1 3467 my ( $self, %args ) = @_;
67 4 100       25 croak 'Missing key in parameters: release_id' unless $args{release_id};
68 3         15 $self->_validate_user_repo_args( \%args );
69             return $self->request(
70             method => 'DELETE',
71 3         29 path => sprintf( '/repos/%s/%s/releases/%d', delete $args{user}, delete $args{repo}, delete $args{release_id} ),
72             %args,
73             );
74             }
75              
76             1;
77              
78             __END__