forked from 47degrees/github4s
/
PullRequest.scala
119 lines (105 loc) · 4.16 KB
/
PullRequest.scala
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*
* Copyright 2016-2017 47 Degrees, LLC. <http://www.47deg.com>
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package github4s.free.domain
case class PullRequest(
id: Int,
number: Int,
state: String,
title: String,
body: String,
locked: Boolean,
html_url: String,
created_at: String,
updated_at: Option[String],
closed_at: Option[String],
merged_at: Option[String],
base: Option[PullRequestBase],
head: Option[PullRequestBase],
user: Option[User],
assignee: Option[User])
case class PullRequestBase(
label: Option[String],
ref: String,
sha: String,
user: Option[User],
repo: Option[Repository])
case class PullRequestFile(
sha: String,
filename: String,
status: String,
additions: Int,
deletions: Int,
changes: Int,
blob_url: String,
raw_url: String,
contents_url: String,
patch: Option[String],
previous_filename: Option[String])
sealed trait CreatePullRequest {
def head: String
def base: String
def maintainer_can_modify: Option[Boolean]
}
case class CreatePullRequestData(
title: String,
head: String,
base: String,
body: String,
maintainer_can_modify: Option[Boolean] = Some(true))
extends CreatePullRequest
case class CreatePullRequestIssue(
issue: Int,
head: String,
base: String,
maintainer_can_modify: Option[Boolean] = Some(true))
extends CreatePullRequest
sealed abstract class PRFilter(val name: String, val value: String)
extends Product
with Serializable {
def tupled: (String, String) = name -> value
}
sealed abstract class PRFilterState(override val value: String) extends PRFilter("state", value)
case object PRFilterOpen extends PRFilterState("open")
case object PRFilterClosed extends PRFilterState("closed")
case object PRFilterAll extends PRFilterState("all")
case class PRFilterHead(override val value: String) extends PRFilter("head", value)
case class PRFilterBase(override val value: String) extends PRFilter("base", value)
sealed abstract class PRFilterSort(override val value: String) extends PRFilter("sort", value)
case object PRFilterSortCreated extends PRFilterSort("created")
case object PRFilterSortUpdated extends PRFilterSort("updated")
case object PRFilterSortPopularity extends PRFilterSort("popularity")
case object PRFilterSortLongRunning extends PRFilterSort("long-running")
sealed abstract class PRFilterDirection(override val value: String)
extends PRFilter("direction", value)
case object PRFilterOrderAsc extends PRFilterDirection("asc")
case object PRFilterOrderDesc extends PRFilterDirection("desc")
sealed trait NewPullRequest
case class NewPullRequestData(title: String, body: String) extends NewPullRequest
case class NewPullRequestIssue(issue: Int) extends NewPullRequest
case class PullRequestReview(
id: Int,
user: Option[User],
body: String,
commit_id: String,
state: PullRequestReviewState,
html_url: String,
pull_request_url: String)
sealed abstract class PullRequestReviewState(val value: String)
case object PRRStateApproved extends PullRequestReviewState("APPROVED")
case object PRRStateChangesRequested extends PullRequestReviewState("CHANGES_REQUESTED")
case object PRRStateCommented extends PullRequestReviewState("COMMENTED")
case object PRRStatePending extends PullRequestReviewState("PENDING")
case object PRRStateDismissed extends PullRequestReviewState("DISMISSED")