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