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