module TD.Data.ChatStatisticsInteractionInfo
(ChatStatisticsInteractionInfo(..)) 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.ChatStatisticsObjectType as ChatStatisticsObjectType
data ChatStatisticsInteractionInfo
= ChatStatisticsInteractionInfo
{ ChatStatisticsInteractionInfo -> Maybe ChatStatisticsObjectType
object_type :: Maybe ChatStatisticsObjectType.ChatStatisticsObjectType
, ChatStatisticsInteractionInfo -> Maybe Int
view_count :: Maybe Int
, ChatStatisticsInteractionInfo -> Maybe Int
forward_count :: Maybe Int
, ChatStatisticsInteractionInfo -> Maybe Int
reaction_count :: Maybe Int
}
deriving (ChatStatisticsInteractionInfo
-> ChatStatisticsInteractionInfo -> Bool
(ChatStatisticsInteractionInfo
-> ChatStatisticsInteractionInfo -> Bool)
-> (ChatStatisticsInteractionInfo
-> ChatStatisticsInteractionInfo -> Bool)
-> Eq ChatStatisticsInteractionInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ChatStatisticsInteractionInfo
-> ChatStatisticsInteractionInfo -> Bool
== :: ChatStatisticsInteractionInfo
-> ChatStatisticsInteractionInfo -> Bool
$c/= :: ChatStatisticsInteractionInfo
-> ChatStatisticsInteractionInfo -> Bool
/= :: ChatStatisticsInteractionInfo
-> ChatStatisticsInteractionInfo -> Bool
Eq, Int -> ChatStatisticsInteractionInfo -> ShowS
[ChatStatisticsInteractionInfo] -> ShowS
ChatStatisticsInteractionInfo -> String
(Int -> ChatStatisticsInteractionInfo -> ShowS)
-> (ChatStatisticsInteractionInfo -> String)
-> ([ChatStatisticsInteractionInfo] -> ShowS)
-> Show ChatStatisticsInteractionInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ChatStatisticsInteractionInfo -> ShowS
showsPrec :: Int -> ChatStatisticsInteractionInfo -> ShowS
$cshow :: ChatStatisticsInteractionInfo -> String
show :: ChatStatisticsInteractionInfo -> String
$cshowList :: [ChatStatisticsInteractionInfo] -> ShowS
showList :: [ChatStatisticsInteractionInfo] -> ShowS
Show)
instance I.ShortShow ChatStatisticsInteractionInfo where
shortShow :: ChatStatisticsInteractionInfo -> String
shortShow ChatStatisticsInteractionInfo
{ object_type :: ChatStatisticsInteractionInfo -> Maybe ChatStatisticsObjectType
object_type = Maybe ChatStatisticsObjectType
object_type_
, view_count :: ChatStatisticsInteractionInfo -> Maybe Int
view_count = Maybe Int
view_count_
, forward_count :: ChatStatisticsInteractionInfo -> Maybe Int
forward_count = Maybe Int
forward_count_
, reaction_count :: ChatStatisticsInteractionInfo -> Maybe Int
reaction_count = Maybe Int
reaction_count_
}
= String
"ChatStatisticsInteractionInfo"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"object_type" String -> Maybe ChatStatisticsObjectType -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe ChatStatisticsObjectType
object_type_
, String
"view_count" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
view_count_
, String
"forward_count" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
forward_count_
, String
"reaction_count" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
reaction_count_
]
instance AT.FromJSON ChatStatisticsInteractionInfo where
parseJSON :: Value -> Parser ChatStatisticsInteractionInfo
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
"chatStatisticsInteractionInfo" -> Value -> Parser ChatStatisticsInteractionInfo
parseChatStatisticsInteractionInfo Value
v
String
_ -> Parser ChatStatisticsInteractionInfo
forall a. Monoid a => a
mempty
where
parseChatStatisticsInteractionInfo :: A.Value -> AT.Parser ChatStatisticsInteractionInfo
parseChatStatisticsInteractionInfo :: Value -> Parser ChatStatisticsInteractionInfo
parseChatStatisticsInteractionInfo = String
-> (Object -> Parser ChatStatisticsInteractionInfo)
-> Value
-> Parser ChatStatisticsInteractionInfo
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"ChatStatisticsInteractionInfo" ((Object -> Parser ChatStatisticsInteractionInfo)
-> Value -> Parser ChatStatisticsInteractionInfo)
-> (Object -> Parser ChatStatisticsInteractionInfo)
-> Value
-> Parser ChatStatisticsInteractionInfo
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe ChatStatisticsObjectType
object_type_ <- Object
o Object -> Key -> Parser (Maybe ChatStatisticsObjectType)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"object_type"
Maybe Int
view_count_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"view_count"
Maybe Int
forward_count_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"forward_count"
Maybe Int
reaction_count_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"reaction_count"
ChatStatisticsInteractionInfo
-> Parser ChatStatisticsInteractionInfo
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ChatStatisticsInteractionInfo
-> Parser ChatStatisticsInteractionInfo)
-> ChatStatisticsInteractionInfo
-> Parser ChatStatisticsInteractionInfo
forall a b. (a -> b) -> a -> b
$ ChatStatisticsInteractionInfo
{ object_type :: Maybe ChatStatisticsObjectType
object_type = Maybe ChatStatisticsObjectType
object_type_
, view_count :: Maybe Int
view_count = Maybe Int
view_count_
, forward_count :: Maybe Int
forward_count = Maybe Int
forward_count_
, reaction_count :: Maybe Int
reaction_count = Maybe Int
reaction_count_
}
parseJSON Value
_ = Parser ChatStatisticsInteractionInfo
forall a. Monoid a => a
mempty