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