module TD.Data.InputPageBlockListItem
( InputPageBlockListItem(..)
, defaultInputPageBlockListItem
) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
import {-# SOURCE #-} qualified TD.Data.InputPageBlock as InputPageBlock
import qualified Data.Text as T
data InputPageBlockListItem
= InputPageBlockListItem
{ InputPageBlockListItem -> Maybe [InputPageBlock]
blocks :: Maybe [InputPageBlock.InputPageBlock]
, InputPageBlockListItem -> Maybe Bool
has_checkbox :: Maybe Bool
, InputPageBlockListItem -> Maybe Bool
is_checked :: Maybe Bool
, InputPageBlockListItem -> Maybe Int
value :: Maybe Int
, InputPageBlockListItem -> Maybe Text
_type :: Maybe T.Text
}
deriving (InputPageBlockListItem -> InputPageBlockListItem -> Bool
(InputPageBlockListItem -> InputPageBlockListItem -> Bool)
-> (InputPageBlockListItem -> InputPageBlockListItem -> Bool)
-> Eq InputPageBlockListItem
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: InputPageBlockListItem -> InputPageBlockListItem -> Bool
== :: InputPageBlockListItem -> InputPageBlockListItem -> Bool
$c/= :: InputPageBlockListItem -> InputPageBlockListItem -> Bool
/= :: InputPageBlockListItem -> InputPageBlockListItem -> Bool
Eq, Int -> InputPageBlockListItem -> ShowS
[InputPageBlockListItem] -> ShowS
InputPageBlockListItem -> String
(Int -> InputPageBlockListItem -> ShowS)
-> (InputPageBlockListItem -> String)
-> ([InputPageBlockListItem] -> ShowS)
-> Show InputPageBlockListItem
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> InputPageBlockListItem -> ShowS
showsPrec :: Int -> InputPageBlockListItem -> ShowS
$cshow :: InputPageBlockListItem -> String
show :: InputPageBlockListItem -> String
$cshowList :: [InputPageBlockListItem] -> ShowS
showList :: [InputPageBlockListItem] -> ShowS
Show)
instance I.ShortShow InputPageBlockListItem where
shortShow :: InputPageBlockListItem -> String
shortShow InputPageBlockListItem
{ blocks :: InputPageBlockListItem -> Maybe [InputPageBlock]
blocks = Maybe [InputPageBlock]
blocks_
, has_checkbox :: InputPageBlockListItem -> Maybe Bool
has_checkbox = Maybe Bool
has_checkbox_
, is_checked :: InputPageBlockListItem -> Maybe Bool
is_checked = Maybe Bool
is_checked_
, value :: InputPageBlockListItem -> Maybe Int
value = Maybe Int
value_
, _type :: InputPageBlockListItem -> Maybe Text
_type = Maybe Text
_type_
}
= String
"InputPageBlockListItem"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"blocks" String -> Maybe [InputPageBlock] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [InputPageBlock]
blocks_
, String
"has_checkbox" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
has_checkbox_
, String
"is_checked" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_checked_
, String
"value" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
value_
, String
"_type" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
_type_
]
instance AT.FromJSON InputPageBlockListItem where
parseJSON :: Value -> Parser InputPageBlockListItem
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
"inputPageBlockListItem" -> Value -> Parser InputPageBlockListItem
parseInputPageBlockListItem Value
v
String
_ -> Parser InputPageBlockListItem
forall a. Monoid a => a
mempty
where
parseInputPageBlockListItem :: A.Value -> AT.Parser InputPageBlockListItem
parseInputPageBlockListItem :: Value -> Parser InputPageBlockListItem
parseInputPageBlockListItem = String
-> (Object -> Parser InputPageBlockListItem)
-> Value
-> Parser InputPageBlockListItem
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"InputPageBlockListItem" ((Object -> Parser InputPageBlockListItem)
-> Value -> Parser InputPageBlockListItem)
-> (Object -> Parser InputPageBlockListItem)
-> Value
-> Parser InputPageBlockListItem
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe [InputPageBlock]
blocks_ <- Object
o Object -> Key -> Parser (Maybe [InputPageBlock])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"blocks"
Maybe Bool
has_checkbox_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"has_checkbox"
Maybe Bool
is_checked_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_checked"
Maybe Int
value_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"value"
Maybe Text
_type_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"type"
InputPageBlockListItem -> Parser InputPageBlockListItem
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (InputPageBlockListItem -> Parser InputPageBlockListItem)
-> InputPageBlockListItem -> Parser InputPageBlockListItem
forall a b. (a -> b) -> a -> b
$ InputPageBlockListItem
{ blocks :: Maybe [InputPageBlock]
blocks = Maybe [InputPageBlock]
blocks_
, has_checkbox :: Maybe Bool
has_checkbox = Maybe Bool
has_checkbox_
, is_checked :: Maybe Bool
is_checked = Maybe Bool
is_checked_
, value :: Maybe Int
value = Maybe Int
value_
, _type :: Maybe Text
_type = Maybe Text
_type_
}
parseJSON Value
_ = Parser InputPageBlockListItem
forall a. Monoid a => a
mempty
instance AT.ToJSON InputPageBlockListItem where
toJSON :: InputPageBlockListItem -> Value
toJSON InputPageBlockListItem
{ blocks :: InputPageBlockListItem -> Maybe [InputPageBlock]
blocks = Maybe [InputPageBlock]
blocks_
, has_checkbox :: InputPageBlockListItem -> Maybe Bool
has_checkbox = Maybe Bool
has_checkbox_
, is_checked :: InputPageBlockListItem -> Maybe Bool
is_checked = Maybe Bool
is_checked_
, value :: InputPageBlockListItem -> Maybe Int
value = Maybe Int
value_
, _type :: InputPageBlockListItem -> Maybe Text
_type = Maybe Text
_type_
}
= [Pair] -> Value
A.object
[ Key
"@type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
AT.String Text
"inputPageBlockListItem"
, Key
"blocks" Key -> Maybe [InputPageBlock] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe [InputPageBlock]
blocks_
, Key
"has_checkbox" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
has_checkbox_
, Key
"is_checked" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
is_checked_
, Key
"value" Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
value_
, Key
"type" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
_type_
]
defaultInputPageBlockListItem :: InputPageBlockListItem
defaultInputPageBlockListItem :: InputPageBlockListItem
defaultInputPageBlockListItem =
InputPageBlockListItem
{ blocks :: Maybe [InputPageBlock]
blocks = Maybe [InputPageBlock]
forall a. Maybe a
Nothing
, has_checkbox :: Maybe Bool
has_checkbox = Maybe Bool
forall a. Maybe a
Nothing
, is_checked :: Maybe Bool
is_checked = Maybe Bool
forall a. Maybe a
Nothing
, value :: Maybe Int
value = Maybe Int
forall a. Maybe a
Nothing
, _type :: Maybe Text
_type = Maybe Text
forall a. Maybe a
Nothing
}