{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
module GitHub.Types.Base.CheckPullRequest where
import Data.Aeson (FromJSON (..), ToJSON (..),
object)
import Data.Aeson.Types (Value (..), (.:), (.=))
import Data.Text (Text)
import Test.QuickCheck.Arbitrary (Arbitrary (..))
import GitHub.Types.Base.CheckCommitRef
data CheckPullRequest = CheckPullRequest
{ CheckPullRequest -> CheckCommitRef
checkPullRequestBase :: CheckCommitRef
, CheckPullRequest -> CheckCommitRef
checkPullRequestHead :: CheckCommitRef
, CheckPullRequest -> Int
checkPullRequestId :: Int
, CheckPullRequest -> Int
checkPullRequestNumber :: Int
, CheckPullRequest -> Text
checkPullRequestUrl :: Text
} deriving (CheckPullRequest -> CheckPullRequest -> Bool
(CheckPullRequest -> CheckPullRequest -> Bool)
-> (CheckPullRequest -> CheckPullRequest -> Bool)
-> Eq CheckPullRequest
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CheckPullRequest -> CheckPullRequest -> Bool
$c/= :: CheckPullRequest -> CheckPullRequest -> Bool
== :: CheckPullRequest -> CheckPullRequest -> Bool
$c== :: CheckPullRequest -> CheckPullRequest -> Bool
Eq, Int -> CheckPullRequest -> ShowS
[CheckPullRequest] -> ShowS
CheckPullRequest -> String
(Int -> CheckPullRequest -> ShowS)
-> (CheckPullRequest -> String)
-> ([CheckPullRequest] -> ShowS)
-> Show CheckPullRequest
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CheckPullRequest] -> ShowS
$cshowList :: [CheckPullRequest] -> ShowS
show :: CheckPullRequest -> String
$cshow :: CheckPullRequest -> String
showsPrec :: Int -> CheckPullRequest -> ShowS
$cshowsPrec :: Int -> CheckPullRequest -> ShowS
Show, ReadPrec [CheckPullRequest]
ReadPrec CheckPullRequest
Int -> ReadS CheckPullRequest
ReadS [CheckPullRequest]
(Int -> ReadS CheckPullRequest)
-> ReadS [CheckPullRequest]
-> ReadPrec CheckPullRequest
-> ReadPrec [CheckPullRequest]
-> Read CheckPullRequest
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CheckPullRequest]
$creadListPrec :: ReadPrec [CheckPullRequest]
readPrec :: ReadPrec CheckPullRequest
$creadPrec :: ReadPrec CheckPullRequest
readList :: ReadS [CheckPullRequest]
$creadList :: ReadS [CheckPullRequest]
readsPrec :: Int -> ReadS CheckPullRequest
$creadsPrec :: Int -> ReadS CheckPullRequest
Read)
instance FromJSON CheckPullRequest where
parseJSON :: Value -> Parser CheckPullRequest
parseJSON (Object Object
x) = CheckCommitRef
-> CheckCommitRef -> Int -> Int -> Text -> CheckPullRequest
CheckPullRequest
(CheckCommitRef
-> CheckCommitRef -> Int -> Int -> Text -> CheckPullRequest)
-> Parser CheckCommitRef
-> Parser
(CheckCommitRef -> Int -> Int -> Text -> CheckPullRequest)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
x Object -> Key -> Parser CheckCommitRef
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"base"
Parser (CheckCommitRef -> Int -> Int -> Text -> CheckPullRequest)
-> Parser CheckCommitRef
-> Parser (Int -> Int -> Text -> CheckPullRequest)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
x Object -> Key -> Parser CheckCommitRef
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"head"
Parser (Int -> Int -> Text -> CheckPullRequest)
-> Parser Int -> Parser (Int -> Text -> CheckPullRequest)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
x Object -> Key -> Parser Int
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"id"
Parser (Int -> Text -> CheckPullRequest)
-> Parser Int -> Parser (Text -> CheckPullRequest)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
x Object -> Key -> Parser Int
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"number"
Parser (Text -> CheckPullRequest)
-> Parser Text -> Parser CheckPullRequest
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
x Object -> Key -> Parser Text
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"url"
parseJSON Value
_ = String -> Parser CheckPullRequest
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"CheckPullRequest"
instance ToJSON CheckPullRequest where
toJSON :: CheckPullRequest -> Value
toJSON CheckPullRequest{Int
Text
CheckCommitRef
checkPullRequestUrl :: Text
checkPullRequestNumber :: Int
checkPullRequestId :: Int
checkPullRequestHead :: CheckCommitRef
checkPullRequestBase :: CheckCommitRef
checkPullRequestUrl :: CheckPullRequest -> Text
checkPullRequestNumber :: CheckPullRequest -> Int
checkPullRequestId :: CheckPullRequest -> Int
checkPullRequestHead :: CheckPullRequest -> CheckCommitRef
checkPullRequestBase :: CheckPullRequest -> CheckCommitRef
..} = [Pair] -> Value
object
[ Key
"base" Key -> CheckCommitRef -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= CheckCommitRef
checkPullRequestBase
, Key
"head" Key -> CheckCommitRef -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= CheckCommitRef
checkPullRequestHead
, Key
"id" Key -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
checkPullRequestId
, Key
"number" Key -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Int
checkPullRequestNumber
, Key
"url" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Text
checkPullRequestUrl
]
instance Arbitrary CheckPullRequest where
arbitrary :: Gen CheckPullRequest
arbitrary = CheckCommitRef
-> CheckCommitRef -> Int -> Int -> Text -> CheckPullRequest
CheckPullRequest
(CheckCommitRef
-> CheckCommitRef -> Int -> Int -> Text -> CheckPullRequest)
-> Gen CheckCommitRef
-> Gen (CheckCommitRef -> Int -> Int -> Text -> CheckPullRequest)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen CheckCommitRef
forall a. Arbitrary a => Gen a
arbitrary
Gen (CheckCommitRef -> Int -> Int -> Text -> CheckPullRequest)
-> Gen CheckCommitRef
-> Gen (Int -> Int -> Text -> CheckPullRequest)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen CheckCommitRef
forall a. Arbitrary a => Gen a
arbitrary
Gen (Int -> Int -> Text -> CheckPullRequest)
-> Gen Int -> Gen (Int -> Text -> CheckPullRequest)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Int
forall a. Arbitrary a => Gen a
arbitrary
Gen (Int -> Text -> CheckPullRequest)
-> Gen Int -> Gen (Text -> CheckPullRequest)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Int
forall a. Arbitrary a => Gen a
arbitrary
Gen (Text -> CheckPullRequest) -> Gen Text -> Gen CheckPullRequest
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Gen Text
forall a. Arbitrary a => Gen a
arbitrary