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