module GitHub.Data.Reviews where
import GitHub.Data.Definitions (SimpleUser)
import GitHub.Data.Id (Id)
import GitHub.Data.URL (URL)
import GitHub.Internal.Prelude
import Prelude ()
import qualified Data.Text as T
data ReviewState
= ReviewStatePending
| ReviewStateApproved
| ReviewStateDismissed
|
| ReviewStateChangesRequested
deriving (Int -> ReviewState -> ShowS
[ReviewState] -> ShowS
ReviewState -> String
(Int -> ReviewState -> ShowS)
-> (ReviewState -> String)
-> ([ReviewState] -> ShowS)
-> Show ReviewState
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ReviewState] -> ShowS
$cshowList :: [ReviewState] -> ShowS
show :: ReviewState -> String
$cshow :: ReviewState -> String
showsPrec :: Int -> ReviewState -> ShowS
$cshowsPrec :: Int -> ReviewState -> ShowS
Show, Int -> ReviewState
ReviewState -> Int
ReviewState -> [ReviewState]
ReviewState -> ReviewState
ReviewState -> ReviewState -> [ReviewState]
ReviewState -> ReviewState -> ReviewState -> [ReviewState]
(ReviewState -> ReviewState)
-> (ReviewState -> ReviewState)
-> (Int -> ReviewState)
-> (ReviewState -> Int)
-> (ReviewState -> [ReviewState])
-> (ReviewState -> ReviewState -> [ReviewState])
-> (ReviewState -> ReviewState -> [ReviewState])
-> (ReviewState -> ReviewState -> ReviewState -> [ReviewState])
-> Enum ReviewState
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: ReviewState -> ReviewState -> ReviewState -> [ReviewState]
$cenumFromThenTo :: ReviewState -> ReviewState -> ReviewState -> [ReviewState]
enumFromTo :: ReviewState -> ReviewState -> [ReviewState]
$cenumFromTo :: ReviewState -> ReviewState -> [ReviewState]
enumFromThen :: ReviewState -> ReviewState -> [ReviewState]
$cenumFromThen :: ReviewState -> ReviewState -> [ReviewState]
enumFrom :: ReviewState -> [ReviewState]
$cenumFrom :: ReviewState -> [ReviewState]
fromEnum :: ReviewState -> Int
$cfromEnum :: ReviewState -> Int
toEnum :: Int -> ReviewState
$ctoEnum :: Int -> ReviewState
pred :: ReviewState -> ReviewState
$cpred :: ReviewState -> ReviewState
succ :: ReviewState -> ReviewState
$csucc :: ReviewState -> ReviewState
Enum, ReviewState
ReviewState -> ReviewState -> Bounded ReviewState
forall a. a -> a -> Bounded a
maxBound :: ReviewState
$cmaxBound :: ReviewState
minBound :: ReviewState
$cminBound :: ReviewState
Bounded, ReviewState -> ReviewState -> Bool
(ReviewState -> ReviewState -> Bool)
-> (ReviewState -> ReviewState -> Bool) -> Eq ReviewState
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ReviewState -> ReviewState -> Bool
$c/= :: ReviewState -> ReviewState -> Bool
== :: ReviewState -> ReviewState -> Bool
$c== :: ReviewState -> ReviewState -> Bool
Eq, Eq ReviewState
Eq ReviewState
-> (ReviewState -> ReviewState -> Ordering)
-> (ReviewState -> ReviewState -> Bool)
-> (ReviewState -> ReviewState -> Bool)
-> (ReviewState -> ReviewState -> Bool)
-> (ReviewState -> ReviewState -> Bool)
-> (ReviewState -> ReviewState -> ReviewState)
-> (ReviewState -> ReviewState -> ReviewState)
-> Ord ReviewState
ReviewState -> ReviewState -> Bool
ReviewState -> ReviewState -> Ordering
ReviewState -> ReviewState -> ReviewState
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: ReviewState -> ReviewState -> ReviewState
$cmin :: ReviewState -> ReviewState -> ReviewState
max :: ReviewState -> ReviewState -> ReviewState
$cmax :: ReviewState -> ReviewState -> ReviewState
>= :: ReviewState -> ReviewState -> Bool
$c>= :: ReviewState -> ReviewState -> Bool
> :: ReviewState -> ReviewState -> Bool
$c> :: ReviewState -> ReviewState -> Bool
<= :: ReviewState -> ReviewState -> Bool
$c<= :: ReviewState -> ReviewState -> Bool
< :: ReviewState -> ReviewState -> Bool
$c< :: ReviewState -> ReviewState -> Bool
compare :: ReviewState -> ReviewState -> Ordering
$ccompare :: ReviewState -> ReviewState -> Ordering
Ord, (forall x. ReviewState -> Rep ReviewState x)
-> (forall x. Rep ReviewState x -> ReviewState)
-> Generic ReviewState
forall x. Rep ReviewState x -> ReviewState
forall x. ReviewState -> Rep ReviewState x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ReviewState x -> ReviewState
$cfrom :: forall x. ReviewState -> Rep ReviewState x
Generic)
instance NFData ReviewState where
rnf :: ReviewState -> ()
rnf = ReviewState -> ()
forall a. (Generic a, GNFData (Rep a)) => a -> ()
genericRnf
instance Binary ReviewState
instance FromJSON ReviewState where
parseJSON :: Value -> Parser ReviewState
parseJSON = String
-> (Text -> Parser ReviewState) -> Value -> Parser ReviewState
forall a. String -> (Text -> Parser a) -> Value -> Parser a
withText String
"ReviewState" ((Text -> Parser ReviewState) -> Value -> Parser ReviewState)
-> (Text -> Parser ReviewState) -> Value -> Parser ReviewState
forall a b. (a -> b) -> a -> b
$ \Text
t -> case Text -> Text
T.toLower Text
t of
Text
"approved" -> ReviewState -> Parser ReviewState
forall (f :: * -> *) a. Applicative f => a -> f a
pure ReviewState
ReviewStateApproved
Text
"pending" -> ReviewState -> Parser ReviewState
forall (f :: * -> *) a. Applicative f => a -> f a
pure ReviewState
ReviewStatePending
Text
"dismissed" -> ReviewState -> Parser ReviewState
forall (f :: * -> *) a. Applicative f => a -> f a
pure ReviewState
ReviewStateDismissed
Text
"commented" -> ReviewState -> Parser ReviewState
forall (f :: * -> *) a. Applicative f => a -> f a
pure ReviewState
ReviewStateCommented
Text
"changes_requested" -> ReviewState -> Parser ReviewState
forall (f :: * -> *) a. Applicative f => a -> f a
pure ReviewState
ReviewStateChangesRequested
Text
_ -> String -> Parser ReviewState
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Parser ReviewState) -> String -> Parser ReviewState
forall a b. (a -> b) -> a -> b
$ String
"Unknown ReviewState: " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Text -> String
T.unpack Text
t
data Review = Review
{ Review -> Text
reviewBody :: !Text
, Review -> Text
reviewCommitId :: !Text
, Review -> ReviewState
reviewState :: ReviewState
, Review -> Maybe UTCTime
reviewSubmittedAt :: !(Maybe UTCTime)
, Review -> URL
reviewPullRequestUrl :: !URL
, Review -> Text
reviewHtmlUrl :: !Text
, Review -> SimpleUser
reviewUser :: !SimpleUser
, Review -> Id Review
reviewId :: !(Id Review)
} deriving (Int -> Review -> ShowS
[Review] -> ShowS
Review -> String
(Int -> Review -> ShowS)
-> (Review -> String) -> ([Review] -> ShowS) -> Show Review
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Review] -> ShowS
$cshowList :: [Review] -> ShowS
show :: Review -> String
$cshow :: Review -> String
showsPrec :: Int -> Review -> ShowS
$cshowsPrec :: Int -> Review -> ShowS
Show, (forall x. Review -> Rep Review x)
-> (forall x. Rep Review x -> Review) -> Generic Review
forall x. Rep Review x -> Review
forall x. Review -> Rep Review x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Review x -> Review
$cfrom :: forall x. Review -> Rep Review x
Generic)
instance NFData Review where
rnf :: Review -> ()
rnf = Review -> ()
forall a. (Generic a, GNFData (Rep a)) => a -> ()
genericRnf
instance Binary Review
instance FromJSON Review where
parseJSON :: Value -> Parser Review
parseJSON =
String -> (Object -> Parser Review) -> Value -> Parser Review
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"Review" ((Object -> Parser Review) -> Value -> Parser Review)
-> (Object -> Parser Review) -> Value -> Parser Review
forall a b. (a -> b) -> a -> b
$ \Object
o ->
Text
-> Text
-> ReviewState
-> Maybe UTCTime
-> URL
-> Text
-> SimpleUser
-> Id Review
-> Review
Review (Text
-> Text
-> ReviewState
-> Maybe UTCTime
-> URL
-> Text
-> SimpleUser
-> Id Review
-> Review)
-> Parser Text
-> Parser
(Text
-> ReviewState
-> Maybe UTCTime
-> URL
-> Text
-> SimpleUser
-> Id Review
-> Review)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Key -> Parser Text
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"body" Parser
(Text
-> ReviewState
-> Maybe UTCTime
-> URL
-> Text
-> SimpleUser
-> Id Review
-> Review)
-> Parser Text
-> Parser
(ReviewState
-> Maybe UTCTime
-> URL
-> Text
-> SimpleUser
-> Id Review
-> Review)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Key -> Parser Text
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"commit_id" Parser
(ReviewState
-> Maybe UTCTime
-> URL
-> Text
-> SimpleUser
-> Id Review
-> Review)
-> Parser ReviewState
-> Parser
(Maybe UTCTime -> URL -> Text -> SimpleUser -> Id Review -> Review)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Key -> Parser ReviewState
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"state" Parser
(Maybe UTCTime -> URL -> Text -> SimpleUser -> Id Review -> Review)
-> Parser (Maybe UTCTime)
-> Parser (URL -> Text -> SimpleUser -> Id Review -> Review)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
Object
o Object -> Key -> Parser (Maybe UTCTime)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"submitted_at" Parser (URL -> Text -> SimpleUser -> Id Review -> Review)
-> Parser URL -> Parser (Text -> SimpleUser -> Id Review -> Review)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
Object
o Object -> Key -> Parser URL
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"pull_request_url" Parser (Text -> SimpleUser -> Id Review -> Review)
-> Parser Text -> Parser (SimpleUser -> Id Review -> Review)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
Object
o Object -> Key -> Parser Text
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"html_url" Parser (SimpleUser -> Id Review -> Review)
-> Parser SimpleUser -> Parser (Id Review -> Review)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
Object
o Object -> Key -> Parser SimpleUser
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"user" Parser (Id Review -> Review) -> Parser (Id Review) -> Parser Review
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*>
Object
o Object -> Key -> Parser (Id Review)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"id"
data =
{ :: !(Id ReviewComment)
, :: !SimpleUser
, ReviewComment -> Text
reviewCommentBody :: !Text
, :: !URL
, :: !(Id Review)
, :: !Text
, :: !Text
, :: !Int
, :: !Int
, :: !Text
, :: !Text
, :: !UTCTime
, :: !UTCTime
, :: !URL
, :: !URL
} deriving (Int -> ReviewComment -> ShowS
[ReviewComment] -> ShowS
ReviewComment -> String
(Int -> ReviewComment -> ShowS)
-> (ReviewComment -> String)
-> ([ReviewComment] -> ShowS)
-> Show ReviewComment
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ReviewComment] -> ShowS
$cshowList :: [ReviewComment] -> ShowS
show :: ReviewComment -> String
$cshow :: ReviewComment -> String
showsPrec :: Int -> ReviewComment -> ShowS
$cshowsPrec :: Int -> ReviewComment -> ShowS
Show, (forall x. ReviewComment -> Rep ReviewComment x)
-> (forall x. Rep ReviewComment x -> ReviewComment)
-> Generic ReviewComment
forall x. Rep ReviewComment x -> ReviewComment
forall x. ReviewComment -> Rep ReviewComment x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ReviewComment x -> ReviewComment
$cfrom :: forall x. ReviewComment -> Rep ReviewComment x
Generic)
instance NFData ReviewComment where
rnf :: ReviewComment -> ()
rnf = ReviewComment -> ()
forall a. (Generic a, GNFData (Rep a)) => a -> ()
genericRnf
instance Binary ReviewComment
instance FromJSON ReviewComment where
parseJSON :: Value -> Parser ReviewComment
parseJSON =
String
-> (Object -> Parser ReviewComment)
-> Value
-> Parser ReviewComment
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject String
"ReviewComment" ((Object -> Parser ReviewComment) -> Value -> Parser ReviewComment)
-> (Object -> Parser ReviewComment)
-> Value
-> Parser ReviewComment
forall a b. (a -> b) -> a -> b
$ \Object
o -> Id ReviewComment
-> SimpleUser
-> Text
-> URL
-> Id Review
-> Text
-> Text
-> Int
-> Int
-> Text
-> Text
-> UTCTime
-> UTCTime
-> URL
-> URL
-> ReviewComment
ReviewComment
(Id ReviewComment
-> SimpleUser
-> Text
-> URL
-> Id Review
-> Text
-> Text
-> Int
-> Int
-> Text
-> Text
-> UTCTime
-> UTCTime
-> URL
-> URL
-> ReviewComment)
-> Parser (Id ReviewComment)
-> Parser
(SimpleUser
-> Text
-> URL
-> Id Review
-> Text
-> Text
-> Int
-> Int
-> Text
-> Text
-> UTCTime
-> UTCTime
-> URL
-> URL
-> ReviewComment)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
o Object -> Key -> Parser (Id ReviewComment)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"id"
Parser
(SimpleUser
-> Text
-> URL
-> Id Review
-> Text
-> Text
-> Int
-> Int
-> Text
-> Text
-> UTCTime
-> UTCTime
-> URL
-> URL
-> ReviewComment)
-> Parser SimpleUser
-> Parser
(Text
-> URL
-> Id Review
-> Text
-> Text
-> Int
-> Int
-> Text
-> Text
-> UTCTime
-> UTCTime
-> URL
-> URL
-> ReviewComment)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Key -> Parser SimpleUser
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"user"
Parser
(Text
-> URL
-> Id Review
-> Text
-> Text
-> Int
-> Int
-> Text
-> Text
-> UTCTime
-> UTCTime
-> URL
-> URL
-> ReviewComment)
-> Parser Text
-> Parser
(URL
-> Id Review
-> Text
-> Text
-> Int
-> Int
-> Text
-> Text
-> UTCTime
-> UTCTime
-> URL
-> URL
-> ReviewComment)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Key -> Parser Text
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"body"
Parser
(URL
-> Id Review
-> Text
-> Text
-> Int
-> Int
-> Text
-> Text
-> UTCTime
-> UTCTime
-> URL
-> URL
-> ReviewComment)
-> Parser URL
-> Parser
(Id Review
-> Text
-> Text
-> Int
-> Int
-> Text
-> Text
-> UTCTime
-> UTCTime
-> URL
-> URL
-> ReviewComment)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Key -> Parser URL
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"url"
Parser
(Id Review
-> Text
-> Text
-> Int
-> Int
-> Text
-> Text
-> UTCTime
-> UTCTime
-> URL
-> URL
-> ReviewComment)
-> Parser (Id Review)
-> Parser
(Text
-> Text
-> Int
-> Int
-> Text
-> Text
-> UTCTime
-> UTCTime
-> URL
-> URL
-> ReviewComment)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Key -> Parser (Id Review)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"pull_request_review_id"
Parser
(Text
-> Text
-> Int
-> Int
-> Text
-> Text
-> UTCTime
-> UTCTime
-> URL
-> URL
-> ReviewComment)
-> Parser Text
-> Parser
(Text
-> Int
-> Int
-> Text
-> Text
-> UTCTime
-> UTCTime
-> URL
-> URL
-> ReviewComment)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Key -> Parser Text
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"diff_hunk"
Parser
(Text
-> Int
-> Int
-> Text
-> Text
-> UTCTime
-> UTCTime
-> URL
-> URL
-> ReviewComment)
-> Parser Text
-> Parser
(Int
-> Int
-> Text
-> Text
-> UTCTime
-> UTCTime
-> URL
-> URL
-> ReviewComment)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Key -> Parser Text
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"path"
Parser
(Int
-> Int
-> Text
-> Text
-> UTCTime
-> UTCTime
-> URL
-> URL
-> ReviewComment)
-> Parser Int
-> Parser
(Int
-> Text
-> Text
-> UTCTime
-> UTCTime
-> URL
-> URL
-> ReviewComment)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Key -> Parser Int
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"position"
Parser
(Int
-> Text
-> Text
-> UTCTime
-> UTCTime
-> URL
-> URL
-> ReviewComment)
-> Parser Int
-> Parser
(Text -> Text -> UTCTime -> UTCTime -> URL -> URL -> ReviewComment)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Key -> Parser Int
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"original_position"
Parser
(Text -> Text -> UTCTime -> UTCTime -> URL -> URL -> ReviewComment)
-> Parser Text
-> Parser
(Text -> UTCTime -> UTCTime -> URL -> URL -> ReviewComment)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Key -> Parser Text
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"commit_id"
Parser (Text -> UTCTime -> UTCTime -> URL -> URL -> ReviewComment)
-> Parser Text
-> Parser (UTCTime -> UTCTime -> URL -> URL -> ReviewComment)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Key -> Parser Text
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"original_commit_id"
Parser (UTCTime -> UTCTime -> URL -> URL -> ReviewComment)
-> Parser UTCTime
-> Parser (UTCTime -> URL -> URL -> ReviewComment)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Key -> Parser UTCTime
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"created_at"
Parser (UTCTime -> URL -> URL -> ReviewComment)
-> Parser UTCTime -> Parser (URL -> URL -> ReviewComment)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Key -> Parser UTCTime
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"updated_at"
Parser (URL -> URL -> ReviewComment)
-> Parser URL -> Parser (URL -> ReviewComment)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Key -> Parser URL
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"html_url"
Parser (URL -> ReviewComment) -> Parser URL -> Parser ReviewComment
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
o Object -> Key -> Parser URL
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"pull_request_url"