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