File Coverage

blib/lib/Pithub/Issues/Comments.pm
Criterion Covered Total %
statement 28 28 100.0
branch 14 14 100.0
condition n/a
subroutine 7 7 100.0
pod 5 5 100.0
total 54 54 100.0


line stmt bran cond sub pod time code
1             package Pithub::Issues::Comments;
2             our $AUTHORITY = 'cpan:PLU';
3             our $VERSION = '0.01041';
4              
5             # ABSTRACT: Github v3 Issue Comments API
6              
7 17     17   117 use Moo;
  17         34  
  17         94  
8 17     17   5423 use Carp qw( croak );
  17         74  
  17         9639  
9             extends 'Pithub::Base';
10              
11              
12             sub create {
13 6     6 1 10672 my ( $self, %args ) = @_;
14 6 100       32 croak 'Missing key in parameters: issue_id' unless $args{issue_id};
15             croak 'Missing key in parameters: data (hashref)'
16 5 100       34 unless ref $args{data} eq 'HASH';
17 3         24 $self->_validate_user_repo_args( \%args );
18             return $self->request(
19             method => 'POST',
20             path => sprintf(
21             '/repos/%s/%s/issues/%s/comments', delete $args{user},
22             delete $args{repo}, delete $args{issue_id}
23 3         43 ),
24             %args,
25             );
26             }
27              
28              
29             sub delete {
30 4     4 1 3364 my ( $self, %args ) = @_;
31 4 100       30 croak 'Missing key in parameters: comment_id' unless $args{comment_id};
32 3         17 $self->_validate_user_repo_args( \%args );
33             return $self->request(
34             method => 'DELETE',
35             path => sprintf(
36             '/repos/%s/%s/issues/comments/%s', delete $args{user},
37             delete $args{repo}, delete $args{comment_id}
38 3         42 ),
39             %args,
40             );
41             }
42              
43              
44             sub get {
45 3     3 1 2202 my ( $self, %args ) = @_;
46 3 100       24 croak 'Missing key in parameters: comment_id' unless $args{comment_id};
47 2         14 $self->_validate_user_repo_args( \%args );
48             return $self->request(
49             method => 'GET',
50             path => sprintf(
51             '/repos/%s/%s/issues/comments/%s', delete $args{user},
52             delete $args{repo}, delete $args{comment_id}
53 2         26 ),
54             %args,
55             );
56             }
57              
58              
59             sub list {
60 3     3 1 2299 my ( $self, %args ) = @_;
61 3 100       22 croak 'Missing key in parameters: issue_id' unless $args{issue_id};
62 2         16 $self->_validate_user_repo_args( \%args );
63             return $self->request(
64             method => 'GET',
65             path => sprintf(
66             '/repos/%s/%s/issues/%s/comments', delete $args{user},
67             delete $args{repo}, delete $args{issue_id}
68 2         28 ),
69             %args,
70             );
71             }
72              
73              
74             sub update {
75 6     6 1 4727 my ( $self, %args ) = @_;
76 6 100       34 croak 'Missing key in parameters: comment_id' unless $args{comment_id};
77             croak 'Missing key in parameters: data (hashref)'
78 5 100       36 unless ref $args{data} eq 'HASH';
79 3         16 $self->_validate_user_repo_args( \%args );
80             return $self->request(
81             method => 'PATCH',
82             path => sprintf(
83             '/repos/%s/%s/issues/comments/%s', delete $args{user},
84             delete $args{repo}, delete $args{comment_id}
85 3         35 ),
86             %args,
87             );
88             }
89              
90             1;
91              
92             __END__