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