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