module TD.Data.ChatInviteLinkCount
(ChatInviteLinkCount(..)) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
data ChatInviteLinkCount
= ChatInviteLinkCount
{ ChatInviteLinkCount -> Maybe Int
user_id :: Maybe Int
, ChatInviteLinkCount -> Maybe Int
invite_link_count :: Maybe Int
, ChatInviteLinkCount -> Maybe Int
revoked_invite_link_count :: Maybe Int
}
deriving (ChatInviteLinkCount -> ChatInviteLinkCount -> Bool
(ChatInviteLinkCount -> ChatInviteLinkCount -> Bool)
-> (ChatInviteLinkCount -> ChatInviteLinkCount -> Bool)
-> Eq ChatInviteLinkCount
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ChatInviteLinkCount -> ChatInviteLinkCount -> Bool
== :: ChatInviteLinkCount -> ChatInviteLinkCount -> Bool
$c/= :: ChatInviteLinkCount -> ChatInviteLinkCount -> Bool
/= :: ChatInviteLinkCount -> ChatInviteLinkCount -> Bool
Eq, Int -> ChatInviteLinkCount -> ShowS
[ChatInviteLinkCount] -> ShowS
ChatInviteLinkCount -> String
(Int -> ChatInviteLinkCount -> ShowS)
-> (ChatInviteLinkCount -> String)
-> ([ChatInviteLinkCount] -> ShowS)
-> Show ChatInviteLinkCount
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ChatInviteLinkCount -> ShowS
showsPrec :: Int -> ChatInviteLinkCount -> ShowS
$cshow :: ChatInviteLinkCount -> String
show :: ChatInviteLinkCount -> String
$cshowList :: [ChatInviteLinkCount] -> ShowS
showList :: [ChatInviteLinkCount] -> ShowS
Show)
instance I.ShortShow ChatInviteLinkCount where
shortShow :: ChatInviteLinkCount -> String
shortShow ChatInviteLinkCount
{ user_id :: ChatInviteLinkCount -> Maybe Int
user_id = Maybe Int
user_id_
, invite_link_count :: ChatInviteLinkCount -> Maybe Int
invite_link_count = Maybe Int
invite_link_count_
, revoked_invite_link_count :: ChatInviteLinkCount -> Maybe Int
revoked_invite_link_count = Maybe Int
revoked_invite_link_count_
}
= String
"ChatInviteLinkCount"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"user_id" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
user_id_
, String
"invite_link_count" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
invite_link_count_
, String
"revoked_invite_link_count" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
revoked_invite_link_count_
]
instance AT.FromJSON ChatInviteLinkCount where
parseJSON :: Value -> Parser ChatInviteLinkCount
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
"chatInviteLinkCount" -> Value -> Parser ChatInviteLinkCount
parseChatInviteLinkCount Value
v
String
_ -> Parser ChatInviteLinkCount
forall a. Monoid a => a
mempty
where
parseChatInviteLinkCount :: A.Value -> AT.Parser ChatInviteLinkCount
parseChatInviteLinkCount :: Value -> Parser ChatInviteLinkCount
parseChatInviteLinkCount = String
-> (Object -> Parser ChatInviteLinkCount)
-> Value
-> Parser ChatInviteLinkCount
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"ChatInviteLinkCount" ((Object -> Parser ChatInviteLinkCount)
-> Value -> Parser ChatInviteLinkCount)
-> (Object -> Parser ChatInviteLinkCount)
-> Value
-> Parser ChatInviteLinkCount
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Int
user_id_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"user_id"
Maybe Int
invite_link_count_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"invite_link_count"
Maybe Int
revoked_invite_link_count_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"revoked_invite_link_count"
ChatInviteLinkCount -> Parser ChatInviteLinkCount
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ChatInviteLinkCount -> Parser ChatInviteLinkCount)
-> ChatInviteLinkCount -> Parser ChatInviteLinkCount
forall a b. (a -> b) -> a -> b
$ ChatInviteLinkCount
{ user_id :: Maybe Int
user_id = Maybe Int
user_id_
, invite_link_count :: Maybe Int
invite_link_count = Maybe Int
invite_link_count_
, revoked_invite_link_count :: Maybe Int
revoked_invite_link_count = Maybe Int
revoked_invite_link_count_
}
parseJSON Value
_ = Parser ChatInviteLinkCount
forall a. Monoid a => a
mempty