Skip to content

Commit 559b4d8

Browse files
committed
Merge pull request #12 from codacy/generic_commit
Split up createComment into a lower level postNewComment
2 parents eca5210 + 53150b8 commit 559b4d8

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,22 @@ class PullRequestServices(client: BitbucketClient) {
6868
client.postJson(Request(url, classOf[JsObject]), JsNull)
6969
}
7070

71-
def createComment(author: String, repo: String, prId: Int, commitUUID: String, body: String, file: Option[String], line: Option[Int]): RequestResponse[PullRequestComment] = {
71+
private[this] def postNewComment(author: String, repo: String, prId: Int, values: JsObject): RequestResponse[PullRequestComment] = {
7272
val url = s"https://bitbucket.org/api/1.0/repositories/$author/$repo/pullrequests/$prId/comments"
73+
client.postJson(Request(url, classOf[PullRequestComment]), values)
74+
}
75+
76+
def createPullRequestComment(author: String, repo: String, prId: Int, content: String): RequestResponse[PullRequestComment] = {
77+
val values = Json.obj("content" -> JsString(content))
78+
postNewComment(author, repo, prId, values)
79+
}
7380

81+
def createComment(author: String, repo: String, prId: Int, commitUUID: String, body: String, file: Option[String], line: Option[Int]): RequestResponse[PullRequestComment] = {
7482
val params = file.map(filename => "filename" -> JsString(filename)) ++
7583
line.map(lineTo => "line_to" -> JsNumber(lineTo))
7684

7785
val values = JsObject(params.toSeq :+ "content" -> JsString(body) :+ "anchor" -> JsString(commitUUID.take(12)))
78-
79-
client.postJson(Request(url, classOf[PullRequestComment]), values)
86+
postNewComment(author, repo, prId, values = values)
8087
}
8188

8289
def deleteComment(author: String, repo: String, commitUUID: String, pullRequestId: Int, commentId: Long): Unit = {

0 commit comments

Comments
 (0)