Skip to content

Commit d3eff41

Browse files
committed
Add data type for new milestone
1 parent 2553802 commit d3eff41

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

src/GitHub/Data/Milestone.hs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,26 @@ instance FromJSON Milestone where
4040
<*> o .: "url"
4141
<*> o .: "created_at"
4242
<*> o .: "state"
43+
44+
data NewMilestone = NewMilestone
45+
{ newMilestoneTitle :: !Text
46+
, newMilestoneState :: !Text
47+
, newMilestoneDescription :: !(Maybe Text)
48+
, newMilestoneDueOn :: !(Maybe UTCTime)
49+
}
50+
deriving (Show, Data, Typeable, Eq, Ord, Generic)
51+
52+
instance NFData NewMilestone where rnf = genericRnf
53+
instance Binary NewMilestone
54+
55+
56+
instance ToJSON NewMilestone where
57+
toJSON (NewMilestone title state desc due) = object $ filter notNull
58+
[ "title" .= title
59+
, "state" .= state
60+
, "description" .= desc
61+
, "due_on" .= due
62+
]
63+
where
64+
notNull (_, Null) = False
65+
notNull (_, _) = True

0 commit comments

Comments
 (0)