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