module TD.Data.MessageReactions
(MessageReactions(..)) 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.MessageReaction as MessageReaction
import qualified TD.Data.PaidReactor as PaidReactor
data MessageReactions
= MessageReactions
{ MessageReactions -> Maybe [MessageReaction]
reactions :: Maybe [MessageReaction.MessageReaction]
, MessageReactions -> Maybe Bool
are_tags :: Maybe Bool
, MessageReactions -> Maybe [PaidReactor]
paid_reactors :: Maybe [PaidReactor.PaidReactor]
, MessageReactions -> Maybe Bool
can_get_added_reactions :: Maybe Bool
}
deriving (MessageReactions -> MessageReactions -> Bool
(MessageReactions -> MessageReactions -> Bool)
-> (MessageReactions -> MessageReactions -> Bool)
-> Eq MessageReactions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: MessageReactions -> MessageReactions -> Bool
== :: MessageReactions -> MessageReactions -> Bool
$c/= :: MessageReactions -> MessageReactions -> Bool
/= :: MessageReactions -> MessageReactions -> Bool
Eq, Int -> MessageReactions -> ShowS
[MessageReactions] -> ShowS
MessageReactions -> String
(Int -> MessageReactions -> ShowS)
-> (MessageReactions -> String)
-> ([MessageReactions] -> ShowS)
-> Show MessageReactions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> MessageReactions -> ShowS
showsPrec :: Int -> MessageReactions -> ShowS
$cshow :: MessageReactions -> String
show :: MessageReactions -> String
$cshowList :: [MessageReactions] -> ShowS
showList :: [MessageReactions] -> ShowS
Show)
instance I.ShortShow MessageReactions where
shortShow :: MessageReactions -> String
shortShow MessageReactions
{ reactions :: MessageReactions -> Maybe [MessageReaction]
reactions = Maybe [MessageReaction]
reactions_
, are_tags :: MessageReactions -> Maybe Bool
are_tags = Maybe Bool
are_tags_
, paid_reactors :: MessageReactions -> Maybe [PaidReactor]
paid_reactors = Maybe [PaidReactor]
paid_reactors_
, can_get_added_reactions :: MessageReactions -> Maybe Bool
can_get_added_reactions = Maybe Bool
can_get_added_reactions_
}
= String
"MessageReactions"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"reactions" String -> Maybe [MessageReaction] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [MessageReaction]
reactions_
, String
"are_tags" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
are_tags_
, String
"paid_reactors" String -> Maybe [PaidReactor] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [PaidReactor]
paid_reactors_
, String
"can_get_added_reactions" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_get_added_reactions_
]
instance AT.FromJSON MessageReactions where
parseJSON :: Value -> Parser MessageReactions
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
"messageReactions" -> Value -> Parser MessageReactions
parseMessageReactions Value
v
String
_ -> Parser MessageReactions
forall a. Monoid a => a
mempty
where
parseMessageReactions :: A.Value -> AT.Parser MessageReactions
parseMessageReactions :: Value -> Parser MessageReactions
parseMessageReactions = String
-> (Object -> Parser MessageReactions)
-> Value
-> Parser MessageReactions
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"MessageReactions" ((Object -> Parser MessageReactions)
-> Value -> Parser MessageReactions)
-> (Object -> Parser MessageReactions)
-> Value
-> Parser MessageReactions
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe [MessageReaction]
reactions_ <- Object
o Object -> Key -> Parser (Maybe [MessageReaction])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"reactions"
Maybe Bool
are_tags_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"are_tags"
Maybe [PaidReactor]
paid_reactors_ <- Object
o Object -> Key -> Parser (Maybe [PaidReactor])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"paid_reactors"
Maybe Bool
can_get_added_reactions_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"can_get_added_reactions"
MessageReactions -> Parser MessageReactions
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (MessageReactions -> Parser MessageReactions)
-> MessageReactions -> Parser MessageReactions
forall a b. (a -> b) -> a -> b
$ MessageReactions
{ reactions :: Maybe [MessageReaction]
reactions = Maybe [MessageReaction]
reactions_
, are_tags :: Maybe Bool
are_tags = Maybe Bool
are_tags_
, paid_reactors :: Maybe [PaidReactor]
paid_reactors = Maybe [PaidReactor]
paid_reactors_
, can_get_added_reactions :: Maybe Bool
can_get_added_reactions = Maybe Bool
can_get_added_reactions_
}
parseJSON Value
_ = Parser MessageReactions
forall a. Monoid a => a
mempty