module TD.Data.PaidReactor
(PaidReactor(..)) 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.MessageSender as MessageSender
data PaidReactor
= PaidReactor
{ PaidReactor -> Maybe MessageSender
sender_id :: Maybe MessageSender.MessageSender
, PaidReactor -> Maybe Int
star_count :: Maybe Int
, PaidReactor -> Maybe Bool
is_top :: Maybe Bool
, PaidReactor -> Maybe Bool
is_me :: Maybe Bool
, PaidReactor -> Maybe Bool
is_anonymous :: Maybe Bool
}
deriving (PaidReactor -> PaidReactor -> Bool
(PaidReactor -> PaidReactor -> Bool)
-> (PaidReactor -> PaidReactor -> Bool) -> Eq PaidReactor
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PaidReactor -> PaidReactor -> Bool
== :: PaidReactor -> PaidReactor -> Bool
$c/= :: PaidReactor -> PaidReactor -> Bool
/= :: PaidReactor -> PaidReactor -> Bool
Eq, Int -> PaidReactor -> ShowS
[PaidReactor] -> ShowS
PaidReactor -> String
(Int -> PaidReactor -> ShowS)
-> (PaidReactor -> String)
-> ([PaidReactor] -> ShowS)
-> Show PaidReactor
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PaidReactor -> ShowS
showsPrec :: Int -> PaidReactor -> ShowS
$cshow :: PaidReactor -> String
show :: PaidReactor -> String
$cshowList :: [PaidReactor] -> ShowS
showList :: [PaidReactor] -> ShowS
Show)
instance I.ShortShow PaidReactor where
shortShow :: PaidReactor -> String
shortShow PaidReactor
{ sender_id :: PaidReactor -> Maybe MessageSender
sender_id = Maybe MessageSender
sender_id_
, star_count :: PaidReactor -> Maybe Int
star_count = Maybe Int
star_count_
, is_top :: PaidReactor -> Maybe Bool
is_top = Maybe Bool
is_top_
, is_me :: PaidReactor -> Maybe Bool
is_me = Maybe Bool
is_me_
, is_anonymous :: PaidReactor -> Maybe Bool
is_anonymous = Maybe Bool
is_anonymous_
}
= String
"PaidReactor"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"sender_id" String -> Maybe MessageSender -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe MessageSender
sender_id_
, String
"star_count" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
star_count_
, String
"is_top" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_top_
, String
"is_me" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_me_
, String
"is_anonymous" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_anonymous_
]
instance AT.FromJSON PaidReactor where
parseJSON :: Value -> Parser PaidReactor
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
"paidReactor" -> Value -> Parser PaidReactor
parsePaidReactor Value
v
String
_ -> Parser PaidReactor
forall a. Monoid a => a
mempty
where
parsePaidReactor :: A.Value -> AT.Parser PaidReactor
parsePaidReactor :: Value -> Parser PaidReactor
parsePaidReactor = String
-> (Object -> Parser PaidReactor) -> Value -> Parser PaidReactor
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"PaidReactor" ((Object -> Parser PaidReactor) -> Value -> Parser PaidReactor)
-> (Object -> Parser PaidReactor) -> Value -> Parser PaidReactor
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe MessageSender
sender_id_ <- Object
o Object -> Key -> Parser (Maybe MessageSender)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"sender_id"
Maybe Int
star_count_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"star_count"
Maybe Bool
is_top_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_top"
Maybe Bool
is_me_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_me"
Maybe Bool
is_anonymous_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_anonymous"
PaidReactor -> Parser PaidReactor
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (PaidReactor -> Parser PaidReactor)
-> PaidReactor -> Parser PaidReactor
forall a b. (a -> b) -> a -> b
$ PaidReactor
{ sender_id :: Maybe MessageSender
sender_id = Maybe MessageSender
sender_id_
, star_count :: Maybe Int
star_count = Maybe Int
star_count_
, is_top :: Maybe Bool
is_top = Maybe Bool
is_top_
, is_me :: Maybe Bool
is_me = Maybe Bool
is_me_
, is_anonymous :: Maybe Bool
is_anonymous = Maybe Bool
is_anonymous_
}
parseJSON Value
_ = Parser PaidReactor
forall a. Monoid a => a
mempty