module TD.Data.PremiumStatePaymentOption
(PremiumStatePaymentOption(..)) 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.PremiumPaymentOption as PremiumPaymentOption
import qualified Data.Text as T
data PremiumStatePaymentOption
= PremiumStatePaymentOption
{ PremiumStatePaymentOption -> Maybe PremiumPaymentOption
payment_option :: Maybe PremiumPaymentOption.PremiumPaymentOption
, PremiumStatePaymentOption -> Maybe Bool
is_current :: Maybe Bool
, PremiumStatePaymentOption -> Maybe Bool
is_upgrade :: Maybe Bool
, PremiumStatePaymentOption -> Maybe Text
last_transaction_id :: Maybe T.Text
}
deriving (PremiumStatePaymentOption -> PremiumStatePaymentOption -> Bool
(PremiumStatePaymentOption -> PremiumStatePaymentOption -> Bool)
-> (PremiumStatePaymentOption -> PremiumStatePaymentOption -> Bool)
-> Eq PremiumStatePaymentOption
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PremiumStatePaymentOption -> PremiumStatePaymentOption -> Bool
== :: PremiumStatePaymentOption -> PremiumStatePaymentOption -> Bool
$c/= :: PremiumStatePaymentOption -> PremiumStatePaymentOption -> Bool
/= :: PremiumStatePaymentOption -> PremiumStatePaymentOption -> Bool
Eq, Int -> PremiumStatePaymentOption -> ShowS
[PremiumStatePaymentOption] -> ShowS
PremiumStatePaymentOption -> String
(Int -> PremiumStatePaymentOption -> ShowS)
-> (PremiumStatePaymentOption -> String)
-> ([PremiumStatePaymentOption] -> ShowS)
-> Show PremiumStatePaymentOption
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PremiumStatePaymentOption -> ShowS
showsPrec :: Int -> PremiumStatePaymentOption -> ShowS
$cshow :: PremiumStatePaymentOption -> String
show :: PremiumStatePaymentOption -> String
$cshowList :: [PremiumStatePaymentOption] -> ShowS
showList :: [PremiumStatePaymentOption] -> ShowS
Show)
instance I.ShortShow PremiumStatePaymentOption where
shortShow :: PremiumStatePaymentOption -> String
shortShow PremiumStatePaymentOption
{ payment_option :: PremiumStatePaymentOption -> Maybe PremiumPaymentOption
payment_option = Maybe PremiumPaymentOption
payment_option_
, is_current :: PremiumStatePaymentOption -> Maybe Bool
is_current = Maybe Bool
is_current_
, is_upgrade :: PremiumStatePaymentOption -> Maybe Bool
is_upgrade = Maybe Bool
is_upgrade_
, last_transaction_id :: PremiumStatePaymentOption -> Maybe Text
last_transaction_id = Maybe Text
last_transaction_id_
}
= String
"PremiumStatePaymentOption"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"payment_option" String -> Maybe PremiumPaymentOption -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe PremiumPaymentOption
payment_option_
, String
"is_current" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_current_
, String
"is_upgrade" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_upgrade_
, String
"last_transaction_id" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
last_transaction_id_
]
instance AT.FromJSON PremiumStatePaymentOption where
parseJSON :: Value -> Parser PremiumStatePaymentOption
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
"premiumStatePaymentOption" -> Value -> Parser PremiumStatePaymentOption
parsePremiumStatePaymentOption Value
v
String
_ -> Parser PremiumStatePaymentOption
forall a. Monoid a => a
mempty
where
parsePremiumStatePaymentOption :: A.Value -> AT.Parser PremiumStatePaymentOption
parsePremiumStatePaymentOption :: Value -> Parser PremiumStatePaymentOption
parsePremiumStatePaymentOption = String
-> (Object -> Parser PremiumStatePaymentOption)
-> Value
-> Parser PremiumStatePaymentOption
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"PremiumStatePaymentOption" ((Object -> Parser PremiumStatePaymentOption)
-> Value -> Parser PremiumStatePaymentOption)
-> (Object -> Parser PremiumStatePaymentOption)
-> Value
-> Parser PremiumStatePaymentOption
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe PremiumPaymentOption
payment_option_ <- Object
o Object -> Key -> Parser (Maybe PremiumPaymentOption)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"payment_option"
Maybe Bool
is_current_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_current"
Maybe Bool
is_upgrade_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_upgrade"
Maybe Text
last_transaction_id_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"last_transaction_id"
PremiumStatePaymentOption -> Parser PremiumStatePaymentOption
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (PremiumStatePaymentOption -> Parser PremiumStatePaymentOption)
-> PremiumStatePaymentOption -> Parser PremiumStatePaymentOption
forall a b. (a -> b) -> a -> b
$ PremiumStatePaymentOption
{ payment_option :: Maybe PremiumPaymentOption
payment_option = Maybe PremiumPaymentOption
payment_option_
, is_current :: Maybe Bool
is_current = Maybe Bool
is_current_
, is_upgrade :: Maybe Bool
is_upgrade = Maybe Bool
is_upgrade_
, last_transaction_id :: Maybe Text
last_transaction_id = Maybe Text
last_transaction_id_
}
parseJSON Value
_ = Parser PremiumStatePaymentOption
forall a. Monoid a => a
mempty