@@ -28,6 +28,11 @@ class PullRequestServices(client: BitbucketClient) {
28
28
client.executePaginated(Request (url, classOf [Seq [SimpleCommit ]]))
29
29
}
30
30
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
+
31
36
def create (owner : String , repository : String , title : String , sourceBranch : String , destinationBranch : String ): RequestResponse [JsObject ] = {
32
37
val url = s " https://bitbucket.org/api/2.0/repositories/ $owner/ $repository/pullrequests "
33
38
@@ -68,19 +73,22 @@ class PullRequestServices(client: BitbucketClient) {
68
73
client.postJson(Request (url, classOf [JsObject ]), JsNull )
69
74
}
70
75
71
- def createComment (author : String , repo : String , prId : Int , body : String ,
76
+ def createLineComment (author : String , repo : String , prId : Int , body : String ,
72
77
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
-
75
78
val params = for {
76
79
filename <- file
77
80
lineTo <- line
78
81
} yield {
79
82
" inline" -> Json .obj(" path" -> JsString (filename), " to" -> JsNumber (lineTo))
80
83
}
81
84
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)
84
92
}
85
93
86
94
def deleteComment (author : String , repo : String , pullRequestId : Int , commentId : Long ): RequestResponse [Boolean ] = {
0 commit comments