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