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