module TD.Data.PageBlockListItem
(PageBlockListItem(..)) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
import qualified Data.Text as T
import {-# SOURCE #-} qualified TD.Data.PageBlock as PageBlock
data PageBlockListItem
= PageBlockListItem
{ PageBlockListItem -> Maybe Text
label :: Maybe T.Text
, PageBlockListItem -> Maybe [PageBlock]
page_blocks :: Maybe [PageBlock.PageBlock]
}
deriving (PageBlockListItem -> PageBlockListItem -> Bool
(PageBlockListItem -> PageBlockListItem -> Bool)
-> (PageBlockListItem -> PageBlockListItem -> Bool)
-> Eq PageBlockListItem
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PageBlockListItem -> PageBlockListItem -> Bool
== :: PageBlockListItem -> PageBlockListItem -> Bool
$c/= :: PageBlockListItem -> PageBlockListItem -> Bool
/= :: PageBlockListItem -> PageBlockListItem -> Bool
Eq, Int -> PageBlockListItem -> ShowS
[PageBlockListItem] -> ShowS
PageBlockListItem -> String
(Int -> PageBlockListItem -> ShowS)
-> (PageBlockListItem -> String)
-> ([PageBlockListItem] -> ShowS)
-> Show PageBlockListItem
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PageBlockListItem -> ShowS
showsPrec :: Int -> PageBlockListItem -> ShowS
$cshow :: PageBlockListItem -> String
show :: PageBlockListItem -> String
$cshowList :: [PageBlockListItem] -> ShowS
showList :: [PageBlockListItem] -> ShowS
Show)
instance I.ShortShow PageBlockListItem where
shortShow :: PageBlockListItem -> String
shortShow PageBlockListItem
{ label :: PageBlockListItem -> Maybe Text
label = Maybe Text
label_
, page_blocks :: PageBlockListItem -> Maybe [PageBlock]
page_blocks = Maybe [PageBlock]
page_blocks_
}
= String
"PageBlockListItem"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"label" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
label_
, String
"page_blocks" String -> Maybe [PageBlock] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [PageBlock]
page_blocks_
]
instance AT.FromJSON PageBlockListItem where
parseJSON :: Value -> Parser PageBlockListItem
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
"pageBlockListItem" -> Value -> Parser PageBlockListItem
parsePageBlockListItem Value
v
String
_ -> Parser PageBlockListItem
forall a. Monoid a => a
mempty
where
parsePageBlockListItem :: A.Value -> AT.Parser PageBlockListItem
parsePageBlockListItem :: Value -> Parser PageBlockListItem
parsePageBlockListItem = String
-> (Object -> Parser PageBlockListItem)
-> Value
-> Parser PageBlockListItem
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"PageBlockListItem" ((Object -> Parser PageBlockListItem)
-> Value -> Parser PageBlockListItem)
-> (Object -> Parser PageBlockListItem)
-> Value
-> Parser PageBlockListItem
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Text
label_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"label"
Maybe [PageBlock]
page_blocks_ <- Object
o Object -> Key -> Parser (Maybe [PageBlock])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"page_blocks"
PageBlockListItem -> Parser PageBlockListItem
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (PageBlockListItem -> Parser PageBlockListItem)
-> PageBlockListItem -> Parser PageBlockListItem
forall a b. (a -> b) -> a -> b
$ PageBlockListItem
{ label :: Maybe Text
label = Maybe Text
label_
, page_blocks :: Maybe [PageBlock]
page_blocks = Maybe [PageBlock]
page_blocks_
}
parseJSON Value
_ = Parser PageBlockListItem
forall a. Monoid a => a
mempty