module TD.Data.GiftUpgradePreview
(GiftUpgradePreview(..)) 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.UpgradedGiftModel as UpgradedGiftModel
import qualified TD.Data.UpgradedGiftSymbol as UpgradedGiftSymbol
import qualified TD.Data.UpgradedGiftBackdrop as UpgradedGiftBackdrop
data GiftUpgradePreview
= GiftUpgradePreview
{ GiftUpgradePreview -> Maybe [UpgradedGiftModel]
models :: Maybe [UpgradedGiftModel.UpgradedGiftModel]
, GiftUpgradePreview -> Maybe [UpgradedGiftSymbol]
symbols :: Maybe [UpgradedGiftSymbol.UpgradedGiftSymbol]
, GiftUpgradePreview -> Maybe [UpgradedGiftBackdrop]
backdrops :: Maybe [UpgradedGiftBackdrop.UpgradedGiftBackdrop]
}
deriving (GiftUpgradePreview -> GiftUpgradePreview -> Bool
(GiftUpgradePreview -> GiftUpgradePreview -> Bool)
-> (GiftUpgradePreview -> GiftUpgradePreview -> Bool)
-> Eq GiftUpgradePreview
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GiftUpgradePreview -> GiftUpgradePreview -> Bool
== :: GiftUpgradePreview -> GiftUpgradePreview -> Bool
$c/= :: GiftUpgradePreview -> GiftUpgradePreview -> Bool
/= :: GiftUpgradePreview -> GiftUpgradePreview -> Bool
Eq, Int -> GiftUpgradePreview -> ShowS
[GiftUpgradePreview] -> ShowS
GiftUpgradePreview -> String
(Int -> GiftUpgradePreview -> ShowS)
-> (GiftUpgradePreview -> String)
-> ([GiftUpgradePreview] -> ShowS)
-> Show GiftUpgradePreview
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GiftUpgradePreview -> ShowS
showsPrec :: Int -> GiftUpgradePreview -> ShowS
$cshow :: GiftUpgradePreview -> String
show :: GiftUpgradePreview -> String
$cshowList :: [GiftUpgradePreview] -> ShowS
showList :: [GiftUpgradePreview] -> ShowS
Show)
instance I.ShortShow GiftUpgradePreview where
shortShow :: GiftUpgradePreview -> String
shortShow GiftUpgradePreview
{ models :: GiftUpgradePreview -> Maybe [UpgradedGiftModel]
models = Maybe [UpgradedGiftModel]
models_
, symbols :: GiftUpgradePreview -> Maybe [UpgradedGiftSymbol]
symbols = Maybe [UpgradedGiftSymbol]
symbols_
, backdrops :: GiftUpgradePreview -> Maybe [UpgradedGiftBackdrop]
backdrops = Maybe [UpgradedGiftBackdrop]
backdrops_
}
= String
"GiftUpgradePreview"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"models" String -> Maybe [UpgradedGiftModel] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [UpgradedGiftModel]
models_
, String
"symbols" String -> Maybe [UpgradedGiftSymbol] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [UpgradedGiftSymbol]
symbols_
, String
"backdrops" String -> Maybe [UpgradedGiftBackdrop] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [UpgradedGiftBackdrop]
backdrops_
]
instance AT.FromJSON GiftUpgradePreview where
parseJSON :: Value -> Parser GiftUpgradePreview
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
"giftUpgradePreview" -> Value -> Parser GiftUpgradePreview
parseGiftUpgradePreview Value
v
String
_ -> Parser GiftUpgradePreview
forall a. Monoid a => a
mempty
where
parseGiftUpgradePreview :: A.Value -> AT.Parser GiftUpgradePreview
parseGiftUpgradePreview :: Value -> Parser GiftUpgradePreview
parseGiftUpgradePreview = String
-> (Object -> Parser GiftUpgradePreview)
-> Value
-> Parser GiftUpgradePreview
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"GiftUpgradePreview" ((Object -> Parser GiftUpgradePreview)
-> Value -> Parser GiftUpgradePreview)
-> (Object -> Parser GiftUpgradePreview)
-> Value
-> Parser GiftUpgradePreview
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe [UpgradedGiftModel]
models_ <- Object
o Object -> Key -> Parser (Maybe [UpgradedGiftModel])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"models"
Maybe [UpgradedGiftSymbol]
symbols_ <- Object
o Object -> Key -> Parser (Maybe [UpgradedGiftSymbol])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"symbols"
Maybe [UpgradedGiftBackdrop]
backdrops_ <- Object
o Object -> Key -> Parser (Maybe [UpgradedGiftBackdrop])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"backdrops"
GiftUpgradePreview -> Parser GiftUpgradePreview
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (GiftUpgradePreview -> Parser GiftUpgradePreview)
-> GiftUpgradePreview -> Parser GiftUpgradePreview
forall a b. (a -> b) -> a -> b
$ GiftUpgradePreview
{ models :: Maybe [UpgradedGiftModel]
models = Maybe [UpgradedGiftModel]
models_
, symbols :: Maybe [UpgradedGiftSymbol]
symbols = Maybe [UpgradedGiftSymbol]
symbols_
, backdrops :: Maybe [UpgradedGiftBackdrop]
backdrops = Maybe [UpgradedGiftBackdrop]
backdrops_
}
parseJSON Value
_ = Parser GiftUpgradePreview
forall a. Monoid a => a
mempty