module TD.Data.VideoChat
(VideoChat(..)) 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.MessageSender as MessageSender
data VideoChat
= VideoChat
{ VideoChat -> Maybe Int
group_call_id :: Maybe Int
, VideoChat -> Maybe Bool
has_participants :: Maybe Bool
, VideoChat -> Maybe MessageSender
default_participant_id :: Maybe MessageSender.MessageSender
}
deriving (VideoChat -> VideoChat -> Bool
(VideoChat -> VideoChat -> Bool)
-> (VideoChat -> VideoChat -> Bool) -> Eq VideoChat
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: VideoChat -> VideoChat -> Bool
== :: VideoChat -> VideoChat -> Bool
$c/= :: VideoChat -> VideoChat -> Bool
/= :: VideoChat -> VideoChat -> Bool
Eq, Int -> VideoChat -> ShowS
[VideoChat] -> ShowS
VideoChat -> String
(Int -> VideoChat -> ShowS)
-> (VideoChat -> String)
-> ([VideoChat] -> ShowS)
-> Show VideoChat
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> VideoChat -> ShowS
showsPrec :: Int -> VideoChat -> ShowS
$cshow :: VideoChat -> String
show :: VideoChat -> String
$cshowList :: [VideoChat] -> ShowS
showList :: [VideoChat] -> ShowS
Show)
instance I.ShortShow VideoChat where
shortShow :: VideoChat -> String
shortShow VideoChat
{ group_call_id :: VideoChat -> Maybe Int
group_call_id = Maybe Int
group_call_id_
, has_participants :: VideoChat -> Maybe Bool
has_participants = Maybe Bool
has_participants_
, default_participant_id :: VideoChat -> Maybe MessageSender
default_participant_id = Maybe MessageSender
default_participant_id_
}
= String
"VideoChat"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"group_call_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
group_call_id_
, String
"has_participants" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
has_participants_
, String
"default_participant_id" String -> Maybe MessageSender -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe MessageSender
default_participant_id_
]
instance AT.FromJSON VideoChat where
parseJSON :: Value -> Parser VideoChat
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
"videoChat" -> Value -> Parser VideoChat
parseVideoChat Value
v
String
_ -> Parser VideoChat
forall a. Monoid a => a
mempty
where
parseVideoChat :: A.Value -> AT.Parser VideoChat
parseVideoChat :: Value -> Parser VideoChat
parseVideoChat = String -> (Object -> Parser VideoChat) -> Value -> Parser VideoChat
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"VideoChat" ((Object -> Parser VideoChat) -> Value -> Parser VideoChat)
-> (Object -> Parser VideoChat) -> Value -> Parser VideoChat
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Int
group_call_id_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"group_call_id"
Maybe Bool
has_participants_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"has_participants"
Maybe MessageSender
default_participant_id_ <- Object
o Object -> Key -> Parser (Maybe MessageSender)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"default_participant_id"
VideoChat -> Parser VideoChat
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (VideoChat -> Parser VideoChat) -> VideoChat -> Parser VideoChat
forall a b. (a -> b) -> a -> b
$ VideoChat
{ group_call_id :: Maybe Int
group_call_id = Maybe Int
group_call_id_
, has_participants :: Maybe Bool
has_participants = Maybe Bool
has_participants_
, default_participant_id :: Maybe MessageSender
default_participant_id = Maybe MessageSender
default_participant_id_
}
parseJSON Value
_ = Parser VideoChat
forall a. Monoid a => a
mempty