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