module TD.Data.RevenueWithdrawalState
(RevenueWithdrawalState(..)) 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 RevenueWithdrawalState
= RevenueWithdrawalStatePending
| RevenueWithdrawalStateSucceeded
{ RevenueWithdrawalState -> Maybe Int
date :: Maybe Int
, RevenueWithdrawalState -> Maybe Text
url :: Maybe T.Text
}
| RevenueWithdrawalStateFailed
deriving (RevenueWithdrawalState -> RevenueWithdrawalState -> Bool
(RevenueWithdrawalState -> RevenueWithdrawalState -> Bool)
-> (RevenueWithdrawalState -> RevenueWithdrawalState -> Bool)
-> Eq RevenueWithdrawalState
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: RevenueWithdrawalState -> RevenueWithdrawalState -> Bool
== :: RevenueWithdrawalState -> RevenueWithdrawalState -> Bool
$c/= :: RevenueWithdrawalState -> RevenueWithdrawalState -> Bool
/= :: RevenueWithdrawalState -> RevenueWithdrawalState -> Bool
Eq, Int -> RevenueWithdrawalState -> ShowS
[RevenueWithdrawalState] -> ShowS
RevenueWithdrawalState -> String
(Int -> RevenueWithdrawalState -> ShowS)
-> (RevenueWithdrawalState -> String)
-> ([RevenueWithdrawalState] -> ShowS)
-> Show RevenueWithdrawalState
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RevenueWithdrawalState -> ShowS
showsPrec :: Int -> RevenueWithdrawalState -> ShowS
$cshow :: RevenueWithdrawalState -> String
show :: RevenueWithdrawalState -> String
$cshowList :: [RevenueWithdrawalState] -> ShowS
showList :: [RevenueWithdrawalState] -> ShowS
Show)
instance I.ShortShow RevenueWithdrawalState where
shortShow :: RevenueWithdrawalState -> String
shortShow RevenueWithdrawalState
RevenueWithdrawalStatePending
= String
"RevenueWithdrawalStatePending"
shortShow RevenueWithdrawalStateSucceeded
{ date :: RevenueWithdrawalState -> Maybe Int
date = Maybe Int
date_
, url :: RevenueWithdrawalState -> Maybe Text
url = Maybe Text
url_
}
= String
"RevenueWithdrawalStateSucceeded"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"date" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
date_
, String
"url" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
url_
]
shortShow RevenueWithdrawalState
RevenueWithdrawalStateFailed
= String
"RevenueWithdrawalStateFailed"
instance AT.FromJSON RevenueWithdrawalState where
parseJSON :: Value -> Parser RevenueWithdrawalState
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
"revenueWithdrawalStatePending" -> RevenueWithdrawalState -> Parser RevenueWithdrawalState
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure RevenueWithdrawalState
RevenueWithdrawalStatePending
String
"revenueWithdrawalStateSucceeded" -> Value -> Parser RevenueWithdrawalState
parseRevenueWithdrawalStateSucceeded Value
v
String
"revenueWithdrawalStateFailed" -> RevenueWithdrawalState -> Parser RevenueWithdrawalState
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure RevenueWithdrawalState
RevenueWithdrawalStateFailed
String
_ -> Parser RevenueWithdrawalState
forall a. Monoid a => a
mempty
where
parseRevenueWithdrawalStateSucceeded :: A.Value -> AT.Parser RevenueWithdrawalState
parseRevenueWithdrawalStateSucceeded :: Value -> Parser RevenueWithdrawalState
parseRevenueWithdrawalStateSucceeded = String
-> (Object -> Parser RevenueWithdrawalState)
-> Value
-> Parser RevenueWithdrawalState
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"RevenueWithdrawalStateSucceeded" ((Object -> Parser RevenueWithdrawalState)
-> Value -> Parser RevenueWithdrawalState)
-> (Object -> Parser RevenueWithdrawalState)
-> Value
-> Parser RevenueWithdrawalState
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Int
date_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"date"
Maybe Text
url_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"url"
RevenueWithdrawalState -> Parser RevenueWithdrawalState
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (RevenueWithdrawalState -> Parser RevenueWithdrawalState)
-> RevenueWithdrawalState -> Parser RevenueWithdrawalState
forall a b. (a -> b) -> a -> b
$ RevenueWithdrawalStateSucceeded
{ date :: Maybe Int
date = Maybe Int
date_
, url :: Maybe Text
url = Maybe Text
url_
}
parseJSON Value
_ = Parser RevenueWithdrawalState
forall a. Monoid a => a
mempty