module TD.Data.EmojiCategorySource
(EmojiCategorySource(..)) 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 EmojiCategorySource
= EmojiCategorySourceSearch
{ EmojiCategorySource -> Maybe [Text]
emojis :: Maybe [T.Text]
}
| EmojiCategorySourcePremium
deriving (EmojiCategorySource -> EmojiCategorySource -> Bool
(EmojiCategorySource -> EmojiCategorySource -> Bool)
-> (EmojiCategorySource -> EmojiCategorySource -> Bool)
-> Eq EmojiCategorySource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: EmojiCategorySource -> EmojiCategorySource -> Bool
== :: EmojiCategorySource -> EmojiCategorySource -> Bool
$c/= :: EmojiCategorySource -> EmojiCategorySource -> Bool
/= :: EmojiCategorySource -> EmojiCategorySource -> Bool
Eq, Int -> EmojiCategorySource -> ShowS
[EmojiCategorySource] -> ShowS
EmojiCategorySource -> String
(Int -> EmojiCategorySource -> ShowS)
-> (EmojiCategorySource -> String)
-> ([EmojiCategorySource] -> ShowS)
-> Show EmojiCategorySource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> EmojiCategorySource -> ShowS
showsPrec :: Int -> EmojiCategorySource -> ShowS
$cshow :: EmojiCategorySource -> String
show :: EmojiCategorySource -> String
$cshowList :: [EmojiCategorySource] -> ShowS
showList :: [EmojiCategorySource] -> ShowS
Show)
instance I.ShortShow EmojiCategorySource where
shortShow :: EmojiCategorySource -> String
shortShow EmojiCategorySourceSearch
{ emojis :: EmojiCategorySource -> Maybe [Text]
emojis = Maybe [Text]
emojis_
}
= String
"EmojiCategorySourceSearch"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"emojis" String -> Maybe [Text] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [Text]
emojis_
]
shortShow EmojiCategorySource
EmojiCategorySourcePremium
= String
"EmojiCategorySourcePremium"
instance AT.FromJSON EmojiCategorySource where
parseJSON :: Value -> Parser EmojiCategorySource
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
"emojiCategorySourceSearch" -> Value -> Parser EmojiCategorySource
parseEmojiCategorySourceSearch Value
v
String
"emojiCategorySourcePremium" -> EmojiCategorySource -> Parser EmojiCategorySource
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure EmojiCategorySource
EmojiCategorySourcePremium
String
_ -> Parser EmojiCategorySource
forall a. Monoid a => a
mempty
where
parseEmojiCategorySourceSearch :: A.Value -> AT.Parser EmojiCategorySource
parseEmojiCategorySourceSearch :: Value -> Parser EmojiCategorySource
parseEmojiCategorySourceSearch = String
-> (Object -> Parser EmojiCategorySource)
-> Value
-> Parser EmojiCategorySource
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"EmojiCategorySourceSearch" ((Object -> Parser EmojiCategorySource)
-> Value -> Parser EmojiCategorySource)
-> (Object -> Parser EmojiCategorySource)
-> Value
-> Parser EmojiCategorySource
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe [Text]
emojis_ <- Object
o Object -> Key -> Parser (Maybe [Text])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"emojis"
EmojiCategorySource -> Parser EmojiCategorySource
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (EmojiCategorySource -> Parser EmojiCategorySource)
-> EmojiCategorySource -> Parser EmojiCategorySource
forall a b. (a -> b) -> a -> b
$ EmojiCategorySourceSearch
{ emojis :: Maybe [Text]
emojis = Maybe [Text]
emojis_
}
parseJSON Value
_ = Parser EmojiCategorySource
forall a. Monoid a => a
mempty