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