1package Pithub::PullRequests::Comments;
2our $AUTHORITY = 'cpan:PLU';
3our $VERSION = '0.01036';
4# ABSTRACT: Github v3 Pull Request Comments API
5
6use Moo;
7use Carp qw( croak );
8extends 'Pithub::Base';
9
10
11sub create {
12    my ( $self, %args ) = @_;
13    croak 'Missing key in parameters: pull_request_id' unless $args{pull_request_id};
14    croak 'Missing key in parameters: data (hashref)' unless ref $args{data} eq 'HASH';
15    $self->_validate_user_repo_args( \%args );
16    return $self->request(
17        method => 'POST',
18        path   => sprintf( '/repos/%s/%s/pulls/%s/comments', delete $args{user}, delete $args{repo}, delete $args{pull_request_id} ),
19        %args
20    );
21}
22
23
24sub delete {
25    my ( $self, %args ) = @_;
26    croak 'Missing key in parameters: comment_id' unless $args{comment_id};
27    $self->_validate_user_repo_args( \%args );
28    return $self->request(
29        method => 'DELETE',
30        path   => sprintf( '/repos/%s/%s/pulls/comments/%s', delete $args{user}, delete $args{repo}, delete $args{comment_id} ),
31        %args,
32    );
33}
34
35
36sub get {
37    my ( $self, %args ) = @_;
38    croak 'Missing key in parameters: comment_id' unless $args{comment_id};
39    $self->_validate_user_repo_args( \%args );
40    return $self->request(
41        method => 'GET',
42        path   => sprintf( '/repos/%s/%s/pulls/comments/%s', delete $args{user}, delete $args{repo}, delete $args{comment_id} ),
43        %args,
44    );
45}
46
47
48sub list {
49    my ( $self, %args ) = @_;
50    croak 'Missing key in parameters: pull_request_id' unless $args{pull_request_id};
51    $self->_validate_user_repo_args( \%args );
52    return $self->request(
53        method => 'GET',
54        path   => sprintf( '/repos/%s/%s/pulls/%s/comments', delete $args{user}, delete $args{repo}, delete $args{pull_request_id} ),
55        %args,
56    );
57}
58
59
60sub update {
61    my ( $self, %args ) = @_;
62    croak 'Missing key in parameters: comment_id' unless $args{comment_id};
63    croak 'Missing key in parameters: data (hashref)' unless ref $args{data} eq 'HASH';
64    $self->_validate_user_repo_args( \%args );
65    return $self->request(
66        method => 'PATCH',
67        path   => sprintf( '/repos/%s/%s/pulls/comments/%s', delete $args{user}, delete $args{repo}, delete $args{comment_id} ),
68        %args,
69    );
70}
71
721;
73
74__END__
75
76=pod
77
78=encoding UTF-8
79
80=head1 NAME
81
82Pithub::PullRequests::Comments - Github v3 Pull Request Comments API
83
84=head1 VERSION
85
86version 0.01036
87
88=head1 METHODS
89
90=head2 create
91
92=over
93
94=item *
95
96Create a comment
97
98    POST /repos/:user/:repo/pulls/:id/comments
99
100Examples:
101
102    my $c = Pithub::PullRequests::Comments->new;
103    my $result = $c->create(
104        repo            => 'Pithub',
105        user            => 'plu',
106        pull_request_id => 1,
107        data            => {
108            body      => 'Nice change',
109            commit_id => '6dcb09b5b57875f334f61aebed695e2e4193db5e',
110            path      => 'file1.txt',
111            position  => 4,
112        }
113    );
114
115=back
116
117=head2 delete
118
119=over
120
121=item *
122
123Delete a comment
124
125    DELETE /repos/:user/:repo/pulls/comments/:id
126
127Examples:
128
129    my $c = Pithub::PullRequests::Comments->new;
130    my $result = $c->delete(
131        repo       => 'Pithub',
132        user       => 'plu',
133        comment_id => 1,
134    );
135
136=back
137
138=head2 get
139
140=over
141
142=item *
143
144Get a single comment
145
146    GET /repos/:user/:repo/pulls/comments/:id
147
148Examples:
149
150    my $c = Pithub::PullRequests::Comments->new;
151    my $result = $c->get(
152        repo       => 'Pithub',
153        user       => 'plu',
154        comment_id => 1,
155    );
156
157=back
158
159=head2 list
160
161=over
162
163=item *
164
165List comments on a pull request
166
167    GET /repos/:user/:repo/pulls/:id/comments
168
169Examples:
170
171    my $c = Pithub::PullRequests::Comments->new;
172    my $result = $c->list(
173        repo            => 'Pithub',
174        user            => 'plu',
175        pull_request_id => 1,
176    );
177
178=back
179
180=head2 update
181
182=over
183
184=item *
185
186Edit a comment
187
188    PATCH /repos/:user/:repo/pulls/comments/:id
189
190Examples:
191
192    my $c = Pithub::PullRequests::Comments->new;
193    my $result = $c->update(
194        repo       => 'Pithub',
195        user       => 'plu',
196        comment_id => 1,
197        data       => { body => 'some updated comment' },
198    );
199
200=back
201
202=head1 AUTHOR
203
204Johannes Plunien <plu@cpan.org>
205
206=head1 COPYRIGHT AND LICENSE
207
208This software is copyright (c) 2011-2019 by Johannes Plunien.
209
210This is free software; you can redistribute it and/or modify it under
211the same terms as the Perl 5 programming language system itself.
212
213=cut
214