module TD.Data.PageBlockCaption
(PageBlockCaption(..)) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
import qualified TD.Data.RichText as RichText
data PageBlockCaption
= PageBlockCaption
{ PageBlockCaption -> Maybe RichText
text :: Maybe RichText.RichText
, PageBlockCaption -> Maybe RichText
credit :: Maybe RichText.RichText
}
deriving (PageBlockCaption -> PageBlockCaption -> Bool
(PageBlockCaption -> PageBlockCaption -> Bool)
-> (PageBlockCaption -> PageBlockCaption -> Bool)
-> Eq PageBlockCaption
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PageBlockCaption -> PageBlockCaption -> Bool
== :: PageBlockCaption -> PageBlockCaption -> Bool
$c/= :: PageBlockCaption -> PageBlockCaption -> Bool
/= :: PageBlockCaption -> PageBlockCaption -> Bool
Eq, Int -> PageBlockCaption -> ShowS
[PageBlockCaption] -> ShowS
PageBlockCaption -> String
(Int -> PageBlockCaption -> ShowS)
-> (PageBlockCaption -> String)
-> ([PageBlockCaption] -> ShowS)
-> Show PageBlockCaption
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PageBlockCaption -> ShowS
showsPrec :: Int -> PageBlockCaption -> ShowS
$cshow :: PageBlockCaption -> String
show :: PageBlockCaption -> String
$cshowList :: [PageBlockCaption] -> ShowS
showList :: [PageBlockCaption] -> ShowS
Show)
instance I.ShortShow PageBlockCaption where
shortShow :: PageBlockCaption -> String
shortShow PageBlockCaption
{ text :: PageBlockCaption -> Maybe RichText
text = Maybe RichText
text_
, credit :: PageBlockCaption -> Maybe RichText
credit = Maybe RichText
credit_
}
= String
"PageBlockCaption"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"text" String -> Maybe RichText -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe RichText
text_
, String
"credit" String -> Maybe RichText -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe RichText
credit_
]
instance AT.FromJSON PageBlockCaption where
parseJSON :: Value -> Parser PageBlockCaption
parseJSON v :: Value
v@(AT.Object Object
obj) = do
String
t <- Object
obj Object -> Key -> Parser String
forall a. FromJSON a => Object -> Key -> Parser a
A..: Key
"@type" :: AT.Parser String
case String
t of
String
"pageBlockCaption" -> Value -> Parser PageBlockCaption
parsePageBlockCaption Value
v
String
_ -> Parser PageBlockCaption
forall a. Monoid a => a
mempty
where
parsePageBlockCaption :: A.Value -> AT.Parser PageBlockCaption
parsePageBlockCaption :: Value -> Parser PageBlockCaption
parsePageBlockCaption = String
-> (Object -> Parser PageBlockCaption)
-> Value
-> Parser PageBlockCaption
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"PageBlockCaption" ((Object -> Parser PageBlockCaption)
-> Value -> Parser PageBlockCaption)
-> (Object -> Parser PageBlockCaption)
-> Value
-> Parser PageBlockCaption
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe RichText
text_ <- Object
o Object -> Key -> Parser (Maybe RichText)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"text"
Maybe RichText
credit_ <- Object
o Object -> Key -> Parser (Maybe RichText)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"credit"
PageBlockCaption -> Parser PageBlockCaption
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (PageBlockCaption -> Parser PageBlockCaption)
-> PageBlockCaption -> Parser PageBlockCaption
forall a b. (a -> b) -> a -> b
$ PageBlockCaption
{ text :: Maybe RichText
text = Maybe RichText
text_
, credit :: Maybe RichText
credit = Maybe RichText
credit_
}
parseJSON Value
_ = Parser PageBlockCaption
forall a. Monoid a => a
mempty