module TD.Data.PollOptionProperties
(PollOptionProperties(..)) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
data PollOptionProperties
= PollOptionProperties
{ PollOptionProperties -> Maybe Bool
can_be_deleted :: Maybe Bool
, PollOptionProperties -> Maybe Bool
can_be_replied :: Maybe Bool
, PollOptionProperties -> Maybe Bool
can_be_replied_in_another_chat :: Maybe Bool
, PollOptionProperties -> Maybe Bool
can_get_link :: Maybe Bool
}
deriving (PollOptionProperties -> PollOptionProperties -> Bool
(PollOptionProperties -> PollOptionProperties -> Bool)
-> (PollOptionProperties -> PollOptionProperties -> Bool)
-> Eq PollOptionProperties
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PollOptionProperties -> PollOptionProperties -> Bool
== :: PollOptionProperties -> PollOptionProperties -> Bool
$c/= :: PollOptionProperties -> PollOptionProperties -> Bool
/= :: PollOptionProperties -> PollOptionProperties -> Bool
Eq, Int -> PollOptionProperties -> ShowS
[PollOptionProperties] -> ShowS
PollOptionProperties -> String
(Int -> PollOptionProperties -> ShowS)
-> (PollOptionProperties -> String)
-> ([PollOptionProperties] -> ShowS)
-> Show PollOptionProperties
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PollOptionProperties -> ShowS
showsPrec :: Int -> PollOptionProperties -> ShowS
$cshow :: PollOptionProperties -> String
show :: PollOptionProperties -> String
$cshowList :: [PollOptionProperties] -> ShowS
showList :: [PollOptionProperties] -> ShowS
Show)
instance I.ShortShow PollOptionProperties where
shortShow :: PollOptionProperties -> String
shortShow PollOptionProperties
{ can_be_deleted :: PollOptionProperties -> Maybe Bool
can_be_deleted = Maybe Bool
can_be_deleted_
, can_be_replied :: PollOptionProperties -> Maybe Bool
can_be_replied = Maybe Bool
can_be_replied_
, can_be_replied_in_another_chat :: PollOptionProperties -> Maybe Bool
can_be_replied_in_another_chat = Maybe Bool
can_be_replied_in_another_chat_
, can_get_link :: PollOptionProperties -> Maybe Bool
can_get_link = Maybe Bool
can_get_link_
}
= String
"PollOptionProperties"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"can_be_deleted" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_be_deleted_
, String
"can_be_replied" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_be_replied_
, String
"can_be_replied_in_another_chat" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_be_replied_in_another_chat_
, String
"can_get_link" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_get_link_
]
instance AT.FromJSON PollOptionProperties where
parseJSON :: Value -> Parser PollOptionProperties
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
"pollOptionProperties" -> Value -> Parser PollOptionProperties
parsePollOptionProperties Value
v
String
_ -> Parser PollOptionProperties
forall a. Monoid a => a
mempty
where
parsePollOptionProperties :: A.Value -> AT.Parser PollOptionProperties
parsePollOptionProperties :: Value -> Parser PollOptionProperties
parsePollOptionProperties = String
-> (Object -> Parser PollOptionProperties)
-> Value
-> Parser PollOptionProperties
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"PollOptionProperties" ((Object -> Parser PollOptionProperties)
-> Value -> Parser PollOptionProperties)
-> (Object -> Parser PollOptionProperties)
-> Value
-> Parser PollOptionProperties
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Bool
can_be_deleted_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"can_be_deleted"
Maybe Bool
can_be_replied_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"can_be_replied"
Maybe Bool
can_be_replied_in_another_chat_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"can_be_replied_in_another_chat"
Maybe Bool
can_get_link_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"can_get_link"
PollOptionProperties -> Parser PollOptionProperties
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (PollOptionProperties -> Parser PollOptionProperties)
-> PollOptionProperties -> Parser PollOptionProperties
forall a b. (a -> b) -> a -> b
$ PollOptionProperties
{ can_be_deleted :: Maybe Bool
can_be_deleted = Maybe Bool
can_be_deleted_
, can_be_replied :: Maybe Bool
can_be_replied = Maybe Bool
can_be_replied_
, can_be_replied_in_another_chat :: Maybe Bool
can_be_replied_in_another_chat = Maybe Bool
can_be_replied_in_another_chat_
, can_get_link :: Maybe Bool
can_get_link = Maybe Bool
can_get_link_
}
parseJSON Value
_ = Parser PollOptionProperties
forall a. Monoid a => a
mempty