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