module TD.Data.StarPaymentOption
(StarPaymentOption(..)) 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
data StarPaymentOption
= StarPaymentOption
{ StarPaymentOption -> Maybe Text
currency :: Maybe T.Text
, StarPaymentOption -> Maybe Int
amount :: Maybe Int
, StarPaymentOption -> Maybe Int
star_count :: Maybe Int
, StarPaymentOption -> Maybe Text
store_product_id :: Maybe T.Text
, StarPaymentOption -> Maybe Bool
is_additional :: Maybe Bool
}
deriving (StarPaymentOption -> StarPaymentOption -> Bool
(StarPaymentOption -> StarPaymentOption -> Bool)
-> (StarPaymentOption -> StarPaymentOption -> Bool)
-> Eq StarPaymentOption
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: StarPaymentOption -> StarPaymentOption -> Bool
== :: StarPaymentOption -> StarPaymentOption -> Bool
$c/= :: StarPaymentOption -> StarPaymentOption -> Bool
/= :: StarPaymentOption -> StarPaymentOption -> Bool
Eq, Int -> StarPaymentOption -> ShowS
[StarPaymentOption] -> ShowS
StarPaymentOption -> String
(Int -> StarPaymentOption -> ShowS)
-> (StarPaymentOption -> String)
-> ([StarPaymentOption] -> ShowS)
-> Show StarPaymentOption
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> StarPaymentOption -> ShowS
showsPrec :: Int -> StarPaymentOption -> ShowS
$cshow :: StarPaymentOption -> String
show :: StarPaymentOption -> String
$cshowList :: [StarPaymentOption] -> ShowS
showList :: [StarPaymentOption] -> ShowS
Show)
instance I.ShortShow StarPaymentOption where
shortShow :: StarPaymentOption -> String
shortShow StarPaymentOption
{ currency :: StarPaymentOption -> Maybe Text
currency = Maybe Text
currency_
, amount :: StarPaymentOption -> Maybe Int
amount = Maybe Int
amount_
, star_count :: StarPaymentOption -> Maybe Int
star_count = Maybe Int
star_count_
, store_product_id :: StarPaymentOption -> Maybe Text
store_product_id = Maybe Text
store_product_id_
, is_additional :: StarPaymentOption -> Maybe Bool
is_additional = Maybe Bool
is_additional_
}
= String
"StarPaymentOption"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"currency" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
currency_
, String
"amount" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
amount_
, String
"star_count" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
star_count_
, String
"store_product_id" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
store_product_id_
, String
"is_additional" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_additional_
]
instance AT.FromJSON StarPaymentOption where
parseJSON :: Value -> Parser StarPaymentOption
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
"starPaymentOption" -> Value -> Parser StarPaymentOption
parseStarPaymentOption Value
v
String
_ -> Parser StarPaymentOption
forall a. Monoid a => a
mempty
where
parseStarPaymentOption :: A.Value -> AT.Parser StarPaymentOption
parseStarPaymentOption :: Value -> Parser StarPaymentOption
parseStarPaymentOption = String
-> (Object -> Parser StarPaymentOption)
-> Value
-> Parser StarPaymentOption
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"StarPaymentOption" ((Object -> Parser StarPaymentOption)
-> Value -> Parser StarPaymentOption)
-> (Object -> Parser StarPaymentOption)
-> Value
-> Parser StarPaymentOption
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Text
currency_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"currency"
Maybe Int
amount_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"amount"
Maybe Int
star_count_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"star_count"
Maybe Text
store_product_id_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"store_product_id"
Maybe Bool
is_additional_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_additional"
StarPaymentOption -> Parser StarPaymentOption
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (StarPaymentOption -> Parser StarPaymentOption)
-> StarPaymentOption -> Parser StarPaymentOption
forall a b. (a -> b) -> a -> b
$ StarPaymentOption
{ currency :: Maybe Text
currency = Maybe Text
currency_
, amount :: Maybe Int
amount = Maybe Int
amount_
, star_count :: Maybe Int
star_count = Maybe Int
star_count_
, store_product_id :: Maybe Text
store_product_id = Maybe Text
store_product_id_
, is_additional :: Maybe Bool
is_additional = Maybe Bool
is_additional_
}
parseJSON Value
_ = Parser StarPaymentOption
forall a. Monoid a => a
mempty