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