{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards   #-}
{-# LANGUAGE StrictData        #-}
module GitHub.Types.Base.PageBuildError 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 (..))

------------------------------------------------------------------------------
-- PageBuildError

newtype PageBuildError = PageBuildError
    { PageBuildError -> Maybe Text
pageBuildErrorMessage :: Maybe Text
    } deriving (PageBuildError -> PageBuildError -> Bool
(PageBuildError -> PageBuildError -> Bool)
-> (PageBuildError -> PageBuildError -> Bool) -> Eq PageBuildError
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PageBuildError -> PageBuildError -> Bool
$c/= :: PageBuildError -> PageBuildError -> Bool
== :: PageBuildError -> PageBuildError -> Bool
$c== :: PageBuildError -> PageBuildError -> Bool
Eq, Int -> PageBuildError -> ShowS
[PageBuildError] -> ShowS
PageBuildError -> String
(Int -> PageBuildError -> ShowS)
-> (PageBuildError -> String)
-> ([PageBuildError] -> ShowS)
-> Show PageBuildError
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PageBuildError] -> ShowS
$cshowList :: [PageBuildError] -> ShowS
show :: PageBuildError -> String
$cshow :: PageBuildError -> String
showsPrec :: Int -> PageBuildError -> ShowS
$cshowsPrec :: Int -> PageBuildError -> ShowS
Show, ReadPrec [PageBuildError]
ReadPrec PageBuildError
Int -> ReadS PageBuildError
ReadS [PageBuildError]
(Int -> ReadS PageBuildError)
-> ReadS [PageBuildError]
-> ReadPrec PageBuildError
-> ReadPrec [PageBuildError]
-> Read PageBuildError
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PageBuildError]
$creadListPrec :: ReadPrec [PageBuildError]
readPrec :: ReadPrec PageBuildError
$creadPrec :: ReadPrec PageBuildError
readList :: ReadS [PageBuildError]
$creadList :: ReadS [PageBuildError]
readsPrec :: Int -> ReadS PageBuildError
$creadsPrec :: Int -> ReadS PageBuildError
Read)


instance FromJSON PageBuildError where
    parseJSON :: Value -> Parser PageBuildError
parseJSON (Object Object
x) = Maybe Text -> PageBuildError
PageBuildError
        (Maybe Text -> PageBuildError)
-> Parser (Maybe Text) -> Parser PageBuildError
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 a
.: Key
"message"

    parseJSON Value
_ = String -> Parser PageBuildError
forall (m :: * -> *) a. MonadFail m => String -> m a
fail String
"PageBuildError"


instance ToJSON PageBuildError where
    toJSON :: PageBuildError -> Value
toJSON PageBuildError{Maybe Text
pageBuildErrorMessage :: Maybe Text
pageBuildErrorMessage :: PageBuildError -> Maybe Text
..} = [Pair] -> Value
object
        [ Key
"message" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
.= Maybe Text
pageBuildErrorMessage
        ]


instance Arbitrary PageBuildError where
    arbitrary :: Gen PageBuildError
arbitrary = Maybe Text -> PageBuildError
PageBuildError
        (Maybe Text -> PageBuildError)
-> Gen (Maybe Text) -> Gen PageBuildError
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Gen (Maybe Text)
forall a. Arbitrary a => Gen a
arbitrary