File Coverage

blib/lib/Pithub/Repos/Releases/Assets.pm
Criterion Covered Total %
statement 30 30 100.0
branch 18 18 100.0
condition n/a
subroutine 7 7 100.0
pod 5 5 100.0
total 60 60 100.0


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