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