module TD.Data.PremiumGiftCodePaymentOption
(PremiumGiftCodePaymentOption(..)) 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
import qualified TD.Data.Sticker as Sticker
data PremiumGiftCodePaymentOption
= PremiumGiftCodePaymentOption
{ PremiumGiftCodePaymentOption -> Maybe Text
currency :: Maybe T.Text
, PremiumGiftCodePaymentOption -> Maybe Int
amount :: Maybe Int
, PremiumGiftCodePaymentOption -> Maybe Int
discount_percentage :: Maybe Int
, PremiumGiftCodePaymentOption -> Maybe Int
winner_count :: Maybe Int
, PremiumGiftCodePaymentOption -> Maybe Int
month_count :: Maybe Int
, PremiumGiftCodePaymentOption -> Maybe Text
store_product_id :: Maybe T.Text
, PremiumGiftCodePaymentOption -> Maybe Int
store_product_quantity :: Maybe Int
, PremiumGiftCodePaymentOption -> Maybe Sticker
sticker :: Maybe Sticker.Sticker
}
deriving (PremiumGiftCodePaymentOption
-> PremiumGiftCodePaymentOption -> Bool
(PremiumGiftCodePaymentOption
-> PremiumGiftCodePaymentOption -> Bool)
-> (PremiumGiftCodePaymentOption
-> PremiumGiftCodePaymentOption -> Bool)
-> Eq PremiumGiftCodePaymentOption
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PremiumGiftCodePaymentOption
-> PremiumGiftCodePaymentOption -> Bool
== :: PremiumGiftCodePaymentOption
-> PremiumGiftCodePaymentOption -> Bool
$c/= :: PremiumGiftCodePaymentOption
-> PremiumGiftCodePaymentOption -> Bool
/= :: PremiumGiftCodePaymentOption
-> PremiumGiftCodePaymentOption -> Bool
Eq, Int -> PremiumGiftCodePaymentOption -> ShowS
[PremiumGiftCodePaymentOption] -> ShowS
PremiumGiftCodePaymentOption -> String
(Int -> PremiumGiftCodePaymentOption -> ShowS)
-> (PremiumGiftCodePaymentOption -> String)
-> ([PremiumGiftCodePaymentOption] -> ShowS)
-> Show PremiumGiftCodePaymentOption
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PremiumGiftCodePaymentOption -> ShowS
showsPrec :: Int -> PremiumGiftCodePaymentOption -> ShowS
$cshow :: PremiumGiftCodePaymentOption -> String
show :: PremiumGiftCodePaymentOption -> String
$cshowList :: [PremiumGiftCodePaymentOption] -> ShowS
showList :: [PremiumGiftCodePaymentOption] -> ShowS
Show)
instance I.ShortShow PremiumGiftCodePaymentOption where
shortShow :: PremiumGiftCodePaymentOption -> String
shortShow PremiumGiftCodePaymentOption
{ currency :: PremiumGiftCodePaymentOption -> Maybe Text
currency = Maybe Text
currency_
, amount :: PremiumGiftCodePaymentOption -> Maybe Int
amount = Maybe Int
amount_
, discount_percentage :: PremiumGiftCodePaymentOption -> Maybe Int
discount_percentage = Maybe Int
discount_percentage_
, winner_count :: PremiumGiftCodePaymentOption -> Maybe Int
winner_count = Maybe Int
winner_count_
, month_count :: PremiumGiftCodePaymentOption -> Maybe Int
month_count = Maybe Int
month_count_
, store_product_id :: PremiumGiftCodePaymentOption -> Maybe Text
store_product_id = Maybe Text
store_product_id_
, store_product_quantity :: PremiumGiftCodePaymentOption -> Maybe Int
store_product_quantity = Maybe Int
store_product_quantity_
, sticker :: PremiumGiftCodePaymentOption -> Maybe Sticker
sticker = Maybe Sticker
sticker_
}
= String
"PremiumGiftCodePaymentOption"
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
"discount_percentage" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
discount_percentage_
, String
"winner_count" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
winner_count_
, String
"month_count" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
month_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
"store_product_quantity" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
store_product_quantity_
, String
"sticker" String -> Maybe Sticker -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Sticker
sticker_
]
instance AT.FromJSON PremiumGiftCodePaymentOption where
parseJSON :: Value -> Parser PremiumGiftCodePaymentOption
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
"premiumGiftCodePaymentOption" -> Value -> Parser PremiumGiftCodePaymentOption
parsePremiumGiftCodePaymentOption Value
v
String
_ -> Parser PremiumGiftCodePaymentOption
forall a. Monoid a => a
mempty
where
parsePremiumGiftCodePaymentOption :: A.Value -> AT.Parser PremiumGiftCodePaymentOption
parsePremiumGiftCodePaymentOption :: Value -> Parser PremiumGiftCodePaymentOption
parsePremiumGiftCodePaymentOption = String
-> (Object -> Parser PremiumGiftCodePaymentOption)
-> Value
-> Parser PremiumGiftCodePaymentOption
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"PremiumGiftCodePaymentOption" ((Object -> Parser PremiumGiftCodePaymentOption)
-> Value -> Parser PremiumGiftCodePaymentOption)
-> (Object -> Parser PremiumGiftCodePaymentOption)
-> Value
-> Parser PremiumGiftCodePaymentOption
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
discount_percentage_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"discount_percentage"
Maybe Int
winner_count_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"winner_count"
Maybe Int
month_count_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"month_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 Int
store_product_quantity_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"store_product_quantity"
Maybe Sticker
sticker_ <- Object
o Object -> Key -> Parser (Maybe Sticker)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"sticker"
PremiumGiftCodePaymentOption -> Parser PremiumGiftCodePaymentOption
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (PremiumGiftCodePaymentOption
-> Parser PremiumGiftCodePaymentOption)
-> PremiumGiftCodePaymentOption
-> Parser PremiumGiftCodePaymentOption
forall a b. (a -> b) -> a -> b
$ PremiumGiftCodePaymentOption
{ currency :: Maybe Text
currency = Maybe Text
currency_
, amount :: Maybe Int
amount = Maybe Int
amount_
, discount_percentage :: Maybe Int
discount_percentage = Maybe Int
discount_percentage_
, winner_count :: Maybe Int
winner_count = Maybe Int
winner_count_
, month_count :: Maybe Int
month_count = Maybe Int
month_count_
, store_product_id :: Maybe Text
store_product_id = Maybe Text
store_product_id_
, store_product_quantity :: Maybe Int
store_product_quantity = Maybe Int
store_product_quantity_
, sticker :: Maybe Sticker
sticker = Maybe Sticker
sticker_
}
parseJSON Value
_ = Parser PremiumGiftCodePaymentOption
forall a. Monoid a => a
mempty