module TD.Data.PremiumGiveawayPaymentOption
(PremiumGiveawayPaymentOption(..)) 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 PremiumGiveawayPaymentOption
= PremiumGiveawayPaymentOption
{ PremiumGiveawayPaymentOption -> Maybe Text
currency :: Maybe T.Text
, PremiumGiveawayPaymentOption -> Maybe Int
amount :: Maybe Int
, PremiumGiveawayPaymentOption -> Maybe Int
winner_count :: Maybe Int
, PremiumGiveawayPaymentOption -> Maybe Int
month_count :: Maybe Int
, PremiumGiveawayPaymentOption -> Maybe Text
store_product_id :: Maybe T.Text
, PremiumGiveawayPaymentOption -> Maybe Int
store_product_quantity :: Maybe Int
}
deriving (PremiumGiveawayPaymentOption
-> PremiumGiveawayPaymentOption -> Bool
(PremiumGiveawayPaymentOption
-> PremiumGiveawayPaymentOption -> Bool)
-> (PremiumGiveawayPaymentOption
-> PremiumGiveawayPaymentOption -> Bool)
-> Eq PremiumGiveawayPaymentOption
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PremiumGiveawayPaymentOption
-> PremiumGiveawayPaymentOption -> Bool
== :: PremiumGiveawayPaymentOption
-> PremiumGiveawayPaymentOption -> Bool
$c/= :: PremiumGiveawayPaymentOption
-> PremiumGiveawayPaymentOption -> Bool
/= :: PremiumGiveawayPaymentOption
-> PremiumGiveawayPaymentOption -> Bool
Eq, Int -> PremiumGiveawayPaymentOption -> ShowS
[PremiumGiveawayPaymentOption] -> ShowS
PremiumGiveawayPaymentOption -> String
(Int -> PremiumGiveawayPaymentOption -> ShowS)
-> (PremiumGiveawayPaymentOption -> String)
-> ([PremiumGiveawayPaymentOption] -> ShowS)
-> Show PremiumGiveawayPaymentOption
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PremiumGiveawayPaymentOption -> ShowS
showsPrec :: Int -> PremiumGiveawayPaymentOption -> ShowS
$cshow :: PremiumGiveawayPaymentOption -> String
show :: PremiumGiveawayPaymentOption -> String
$cshowList :: [PremiumGiveawayPaymentOption] -> ShowS
showList :: [PremiumGiveawayPaymentOption] -> ShowS
Show)
instance I.ShortShow PremiumGiveawayPaymentOption where
shortShow :: PremiumGiveawayPaymentOption -> String
shortShow PremiumGiveawayPaymentOption
{ currency :: PremiumGiveawayPaymentOption -> Maybe Text
currency = Maybe Text
currency_
, amount :: PremiumGiveawayPaymentOption -> Maybe Int
amount = Maybe Int
amount_
, winner_count :: PremiumGiveawayPaymentOption -> Maybe Int
winner_count = Maybe Int
winner_count_
, month_count :: PremiumGiveawayPaymentOption -> Maybe Int
month_count = Maybe Int
month_count_
, store_product_id :: PremiumGiveawayPaymentOption -> Maybe Text
store_product_id = Maybe Text
store_product_id_
, store_product_quantity :: PremiumGiveawayPaymentOption -> Maybe Int
store_product_quantity = Maybe Int
store_product_quantity_
}
= String
"PremiumGiveawayPaymentOption"
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
"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_
]
instance AT.FromJSON PremiumGiveawayPaymentOption where
parseJSON :: Value -> Parser PremiumGiveawayPaymentOption
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
"premiumGiveawayPaymentOption" -> Value -> Parser PremiumGiveawayPaymentOption
parsePremiumGiveawayPaymentOption Value
v
String
_ -> Parser PremiumGiveawayPaymentOption
forall a. Monoid a => a
mempty
where
parsePremiumGiveawayPaymentOption :: A.Value -> AT.Parser PremiumGiveawayPaymentOption
parsePremiumGiveawayPaymentOption :: Value -> Parser PremiumGiveawayPaymentOption
parsePremiumGiveawayPaymentOption = String
-> (Object -> Parser PremiumGiveawayPaymentOption)
-> Value
-> Parser PremiumGiveawayPaymentOption
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"PremiumGiveawayPaymentOption" ((Object -> Parser PremiumGiveawayPaymentOption)
-> Value -> Parser PremiumGiveawayPaymentOption)
-> (Object -> Parser PremiumGiveawayPaymentOption)
-> Value
-> Parser PremiumGiveawayPaymentOption
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
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"
PremiumGiveawayPaymentOption -> Parser PremiumGiveawayPaymentOption
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (PremiumGiveawayPaymentOption
-> Parser PremiumGiveawayPaymentOption)
-> PremiumGiveawayPaymentOption
-> Parser PremiumGiveawayPaymentOption
forall a b. (a -> b) -> a -> b
$ PremiumGiveawayPaymentOption
{ currency :: Maybe Text
currency = Maybe Text
currency_
, amount :: Maybe Int
amount = Maybe Int
amount_
, 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_
}
parseJSON Value
_ = Parser PremiumGiveawayPaymentOption
forall a. Monoid a => a
mempty