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