Skip to content

Commit 0231cfe

Browse files
committed
Add missing arguments and endpoint
1 parent a55c255 commit 0231cfe

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

src/main/scala/com/codacy/client/bitbucket/v2/Repository.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ import play.api.libs.json._
88
case class Repository(name: String, full_name: String, description: String, scm: String,
99
created_on: LocalDateTime, updated_on: LocalDateTime, owner: String, size: Long,
1010
has_issues: Boolean, is_private: Boolean, language: String,
11-
url: Seq[RepositoryUrl])
11+
url: Seq[RepositoryUrl]) {
12+
13+
val sshUrl: String = s"ssh://$scm@bitbucket.org/$owner/$name"
14+
val httpsUrl: String = s"https://$owner@bitbucket.org/$owner/$name"
15+
}
1216

1317
object Repository {
1418
val dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSSSSXXX"

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

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ class PullRequestServices(client: BitbucketClient) {
2828
client.executePaginated(Request(url, classOf[Seq[SimpleCommit]]))
2929
}
3030

31+
private[this] def postNewComment(owner: String, repo: String, prId: Int, values: JsObject): RequestResponse[PullRequestComment] = {
32+
val url = s"https://bitbucket.org/api/2.0/repositories/$owner/$repo/pullrequests/$prId/comments"
33+
client.postJson(Request(url, classOf[PullRequestComment]), values)
34+
}
35+
3136
def create(owner: String, repository: String, title: String, sourceBranch: String, destinationBranch: String): RequestResponse[JsObject] = {
3237
val url = s"https://bitbucket.org/api/2.0/repositories/$owner/$repository/pullrequests"
3338

@@ -68,19 +73,22 @@ class PullRequestServices(client: BitbucketClient) {
6873
client.postJson(Request(url, classOf[JsObject]), JsNull)
6974
}
7075

71-
def createComment(author: String, repo: String, prId: Int, body: String,
76+
def createLineComment(author: String, repo: String, prId: Int, body: String,
7277
file: Option[String], line: Option[Int]): RequestResponse[PullRequestComment] = {
73-
val url = s"https://bitbucket.org/api/2.0/repositories/$author/$repo/pullrequests/$prId/comments"
74-
7578
val params = for {
7679
filename <- file
7780
lineTo <- line
7881
} yield {
7982
"inline" -> Json.obj("path" -> JsString(filename), "to" -> JsNumber(lineTo))
8083
}
8184

82-
val values = JsObject(params.toSeq :+ "content" -> Json.obj("raw" -> JsString(body)))//, "anchor" -> JsString(CommitHelper.anchor(commitUUID))))
83-
client.postJson(Request(url, classOf[PullRequestComment]), values)
85+
val values = JsObject(params.toSeq :+ "content" -> Json.obj("raw" -> JsString(body)))
86+
postNewComment(author, repo, prId, values)
87+
}
88+
89+
def createPullRequestComment(author: String, repo: String, prId: Int, content: String): RequestResponse[PullRequestComment] = {
90+
val values = Json.obj("content" -> JsString(content))
91+
postNewComment(author, repo, prId, values)
8492
}
8593

8694
def deleteComment(author: String, repo: String, pullRequestId: Int, commentId: Long): RequestResponse[Boolean] = {

0 commit comments

Comments
 (0)