1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
package gh
import akka.NotUsed
import akka.stream.scaladsl.Source
import scala.concurrent.Future
import spray.json.{ DefaultJsonProtocol, JsonFormat }
trait Issues { self: HttpClient =>
import self._
case class Issue(
id: Int,
number: Int,
state: String,
title: String,
body: String,
user: User,
labels: Seq[Label],
assignee: Option[User],
milestone: Option[Milestone],
locked: Boolean,
comments: Int,
closedAt: Option[String],
createdAt: String,
updatedAt: String
)
case class User(
login: String,
id: Int,
avatarUrl: String,
gravatarId: String,
`type`: String,
siteAdmin: Boolean
)
case class Label(
name: String,
color: String
)
case class Milestone(
id: Int,
state: String,
title: String,
description: String,
creator: User,
openIssues: Int,
closedIssues: Int,
createdAt: String,
updatedAt: String,
closedAt: String,
dueOn: String
)
case class Comment(
id: Int,
body: String,
user: User,
createdAt: String,
updatedAt: String
)
private object JsonSupport extends DefaultJsonProtocol with SnakifiedSprayJsonSupport {
implicit val userFormat = jsonFormat6(User)
implicit val commentFormat = jsonFormat5(Comment)
implicit val milestoneFormat = jsonFormat11(Milestone)
implicit val labelFormat = jsonFormat2(Label)
implicit val itemFormat = jsonFormat14(Issue)
}
import JsonSupport._
object issues {
def get(
owner: String,
repo: String,
milestone: String = "*",
state: String = "all",
assignee: String = "*",
creator: String = "*",
mentioned: String = "*",
labels: String = "*",
sort: String = "created",
direction: String = "desc",
since: String = "1970-01-01T00:00:00"
): Source[Issue, NotUsed] = {
client.get[collection.immutable.Seq[Issue]]("/repos/" + owner + "/" + repo + "/issues").mapConcat(x => x)
}
}
}
|