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