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