forked from haskell-github/github
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComments.hs
More file actions
97 lines (81 loc) · 2.69 KB
/
Copy pathComments.hs
File metadata and controls
97 lines (81 loc) · 2.69 KB
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
-----------------------------------------------------------------------------
-- |
-- License : BSD-3-Clause
-- Maintainer : Oleg Grenrus <oleg.grenrus@iki.fi>
--
module GitHub.Data.Comments where
import GitHub.Data.Definitions
import GitHub.Data.Id (Id)
import GitHub.Data.URL (URL)
import GitHub.Internal.Prelude
import Prelude ()
data Comment = Comment
{ commentPosition :: !(Maybe Int)
, commentLine :: !(Maybe Int)
, commentBody :: !Text
, commentCommitId :: !(Maybe Text)
, commentUpdatedAt :: !UTCTime
, commentHtmlUrl :: !(Maybe URL)
, commentUrl :: !URL
, commentCreatedAt :: !(Maybe UTCTime)
, commentPath :: !(Maybe Text)
, commentUser :: !SimpleUser
, commentId :: !(Id Comment)
}
deriving (Show, Data, Typeable, Eq, Ord, Generic)
instance NFData Comment where rnf = genericRnf
instance Binary Comment
instance FromJSON Comment where
parseJSON = withObject "Comment" $ \o -> Comment
<$> o .:? "position"
<*> o .:? "line"
<*> o .: "body"
<*> o .:? "commit_id"
<*> o .: "updated_at"
<*> o .:? "html_url"
<*> o .: "url"
<*> o .: "created_at"
<*> o .:? "path"
<*> o .: "user"
<*> o .: "id"
data NewComment = NewComment
{ newCommentBody :: !Text
}
deriving (Show, Data, Typeable, Eq, Ord, Generic)
instance NFData NewComment where rnf = genericRnf
instance Binary NewComment
instance ToJSON NewComment where
toJSON (NewComment b) = object [ "body" .= b ]
data EditComment = EditComment
{ editCommentBody :: !Text
}
deriving (Show, Data, Typeable, Eq, Ord, Generic)
instance NFData EditComment where rnf = genericRnf
instance Binary EditComment
instance ToJSON EditComment where
toJSON (EditComment b) = object [ "body" .= b ]
data NewPullComment = NewPullComment
{ newPullCommentCommit :: !Text
, newPullCommentPath :: !Text
, newPullCommentPosition :: !Int
, newPullCommentBody :: !Text
}
deriving (Show, Data, Typeable, Eq, Ord, Generic)
instance NFData NewPullComment where rnf = genericRnf
instance Binary NewPullComment
instance ToJSON NewPullComment where
toJSON (NewPullComment c path pos b) =
object [ "body" .= b
, "commit_id" .= c
, "path" .= path
, "position" .= pos
]
data PullCommentReply = PullCommentReply
{ pullCommentReplyBody :: Text
}
deriving (Show, Data, Typeable, Eq, Ord, Generic)
instance NFData PullCommentReply where rnf = genericRnf
instance ToJSON PullCommentReply where
toJSON (PullCommentReply b) =
object [ "body" .= b
]