2626import com .google .common .collect .ImmutableMap ;
2727import com .spotify .github .async .AsyncPage ;
2828import com .spotify .github .v3 .comment .Comment ;
29+ import com .spotify .github .v3 .comment .CommentReaction ;
30+ import com .spotify .github .v3 .comment .CommentReactionContent ;
2931import com .spotify .github .v3 .issues .Issue ;
3032import java .lang .invoke .MethodHandles ;
3133import java .util .Iterator ;
3234import java .util .concurrent .CompletableFuture ;
35+
36+ import okhttp3 .Response ;
3337import org .slf4j .Logger ;
3438import org .slf4j .LoggerFactory ;
3539
@@ -39,6 +43,8 @@ public class IssueClient {
3943 static final String COMMENTS_URI_NUMBER_TEMPLATE = "/repos/%s/%s/issues/%s/comments" ;
4044 static final String COMMENTS_URI_TEMPLATE = "/repos/%s/%s/issues/comments" ;
4145 static final String COMMENTS_URI_ID_TEMPLATE = "/repos/%s/%s/issues/comments/%s" ;
46+ static final String COMMENTS_REACTION_TEMPLATE = "/repos/%s/%s/issues/comments/%s/reactions" ;
47+ static final String COMMENTS_REACTION_ID_TEMPLATE = "/repos/%s/%s/issues/%s/reactions/%s" ;
4248 static final String ISSUES_URI_ID_TEMPLATE = "/repos/%s/%s/issues/%s" ;
4349 private static final Logger log = LoggerFactory .getLogger (MethodHandles .lookup ().lookupClass ());
4450
@@ -137,4 +143,23 @@ private Iterator<AsyncPage<Comment>> listComments(final String path) {
137143 public CompletableFuture <Issue > getIssue (final int id ) {
138144 return github .request (String .format (ISSUES_URI_ID_TEMPLATE , owner , repo , id ), Issue .class );
139145 }
146+
147+ /**
148+ * Create a reaction on a comment.
149+ *
150+ * @param commentId comment id
151+ * @param reaction reaction content
152+ * @return the Comment that was just created
153+ */
154+ public CompletableFuture <CommentReaction > createCommentReaction (final long commentId , final CommentReactionContent reaction ) {
155+ final String path = String .format (COMMENTS_REACTION_TEMPLATE , owner , repo , commentId );
156+ final String requestBody = github .json ().toJsonUnchecked (ImmutableMap .of ("content" , reaction ));
157+ return github .post (path , requestBody , CommentReaction .class );
158+ }
159+
160+ public CompletableFuture <Response > deleteCommentReaction (final long issueNumber , final long reactionId ) {
161+ final String path = String .format (COMMENTS_REACTION_ID_TEMPLATE , owner , repo , issueNumber , reactionId );
162+ final String requestBody = github .json ().toJsonUnchecked ("" );
163+ return github .delete (path , requestBody );
164+ }
140165}
0 commit comments