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