module TD.Data.AffiliateProgramInfo
(AffiliateProgramInfo(..)) 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.AffiliateProgramParameters as AffiliateProgramParameters
import qualified TD.Data.StarAmount as StarAmount
data AffiliateProgramInfo
= AffiliateProgramInfo
{ AffiliateProgramInfo -> Maybe AffiliateProgramParameters
parameters :: Maybe AffiliateProgramParameters.AffiliateProgramParameters
, AffiliateProgramInfo -> Maybe Int
end_date :: Maybe Int
, AffiliateProgramInfo -> Maybe StarAmount
daily_revenue_per_user_amount :: Maybe StarAmount.StarAmount
}
deriving (AffiliateProgramInfo -> AffiliateProgramInfo -> Bool
(AffiliateProgramInfo -> AffiliateProgramInfo -> Bool)
-> (AffiliateProgramInfo -> AffiliateProgramInfo -> Bool)
-> Eq AffiliateProgramInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AffiliateProgramInfo -> AffiliateProgramInfo -> Bool
== :: AffiliateProgramInfo -> AffiliateProgramInfo -> Bool
$c/= :: AffiliateProgramInfo -> AffiliateProgramInfo -> Bool
/= :: AffiliateProgramInfo -> AffiliateProgramInfo -> Bool
Eq, Int -> AffiliateProgramInfo -> ShowS
[AffiliateProgramInfo] -> ShowS
AffiliateProgramInfo -> String
(Int -> AffiliateProgramInfo -> ShowS)
-> (AffiliateProgramInfo -> String)
-> ([AffiliateProgramInfo] -> ShowS)
-> Show AffiliateProgramInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AffiliateProgramInfo -> ShowS
showsPrec :: Int -> AffiliateProgramInfo -> ShowS
$cshow :: AffiliateProgramInfo -> String
show :: AffiliateProgramInfo -> String
$cshowList :: [AffiliateProgramInfo] -> ShowS
showList :: [AffiliateProgramInfo] -> ShowS
Show)
instance I.ShortShow AffiliateProgramInfo where
shortShow :: AffiliateProgramInfo -> String
shortShow AffiliateProgramInfo
{ parameters :: AffiliateProgramInfo -> Maybe AffiliateProgramParameters
parameters = Maybe AffiliateProgramParameters
parameters_
, end_date :: AffiliateProgramInfo -> Maybe Int
end_date = Maybe Int
end_date_
, daily_revenue_per_user_amount :: AffiliateProgramInfo -> Maybe StarAmount
daily_revenue_per_user_amount = Maybe StarAmount
daily_revenue_per_user_amount_
}
= String
"AffiliateProgramInfo"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"parameters" String -> Maybe AffiliateProgramParameters -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe AffiliateProgramParameters
parameters_
, String
"end_date" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
end_date_
, String
"daily_revenue_per_user_amount" String -> Maybe StarAmount -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe StarAmount
daily_revenue_per_user_amount_
]
instance AT.FromJSON AffiliateProgramInfo where
parseJSON :: Value -> Parser AffiliateProgramInfo
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
"affiliateProgramInfo" -> Value -> Parser AffiliateProgramInfo
parseAffiliateProgramInfo Value
v
String
_ -> Parser AffiliateProgramInfo
forall a. Monoid a => a
mempty
where
parseAffiliateProgramInfo :: A.Value -> AT.Parser AffiliateProgramInfo
parseAffiliateProgramInfo :: Value -> Parser AffiliateProgramInfo
parseAffiliateProgramInfo = String
-> (Object -> Parser AffiliateProgramInfo)
-> Value
-> Parser AffiliateProgramInfo
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"AffiliateProgramInfo" ((Object -> Parser AffiliateProgramInfo)
-> Value -> Parser AffiliateProgramInfo)
-> (Object -> Parser AffiliateProgramInfo)
-> Value
-> Parser AffiliateProgramInfo
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe AffiliateProgramParameters
parameters_ <- Object
o Object -> Key -> Parser (Maybe AffiliateProgramParameters)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"parameters"
Maybe Int
end_date_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"end_date"
Maybe StarAmount
daily_revenue_per_user_amount_ <- Object
o Object -> Key -> Parser (Maybe StarAmount)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"daily_revenue_per_user_amount"
AffiliateProgramInfo -> Parser AffiliateProgramInfo
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (AffiliateProgramInfo -> Parser AffiliateProgramInfo)
-> AffiliateProgramInfo -> Parser AffiliateProgramInfo
forall a b. (a -> b) -> a -> b
$ AffiliateProgramInfo
{ parameters :: Maybe AffiliateProgramParameters
parameters = Maybe AffiliateProgramParameters
parameters_
, end_date :: Maybe Int
end_date = Maybe Int
end_date_
, daily_revenue_per_user_amount :: Maybe StarAmount
daily_revenue_per_user_amount = Maybe StarAmount
daily_revenue_per_user_amount_
}
parseJSON Value
_ = Parser AffiliateProgramInfo
forall a. Monoid a => a
mempty