@@ -10,39 +10,42 @@ import GitHub.Data.Id (Id)
1010import GitHub.Data.PullRequests
1111import GitHub.Data.URL (URL )
1212import GitHub.Internal.Prelude
13+ import GitHub.Data.Milestone (Milestone )
1314import Prelude ()
1415
15- data Issue = Issue {
16- issueClosedAt :: Maybe UTCTime
17- ,issueUpdatedAt :: UTCTime
18- ,issueEventsUrl :: URL
19- ,issueHtmlUrl :: Maybe URL
20- ,issueClosedBy :: Maybe SimpleUser
21- ,issueLabels :: (Vector IssueLabel )
22- ,issueNumber :: Int
23- ,issueAssignee :: Maybe SimpleUser
24- ,issueUser :: SimpleUser
25- ,issueTitle :: Text
26- ,issuePullRequest :: Maybe PullRequestReference
27- ,issueUrl :: URL
28- ,issueCreatedAt :: UTCTime
29- ,issueBody :: Maybe Text
30- ,issueState :: Text
31- ,issueId :: Id Issue
32- ,issueComments :: Int
33- ,issueMilestone :: Maybe Milestone
34- } deriving (Show , Data , Typeable , Eq , Ord , Generic )
16+ data Issue = Issue
17+ { issueClosedAt :: Maybe UTCTime
18+ , issueUpdatedAt :: UTCTime
19+ , issueEventsUrl :: URL
20+ , issueHtmlUrl :: Maybe URL
21+ , issueClosedBy :: Maybe SimpleUser
22+ , issueLabels :: (Vector IssueLabel )
23+ , issueNumber :: Int
24+ , issueAssignee :: Maybe SimpleUser
25+ , issueUser :: SimpleUser
26+ , issueTitle :: Text
27+ , issuePullRequest :: Maybe PullRequestReference
28+ , issueUrl :: URL
29+ , issueCreatedAt :: UTCTime
30+ , issueBody :: Maybe Text
31+ , issueState :: Text
32+ , issueId :: Id Issue
33+ , issueComments :: Int
34+ , issueMilestone :: Maybe Milestone
35+ }
36+ deriving (Show , Data , Typeable , Eq , Ord , Generic )
3537
3638instance NFData Issue where rnf = genericRnf
3739instance Binary Issue
3840
39- data NewIssue = NewIssue {
40- newIssueTitle :: Text
41- , newIssueBody :: Maybe Text
42- , newIssueAssignee :: Maybe Text
43- , newIssueMilestone :: Maybe Int
44- , newIssueLabels :: Maybe (Vector Text )
45- } deriving (Show , Data , Typeable , Eq , Ord , Generic )
41+ data NewIssue = NewIssue
42+ { newIssueTitle :: Text
43+ , newIssueBody :: Maybe Text
44+ , newIssueAssignee :: Maybe Text
45+ , newIssueMilestone :: Maybe (Id Milestone )
46+ , newIssueLabels :: Maybe (Vector Text )
47+ }
48+ deriving (Show , Data , Typeable , Eq , Ord , Generic )
4649
4750instance NFData NewIssue where rnf = genericRnf
4851instance Binary NewIssue
@@ -52,29 +55,13 @@ data EditIssue = EditIssue {
5255, editIssueBody :: Maybe Text
5356, editIssueAssignee :: Maybe Text
5457, editIssueState :: Maybe Text
55- , editIssueMilestone :: Maybe Int
58+ , editIssueMilestone :: Maybe ( Id Milestone )
5659, editIssueLabels :: Maybe (Vector Text )
5760} deriving (Show , Data , Typeable , Eq , Ord , Generic )
5861
5962instance NFData EditIssue where rnf = genericRnf
6063instance Binary EditIssue
6164
62- data Milestone = Milestone {
63- milestoneCreator :: SimpleUser
64- ,milestoneDueOn :: Maybe UTCTime
65- ,milestoneOpenIssues :: Int
66- ,milestoneNumber :: Int
67- ,milestoneClosedIssues :: Int
68- ,milestoneDescription :: Maybe Text
69- ,milestoneTitle :: Text
70- ,milestoneUrl :: URL
71- ,milestoneCreatedAt :: UTCTime
72- ,milestoneState :: Text
73- } deriving (Show , Data , Typeable , Eq , Ord , Generic )
74-
75- instance NFData Milestone where rnf = genericRnf
76- instance Binary Milestone
77-
7865data IssueLabel = IssueLabel {
7966 labelColor :: Text
8067 ,labelUrl :: URL
@@ -135,76 +122,52 @@ data Event = Event {
135122instance NFData Event where rnf = genericRnf
136123instance Binary Event
137124
138- -- | A data structure for describing how to filter issues. This is used by
139- -- @issuesForRepo@.
140- data IssueLimitation =
141- AnyMilestone -- ^ Issues appearing in any milestone. [default]
142- | NoMilestone -- ^ Issues without a milestone.
143- | MilestoneId Int -- ^ Only issues that are in the milestone with the given id.
144- | Open -- ^ Only open issues. [default]
145- | OnlyClosed -- ^ Only closed issues.
146- | Unassigned -- ^ Issues to which no one has been assigned ownership.
147- | AnyAssignment -- ^ All issues regardless of assignment. [default]
148- | AssignedTo String -- ^ Only issues assigned to the user with the given login.
149- | Mentions String -- ^ Issues which mention the given string, taken to be a user's login.
150- | Labels [String ] -- ^ A list of labels to filter by.
151- | Ascending -- ^ Sort ascending.
152- | Descending -- ^ Sort descending. [default]
153- | Since UTCTime -- ^ Only issues created since the specified date and time.
154- | PerPage Int -- ^ Download this many issues per query
155- deriving (Eq , Ord , Show , Typeable , Data , Generic )
156-
157- instance NFData IssueLimitation where rnf = genericRnf
158- instance Binary IssueLimitation
159-
160- -- JSON instances
161-
162125instance FromJSON Event where
163- parseJSON = withObject " Event" $ \ o ->
164- Event <$> o .: " actor"
165- <*> o .: " event"
166- <*> o .:? " commit_id"
167- <*> o .: " url"
168- <*> o .: " created_at"
169- <*> o .: " id"
170- <*> o .:? " issue"
126+ parseJSON = withObject " Event" $ \ o -> Event
127+ <$> o .: " actor"
128+ <*> o .: " event"
129+ <*> o .:? " commit_id"
130+ <*> o .: " url"
131+ <*> o .: " created_at"
132+ <*> o .: " id"
133+ <*> o .:? " issue"
171134
172135instance FromJSON EventType where
173- parseJSON (String " closed" ) = pure Closed
174- parseJSON (String " reopened" ) = pure Reopened
175- parseJSON (String " subscribed" ) = pure Subscribed
176- parseJSON (String " merged" ) = pure Merged
177- parseJSON (String " referenced" ) = pure Referenced
178- parseJSON (String " mentioned" ) = pure Mentioned
179- parseJSON (String " assigned" ) = pure Assigned
180- parseJSON (String " unsubscribed" ) = pure Unsubscribed
181- parseJSON (String " unassigned" ) = pure ActorUnassigned
182- parseJSON (String " labeled" ) = pure Labeled
183- parseJSON (String " unlabeled" ) = pure Unlabeled
184- parseJSON (String " milestoned" ) = pure Milestoned
185- parseJSON (String " demilestoned" ) = pure Demilestoned
186- parseJSON (String " renamed" ) = pure Renamed
187- parseJSON (String " locked" ) = pure Locked
188- parseJSON (String " unlocked" ) = pure Unlocked
189- parseJSON (String " head_ref_deleted" ) = pure HeadRefDeleted
190- parseJSON (String " head_ref_restored" ) = pure HeadRefRestored
191- parseJSON _ = fail " Could not build an EventType"
136+ parseJSON (String " closed" ) = pure Closed
137+ parseJSON (String " reopened" ) = pure Reopened
138+ parseJSON (String " subscribed" ) = pure Subscribed
139+ parseJSON (String " merged" ) = pure Merged
140+ parseJSON (String " referenced" ) = pure Referenced
141+ parseJSON (String " mentioned" ) = pure Mentioned
142+ parseJSON (String " assigned" ) = pure Assigned
143+ parseJSON (String " unsubscribed" ) = pure Unsubscribed
144+ parseJSON (String " unassigned" ) = pure ActorUnassigned
145+ parseJSON (String " labeled" ) = pure Labeled
146+ parseJSON (String " unlabeled" ) = pure Unlabeled
147+ parseJSON (String " milestoned" ) = pure Milestoned
148+ parseJSON (String " demilestoned" ) = pure Demilestoned
149+ parseJSON (String " renamed" ) = pure Renamed
150+ parseJSON (String " locked" ) = pure Locked
151+ parseJSON (String " unlocked" ) = pure Unlocked
152+ parseJSON (String " head_ref_deleted" ) = pure HeadRefDeleted
153+ parseJSON (String " head_ref_restored" ) = pure HeadRefRestored
154+ parseJSON _ = fail " Could not build an EventType"
192155
193156instance FromJSON IssueLabel where
194- parseJSON = withObject " IssueLabel" $ \ o ->
195- IssueLabel <$> o .: " color"
196- <*> o .: " url"
197- <*> o .: " name"
157+ parseJSON = withObject " IssueLabel" $ \ o -> IssueLabel
158+ <$> o .: " color"
159+ <*> o .: " url"
160+ <*> o .: " name"
198161
199162instance FromJSON IssueComment where
200- parseJSON = withObject " IssueComment" $ \ o ->
201- IssueComment <$> o .: " updated_at"
202- <*> o .: " user"
203- <*> o .: " url"
204- <*> o .: " html_url"
205- <*> o .: " created_at"
206- <*> o .: " body"
207- <*> o .: " id"
163+ parseJSON = withObject " IssueComment" $ \ o -> IssueComment
164+ <$> o .: " updated_at"
165+ <*> o .: " user"
166+ <*> o .: " url"
167+ <*> o .: " html_url"
168+ <*> o .: " created_at"
169+ <*> o .: " body"
170+ <*> o .: " id"
208171
209172instance FromJSON Issue where
210173 parseJSON = withObject " Issue" $ \ o ->
@@ -246,16 +209,3 @@ instance ToJSON EditIssue where
246209 , " labels" .= ls ]
247210 where notNull (_, Null ) = False
248211 notNull (_, _) = True
249-
250- instance FromJSON Milestone where
251- parseJSON = withObject " Milestone" $ \ o ->
252- Milestone <$> o .: " creator"
253- <*> o .: " due_on"
254- <*> o .: " open_issues"
255- <*> o .: " number"
256- <*> o .: " closed_issues"
257- <*> o .: " description"
258- <*> o .: " title"
259- <*> o .: " url"
260- <*> o .: " created_at"
261- <*> o .: " state"
0 commit comments