File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed
src/main/scala/com/codacy/client/bitbucket Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change
1
+ package com .codacy .client .bitbucket
2
+
3
+ import play .api .libs .json .{Json , Reads }
4
+
5
+ case class FieldValue (name: String ,value: String )
6
+ case class ServiceValue (fields: Seq [FieldValue ],`type`: String )
7
+ case class Service (id: Long , service: ServiceValue )
8
+
9
+ object Service {
10
+ implicit val reads : Reads [Service ] = {
11
+ implicit lazy val r0 = Json .reads[FieldValue ]
12
+ implicit lazy val r1 = Json .reads[ServiceValue ]
13
+ Json .reads[Service ]
14
+ }
15
+ }
Original file line number Diff line number Diff line change
1
+ package com .codacy .client .bitbucket .service
2
+
3
+ import com .codacy .client .bitbucket .Service
4
+ import com .codacy .client .bitbucket .client .{BitbucketClient , Request , RequestResponse }
5
+
6
+ class HookServices (client : BitbucketClient ) {
7
+
8
+ def createPostPushHook (author : String , repo : String , hookUrl: String ): RequestResponse [Service ] = {
9
+ val url = s " https://bitbucket.org/!api/1.0/repositories/ $author/ $repo/services "
10
+
11
+ val payload = Map (
12
+ " type" -> " POST" ,
13
+ " URL" -> hookUrl
14
+ ).mapValues(Seq (_))
15
+
16
+ client.post(Request (url, classOf [Service ]), payload)
17
+ }
18
+ }
You can’t perform that action at this time.
0 commit comments