Skip to content

Commit 501be76

Browse files
committed
Add listComments for PR to the Bitbucket API
1 parent 7be72ad commit 501be76

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package com.codacy.client.bitbucket
2+
3+
import play.api.libs.functional.syntax._
4+
import play.api.libs.json._
5+
6+
case class SimplePullRequestComment(id: Long, anchor: Option[String])
7+
8+
object SimplePullRequestComment {
9+
10+
implicit val reader: Reads[SimplePullRequestComment] = (
11+
(__ \ "comment_id").read[Long] and
12+
(__ \ "anchor").readNullable[String]
13+
)(SimplePullRequestComment.apply _)
14+
}

src/main/scala/com/codacy/client/bitbucket/service/PullRequestServices.scala

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.codacy.client.bitbucket.service
22

33
import com.codacy.client.bitbucket.client.{BitbucketClient, Request, RequestResponse}
4-
import com.codacy.client.bitbucket.{PullRequestComment, PullRequest, SimpleCommit}
4+
import com.codacy.client.bitbucket.{PullRequest, PullRequestComment, SimpleCommit, SimplePullRequestComment}
55
import play.api.libs.json._
66

77
class PullRequestServices(client: BitbucketClient) {
@@ -93,4 +93,10 @@ class PullRequestServices(client: BitbucketClient) {
9393
client.delete(url)
9494
}
9595

96+
def listComments(author: String, repo: String, pullRequestId: Int): RequestResponse[Seq[SimplePullRequestComment]] = {
97+
val url = s"https://bitbucket.org/!api/1.0/repositories/$author/$repo/pullrequests/$pullRequestId/comments"
98+
99+
client.execute(Request(url, classOf[Seq[SimplePullRequestComment]]))
100+
}
101+
96102
}

0 commit comments

Comments
 (0)