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