1 /**
2 * Copyright (c) 2013-2023, jcabi.com
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met: 1) Redistributions of source code must retain the above
8 * copyright notice, this list of conditions and the following
9 * disclaimer. 2) Redistributions in binary form must reproduce the above
10 * copyright notice, this list of conditions and the following
11 * disclaimer in the documentation and/or other materials provided
12 * with the distribution. 3) Neither the name of the jcabi.com nor
13 * the names of its contributors may be used to endorse or promote
14 * products derived from this software without specific prior written
15 * permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
19 * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
20 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
21 * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
22 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
28 * OF THE POSSIBILITY OF SUCH DAMAGE.
29 */
30 package com.jcabi.github;
31
32 import com.jcabi.aspects.Immutable;
33 import java.io.IOException;
34 import java.util.Map;
35
36 /**
37 * Github pull comments.
38 *
39 * @author Andres Candal (andres.candal@rollasolution.com)
40 * @version $Id: 8a8d8bdfb797a2f051235f0422b1a5ad30085f3b $
41 * @since 0.8
42 * @see <a href="https://developer.github.com/v3/pulls/comments/">Review Comments API</a>
43 */
44 @Immutable
45 public interface PullComments {
46
47 /**
48 * Pull we're in.
49 *
50 * @return Pull
51 */
52 Pull pull();
53
54 /**
55 * Get specific pull comment by number.
56 *
57 * @param number Pull comment number
58 * @return Pull comment
59 * @see <a href="https://developer.github.com/v3/pulls/comments/#get-a-single-comment">Get a single comment</a>
60 */
61 PullComment get(int number);
62
63 /**
64 * Iterate all pull comments for this repo.
65 *
66 * @param params Iterating parameters, as specified by API
67 * @return Iterable of pull comments
68 * @see <a href="https://developer.github.com/v3/pulls/comments/#list-comments-in-a-repository">List comments in a repository</a>
69 */
70 Iterable<PullComment> iterate(
71 Map<String, String> params);
72
73 /**
74 * Iterate all pull comments for a pull request.
75 *
76 * @param number Pull comment number
77 * @param params Iterating parameters, as specified by API
78 * @return Iterable of pull comments
79 * @see <a href="https://developer.github.com/v3/pulls/comments/#list-comments-on-a-pull-request">List comments on a pull request</a>
80 */
81 Iterable<PullComment> iterate(int number,
82 Map<String, String> params);
83
84 /**
85 * Post a new pull comment.
86 *
87 * @param body Body of it
88 * @param commit Commit ID (SHA) of it
89 * @param path Path of the file to comment on
90 * @param position Line index in the diff to comment on
91 * @return PullComment just created
92 * @throws IOException If there is any I/O problem
93 * @see <a href="https://developer.github.com/v3/pulls/comments/#create-a-comment">Create a comment</a>
94 * @checkstyle ParameterNumberCheck (7 lines)
95 */
96 PullComment post(
97 String body,
98 String commit,
99 String path,
100 int position)
101 throws IOException;
102
103 /**
104 * Create a new comment as a reply to an existing pull comment.
105 *
106 * @param body Body of it
107 * @param comment Commit ID (SHA) of it
108 * @return PullComment just created
109 * @throws IOException If there is any I/O problem
110 * @see <a href="https://developer.github.com/v3/pulls/comments/#create-a-comment">Create a comment</a>
111 */
112 PullComment reply(
113 String body,
114 int comment)
115 throws IOException;
116
117 /**
118 * Removes a pull comment by ID.
119 *
120 * @param number The ID of the pull comment to delete.
121 * @throws IOException If there is any I/O problem.
122 */
123 void remove(int number) throws IOException;
124
125 }