module TD.Data.GiftUpgradePrice
(GiftUpgradePrice(..)) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
data GiftUpgradePrice
= GiftUpgradePrice
{ GiftUpgradePrice -> Maybe Int
date :: Maybe Int
, GiftUpgradePrice -> Maybe Int
star_count :: Maybe Int
}
deriving (GiftUpgradePrice -> GiftUpgradePrice -> Bool
(GiftUpgradePrice -> GiftUpgradePrice -> Bool)
-> (GiftUpgradePrice -> GiftUpgradePrice -> Bool)
-> Eq GiftUpgradePrice
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GiftUpgradePrice -> GiftUpgradePrice -> Bool
== :: GiftUpgradePrice -> GiftUpgradePrice -> Bool
$c/= :: GiftUpgradePrice -> GiftUpgradePrice -> Bool
/= :: GiftUpgradePrice -> GiftUpgradePrice -> Bool
Eq, Int -> GiftUpgradePrice -> ShowS
[GiftUpgradePrice] -> ShowS
GiftUpgradePrice -> String
(Int -> GiftUpgradePrice -> ShowS)
-> (GiftUpgradePrice -> String)
-> ([GiftUpgradePrice] -> ShowS)
-> Show GiftUpgradePrice
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GiftUpgradePrice -> ShowS
showsPrec :: Int -> GiftUpgradePrice -> ShowS
$cshow :: GiftUpgradePrice -> String
show :: GiftUpgradePrice -> String
$cshowList :: [GiftUpgradePrice] -> ShowS
showList :: [GiftUpgradePrice] -> ShowS
Show)
instance I.ShortShow GiftUpgradePrice where
shortShow :: GiftUpgradePrice -> String
shortShow GiftUpgradePrice
{ date :: GiftUpgradePrice -> Maybe Int
date = Maybe Int
date_
, star_count :: GiftUpgradePrice -> Maybe Int
star_count = Maybe Int
star_count_
}
= String
"GiftUpgradePrice"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"date" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
date_
, String
"star_count" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
star_count_
]
instance AT.FromJSON GiftUpgradePrice where
parseJSON :: Value -> Parser GiftUpgradePrice
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
"giftUpgradePrice" -> Value -> Parser GiftUpgradePrice
parseGiftUpgradePrice Value
v
String
_ -> Parser GiftUpgradePrice
forall a. Monoid a => a
mempty
where
parseGiftUpgradePrice :: A.Value -> AT.Parser GiftUpgradePrice
parseGiftUpgradePrice :: Value -> Parser GiftUpgradePrice
parseGiftUpgradePrice = String
-> (Object -> Parser GiftUpgradePrice)
-> Value
-> Parser GiftUpgradePrice
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"GiftUpgradePrice" ((Object -> Parser GiftUpgradePrice)
-> Value -> Parser GiftUpgradePrice)
-> (Object -> Parser GiftUpgradePrice)
-> Value
-> Parser GiftUpgradePrice
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Int
date_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"date"
Maybe Int
star_count_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"star_count"
GiftUpgradePrice -> Parser GiftUpgradePrice
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (GiftUpgradePrice -> Parser GiftUpgradePrice)
-> GiftUpgradePrice -> Parser GiftUpgradePrice
forall a b. (a -> b) -> a -> b
$ GiftUpgradePrice
{ date :: Maybe Int
date = Maybe Int
date_
, star_count :: Maybe Int
star_count = Maybe Int
star_count_
}
parseJSON Value
_ = Parser GiftUpgradePrice
forall a. Monoid a => a
mempty