module TD.Data.DiceStickers
(DiceStickers(..)) 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.Sticker as Sticker
data DiceStickers
= DiceStickersRegular
{ DiceStickers -> Maybe Sticker
sticker :: Maybe Sticker.Sticker
}
|
{ DiceStickers -> Maybe Sticker
background :: Maybe Sticker.Sticker
, DiceStickers -> Maybe Sticker
lever :: Maybe Sticker.Sticker
, DiceStickers -> Maybe Sticker
left_reel :: Maybe Sticker.Sticker
, DiceStickers -> Maybe Sticker
center_reel :: Maybe Sticker.Sticker
, DiceStickers -> Maybe Sticker
right_reel :: Maybe Sticker.Sticker
}
deriving (DiceStickers -> DiceStickers -> Bool
(DiceStickers -> DiceStickers -> Bool)
-> (DiceStickers -> DiceStickers -> Bool) -> Eq DiceStickers
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DiceStickers -> DiceStickers -> Bool
== :: DiceStickers -> DiceStickers -> Bool
$c/= :: DiceStickers -> DiceStickers -> Bool
/= :: DiceStickers -> DiceStickers -> Bool
Eq, Int -> DiceStickers -> ShowS
[DiceStickers] -> ShowS
DiceStickers -> String
(Int -> DiceStickers -> ShowS)
-> (DiceStickers -> String)
-> ([DiceStickers] -> ShowS)
-> Show DiceStickers
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DiceStickers -> ShowS
showsPrec :: Int -> DiceStickers -> ShowS
$cshow :: DiceStickers -> String
show :: DiceStickers -> String
$cshowList :: [DiceStickers] -> ShowS
showList :: [DiceStickers] -> ShowS
Show)
instance I.ShortShow DiceStickers where
shortShow :: DiceStickers -> String
shortShow DiceStickersRegular
{ sticker :: DiceStickers -> Maybe Sticker
sticker = Maybe Sticker
sticker_
}
= String
"DiceStickersRegular"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"sticker" String -> Maybe Sticker -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Sticker
sticker_
]
shortShow DiceStickersSlotMachine
{ background :: DiceStickers -> Maybe Sticker
background = Maybe Sticker
background_
, lever :: DiceStickers -> Maybe Sticker
lever = Maybe Sticker
lever_
, left_reel :: DiceStickers -> Maybe Sticker
left_reel = Maybe Sticker
left_reel_
, center_reel :: DiceStickers -> Maybe Sticker
center_reel = Maybe Sticker
center_reel_
, right_reel :: DiceStickers -> Maybe Sticker
right_reel = Maybe Sticker
right_reel_
}
= String
"DiceStickersSlotMachine"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"background" String -> Maybe Sticker -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Sticker
background_
, String
"lever" String -> Maybe Sticker -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Sticker
lever_
, String
"left_reel" String -> Maybe Sticker -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Sticker
left_reel_
, String
"center_reel" String -> Maybe Sticker -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Sticker
center_reel_
, String
"right_reel" String -> Maybe Sticker -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Sticker
right_reel_
]
instance AT.FromJSON DiceStickers where
parseJSON :: Value -> Parser DiceStickers
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
"diceStickersRegular" -> Value -> Parser DiceStickers
parseDiceStickersRegular Value
v
String
"diceStickersSlotMachine" -> Value -> Parser DiceStickers
parseDiceStickersSlotMachine Value
v
String
_ -> Parser DiceStickers
forall a. Monoid a => a
mempty
where
parseDiceStickersRegular :: A.Value -> AT.Parser DiceStickers
parseDiceStickersRegular :: Value -> Parser DiceStickers
parseDiceStickersRegular = String
-> (Object -> Parser DiceStickers) -> Value -> Parser DiceStickers
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"DiceStickersRegular" ((Object -> Parser DiceStickers) -> Value -> Parser DiceStickers)
-> (Object -> Parser DiceStickers) -> Value -> Parser DiceStickers
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Sticker
sticker_ <- Object
o Object -> Key -> Parser (Maybe Sticker)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"sticker"
DiceStickers -> Parser DiceStickers
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (DiceStickers -> Parser DiceStickers)
-> DiceStickers -> Parser DiceStickers
forall a b. (a -> b) -> a -> b
$ DiceStickersRegular
{ sticker :: Maybe Sticker
sticker = Maybe Sticker
sticker_
}
parseDiceStickersSlotMachine :: A.Value -> AT.Parser DiceStickers
parseDiceStickersSlotMachine :: Value -> Parser DiceStickers
parseDiceStickersSlotMachine = String
-> (Object -> Parser DiceStickers) -> Value -> Parser DiceStickers
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"DiceStickersSlotMachine" ((Object -> Parser DiceStickers) -> Value -> Parser DiceStickers)
-> (Object -> Parser DiceStickers) -> Value -> Parser DiceStickers
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Sticker
background_ <- Object
o Object -> Key -> Parser (Maybe Sticker)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"background"
Maybe Sticker
lever_ <- Object
o Object -> Key -> Parser (Maybe Sticker)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"lever"
Maybe Sticker
left_reel_ <- Object
o Object -> Key -> Parser (Maybe Sticker)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"left_reel"
Maybe Sticker
center_reel_ <- Object
o Object -> Key -> Parser (Maybe Sticker)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"center_reel"
Maybe Sticker
right_reel_ <- Object
o Object -> Key -> Parser (Maybe Sticker)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"right_reel"
DiceStickers -> Parser DiceStickers
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (DiceStickers -> Parser DiceStickers)
-> DiceStickers -> Parser DiceStickers
forall a b. (a -> b) -> a -> b
$ DiceStickersSlotMachine
{ background :: Maybe Sticker
background = Maybe Sticker
background_
, lever :: Maybe Sticker
lever = Maybe Sticker
lever_
, left_reel :: Maybe Sticker
left_reel = Maybe Sticker
left_reel_
, center_reel :: Maybe Sticker
center_reel = Maybe Sticker
center_reel_
, right_reel :: Maybe Sticker
right_reel = Maybe Sticker
right_reel_
}
parseJSON Value
_ = Parser DiceStickers
forall a. Monoid a => a
mempty