module TD.Data.UpgradeGiftResult
(UpgradeGiftResult(..)) 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.UpgradedGift as UpgradedGift
data UpgradeGiftResult
= UpgradeGiftResult
{ UpgradeGiftResult -> Maybe UpgradedGift
gift :: Maybe UpgradedGift.UpgradedGift
, UpgradeGiftResult -> Maybe Bool
is_saved :: Maybe Bool
, UpgradeGiftResult -> Maybe Bool
can_be_transferred :: Maybe Bool
, UpgradeGiftResult -> Maybe Int
transfer_star_count :: Maybe Int
, UpgradeGiftResult -> Maybe Int
export_date :: Maybe Int
}
deriving (UpgradeGiftResult -> UpgradeGiftResult -> Bool
(UpgradeGiftResult -> UpgradeGiftResult -> Bool)
-> (UpgradeGiftResult -> UpgradeGiftResult -> Bool)
-> Eq UpgradeGiftResult
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: UpgradeGiftResult -> UpgradeGiftResult -> Bool
== :: UpgradeGiftResult -> UpgradeGiftResult -> Bool
$c/= :: UpgradeGiftResult -> UpgradeGiftResult -> Bool
/= :: UpgradeGiftResult -> UpgradeGiftResult -> Bool
Eq, Int -> UpgradeGiftResult -> ShowS
[UpgradeGiftResult] -> ShowS
UpgradeGiftResult -> String
(Int -> UpgradeGiftResult -> ShowS)
-> (UpgradeGiftResult -> String)
-> ([UpgradeGiftResult] -> ShowS)
-> Show UpgradeGiftResult
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> UpgradeGiftResult -> ShowS
showsPrec :: Int -> UpgradeGiftResult -> ShowS
$cshow :: UpgradeGiftResult -> String
show :: UpgradeGiftResult -> String
$cshowList :: [UpgradeGiftResult] -> ShowS
showList :: [UpgradeGiftResult] -> ShowS
Show)
instance I.ShortShow UpgradeGiftResult where
shortShow :: UpgradeGiftResult -> String
shortShow UpgradeGiftResult
{ gift :: UpgradeGiftResult -> Maybe UpgradedGift
gift = Maybe UpgradedGift
gift_
, is_saved :: UpgradeGiftResult -> Maybe Bool
is_saved = Maybe Bool
is_saved_
, can_be_transferred :: UpgradeGiftResult -> Maybe Bool
can_be_transferred = Maybe Bool
can_be_transferred_
, transfer_star_count :: UpgradeGiftResult -> Maybe Int
transfer_star_count = Maybe Int
transfer_star_count_
, export_date :: UpgradeGiftResult -> Maybe Int
export_date = Maybe Int
export_date_
}
= String
"UpgradeGiftResult"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"gift" String -> Maybe UpgradedGift -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe UpgradedGift
gift_
, String
"is_saved" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_saved_
, String
"can_be_transferred" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
can_be_transferred_
, String
"transfer_star_count" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
transfer_star_count_
, String
"export_date" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
export_date_
]
instance AT.FromJSON UpgradeGiftResult where
parseJSON :: Value -> Parser UpgradeGiftResult
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
"upgradeGiftResult" -> Value -> Parser UpgradeGiftResult
parseUpgradeGiftResult Value
v
String
_ -> Parser UpgradeGiftResult
forall a. Monoid a => a
mempty
where
parseUpgradeGiftResult :: A.Value -> AT.Parser UpgradeGiftResult
parseUpgradeGiftResult :: Value -> Parser UpgradeGiftResult
parseUpgradeGiftResult = String
-> (Object -> Parser UpgradeGiftResult)
-> Value
-> Parser UpgradeGiftResult
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"UpgradeGiftResult" ((Object -> Parser UpgradeGiftResult)
-> Value -> Parser UpgradeGiftResult)
-> (Object -> Parser UpgradeGiftResult)
-> Value
-> Parser UpgradeGiftResult
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe UpgradedGift
gift_ <- Object
o Object -> Key -> Parser (Maybe UpgradedGift)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"gift"
Maybe Bool
is_saved_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_saved"
Maybe Bool
can_be_transferred_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"can_be_transferred"
Maybe Int
transfer_star_count_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"transfer_star_count"
Maybe Int
export_date_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"export_date"
UpgradeGiftResult -> Parser UpgradeGiftResult
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (UpgradeGiftResult -> Parser UpgradeGiftResult)
-> UpgradeGiftResult -> Parser UpgradeGiftResult
forall a b. (a -> b) -> a -> b
$ UpgradeGiftResult
{ gift :: Maybe UpgradedGift
gift = Maybe UpgradedGift
gift_
, is_saved :: Maybe Bool
is_saved = Maybe Bool
is_saved_
, can_be_transferred :: Maybe Bool
can_be_transferred = Maybe Bool
can_be_transferred_
, transfer_star_count :: Maybe Int
transfer_star_count = Maybe Int
transfer_star_count_
, export_date :: Maybe Int
export_date = Maybe Int
export_date_
}
parseJSON Value
_ = Parser UpgradeGiftResult
forall a. Monoid a => a
mempty