module TD.Data.UpgradedGiftAttributeRarity
(UpgradedGiftAttributeRarity(..)) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
data UpgradedGiftAttributeRarity
= UpgradedGiftAttributeRarityPerMille
{ UpgradedGiftAttributeRarity -> Maybe Int
per_mille :: Maybe Int
}
| UpgradedGiftAttributeRarityUncommon
| UpgradedGiftAttributeRarityRare
| UpgradedGiftAttributeRarityEpic
| UpgradedGiftAttributeRarityLegendary
deriving (UpgradedGiftAttributeRarity -> UpgradedGiftAttributeRarity -> Bool
(UpgradedGiftAttributeRarity
-> UpgradedGiftAttributeRarity -> Bool)
-> (UpgradedGiftAttributeRarity
-> UpgradedGiftAttributeRarity -> Bool)
-> Eq UpgradedGiftAttributeRarity
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: UpgradedGiftAttributeRarity -> UpgradedGiftAttributeRarity -> Bool
== :: UpgradedGiftAttributeRarity -> UpgradedGiftAttributeRarity -> Bool
$c/= :: UpgradedGiftAttributeRarity -> UpgradedGiftAttributeRarity -> Bool
/= :: UpgradedGiftAttributeRarity -> UpgradedGiftAttributeRarity -> Bool
Eq, Int -> UpgradedGiftAttributeRarity -> ShowS
[UpgradedGiftAttributeRarity] -> ShowS
UpgradedGiftAttributeRarity -> String
(Int -> UpgradedGiftAttributeRarity -> ShowS)
-> (UpgradedGiftAttributeRarity -> String)
-> ([UpgradedGiftAttributeRarity] -> ShowS)
-> Show UpgradedGiftAttributeRarity
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> UpgradedGiftAttributeRarity -> ShowS
showsPrec :: Int -> UpgradedGiftAttributeRarity -> ShowS
$cshow :: UpgradedGiftAttributeRarity -> String
show :: UpgradedGiftAttributeRarity -> String
$cshowList :: [UpgradedGiftAttributeRarity] -> ShowS
showList :: [UpgradedGiftAttributeRarity] -> ShowS
Show)
instance I.ShortShow UpgradedGiftAttributeRarity where
shortShow :: UpgradedGiftAttributeRarity -> String
shortShow UpgradedGiftAttributeRarityPerMille
{ per_mille :: UpgradedGiftAttributeRarity -> Maybe Int
per_mille = Maybe Int
per_mille_
}
= String
"UpgradedGiftAttributeRarityPerMille"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"per_mille" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
per_mille_
]
shortShow UpgradedGiftAttributeRarity
UpgradedGiftAttributeRarityUncommon
= String
"UpgradedGiftAttributeRarityUncommon"
shortShow UpgradedGiftAttributeRarity
UpgradedGiftAttributeRarityRare
= String
"UpgradedGiftAttributeRarityRare"
shortShow UpgradedGiftAttributeRarity
UpgradedGiftAttributeRarityEpic
= String
"UpgradedGiftAttributeRarityEpic"
shortShow UpgradedGiftAttributeRarity
UpgradedGiftAttributeRarityLegendary
= String
"UpgradedGiftAttributeRarityLegendary"
instance AT.FromJSON UpgradedGiftAttributeRarity where
parseJSON :: Value -> Parser UpgradedGiftAttributeRarity
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
"upgradedGiftAttributeRarityPerMille" -> Value -> Parser UpgradedGiftAttributeRarity
parseUpgradedGiftAttributeRarityPerMille Value
v
String
"upgradedGiftAttributeRarityUncommon" -> UpgradedGiftAttributeRarity -> Parser UpgradedGiftAttributeRarity
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UpgradedGiftAttributeRarity
UpgradedGiftAttributeRarityUncommon
String
"upgradedGiftAttributeRarityRare" -> UpgradedGiftAttributeRarity -> Parser UpgradedGiftAttributeRarity
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UpgradedGiftAttributeRarity
UpgradedGiftAttributeRarityRare
String
"upgradedGiftAttributeRarityEpic" -> UpgradedGiftAttributeRarity -> Parser UpgradedGiftAttributeRarity
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UpgradedGiftAttributeRarity
UpgradedGiftAttributeRarityEpic
String
"upgradedGiftAttributeRarityLegendary" -> UpgradedGiftAttributeRarity -> Parser UpgradedGiftAttributeRarity
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure UpgradedGiftAttributeRarity
UpgradedGiftAttributeRarityLegendary
String
_ -> Parser UpgradedGiftAttributeRarity
forall a. Monoid a => a
mempty
where
parseUpgradedGiftAttributeRarityPerMille :: A.Value -> AT.Parser UpgradedGiftAttributeRarity
parseUpgradedGiftAttributeRarityPerMille :: Value -> Parser UpgradedGiftAttributeRarity
parseUpgradedGiftAttributeRarityPerMille = String
-> (Object -> Parser UpgradedGiftAttributeRarity)
-> Value
-> Parser UpgradedGiftAttributeRarity
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"UpgradedGiftAttributeRarityPerMille" ((Object -> Parser UpgradedGiftAttributeRarity)
-> Value -> Parser UpgradedGiftAttributeRarity)
-> (Object -> Parser UpgradedGiftAttributeRarity)
-> Value
-> Parser UpgradedGiftAttributeRarity
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Int
per_mille_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"per_mille"
UpgradedGiftAttributeRarity -> Parser UpgradedGiftAttributeRarity
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (UpgradedGiftAttributeRarity -> Parser UpgradedGiftAttributeRarity)
-> UpgradedGiftAttributeRarity
-> Parser UpgradedGiftAttributeRarity
forall a b. (a -> b) -> a -> b
$ UpgradedGiftAttributeRarityPerMille
{ per_mille :: Maybe Int
per_mille = Maybe Int
per_mille_
}
parseJSON Value
_ = Parser UpgradedGiftAttributeRarity
forall a. Monoid a => a
mempty