module TD.Data.CanTransferOwnershipResult
(CanTransferOwnershipResult(..)) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
data CanTransferOwnershipResult
= CanTransferOwnershipResultOk
| CanTransferOwnershipResultPasswordNeeded
| CanTransferOwnershipResultPasswordTooFresh
{ CanTransferOwnershipResult -> Maybe Int
retry_after :: Maybe Int
}
| CanTransferOwnershipResultSessionTooFresh
{ retry_after :: Maybe Int
}
deriving (CanTransferOwnershipResult -> CanTransferOwnershipResult -> Bool
(CanTransferOwnershipResult -> CanTransferOwnershipResult -> Bool)
-> (CanTransferOwnershipResult
-> CanTransferOwnershipResult -> Bool)
-> Eq CanTransferOwnershipResult
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CanTransferOwnershipResult -> CanTransferOwnershipResult -> Bool
== :: CanTransferOwnershipResult -> CanTransferOwnershipResult -> Bool
$c/= :: CanTransferOwnershipResult -> CanTransferOwnershipResult -> Bool
/= :: CanTransferOwnershipResult -> CanTransferOwnershipResult -> Bool
Eq, Int -> CanTransferOwnershipResult -> ShowS
[CanTransferOwnershipResult] -> ShowS
CanTransferOwnershipResult -> String
(Int -> CanTransferOwnershipResult -> ShowS)
-> (CanTransferOwnershipResult -> String)
-> ([CanTransferOwnershipResult] -> ShowS)
-> Show CanTransferOwnershipResult
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CanTransferOwnershipResult -> ShowS
showsPrec :: Int -> CanTransferOwnershipResult -> ShowS
$cshow :: CanTransferOwnershipResult -> String
show :: CanTransferOwnershipResult -> String
$cshowList :: [CanTransferOwnershipResult] -> ShowS
showList :: [CanTransferOwnershipResult] -> ShowS
Show)
instance I.ShortShow CanTransferOwnershipResult where
shortShow :: CanTransferOwnershipResult -> String
shortShow CanTransferOwnershipResult
CanTransferOwnershipResultOk
= String
"CanTransferOwnershipResultOk"
shortShow CanTransferOwnershipResult
CanTransferOwnershipResultPasswordNeeded
= String
"CanTransferOwnershipResultPasswordNeeded"
shortShow CanTransferOwnershipResultPasswordTooFresh
{ retry_after :: CanTransferOwnershipResult -> Maybe Int
retry_after = Maybe Int
retry_after_
}
= String
"CanTransferOwnershipResultPasswordTooFresh"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"retry_after" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
retry_after_
]
shortShow CanTransferOwnershipResultSessionTooFresh
{ retry_after :: CanTransferOwnershipResult -> Maybe Int
retry_after = Maybe Int
retry_after_
}
= String
"CanTransferOwnershipResultSessionTooFresh"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"retry_after" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
retry_after_
]
instance AT.FromJSON CanTransferOwnershipResult where
parseJSON :: Value -> Parser CanTransferOwnershipResult
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
"canTransferOwnershipResultOk" -> CanTransferOwnershipResult -> Parser CanTransferOwnershipResult
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure CanTransferOwnershipResult
CanTransferOwnershipResultOk
String
"canTransferOwnershipResultPasswordNeeded" -> CanTransferOwnershipResult -> Parser CanTransferOwnershipResult
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure CanTransferOwnershipResult
CanTransferOwnershipResultPasswordNeeded
String
"canTransferOwnershipResultPasswordTooFresh" -> Value -> Parser CanTransferOwnershipResult
parseCanTransferOwnershipResultPasswordTooFresh Value
v
String
"canTransferOwnershipResultSessionTooFresh" -> Value -> Parser CanTransferOwnershipResult
parseCanTransferOwnershipResultSessionTooFresh Value
v
String
_ -> Parser CanTransferOwnershipResult
forall a. Monoid a => a
mempty
where
parseCanTransferOwnershipResultPasswordTooFresh :: A.Value -> AT.Parser CanTransferOwnershipResult
parseCanTransferOwnershipResultPasswordTooFresh :: Value -> Parser CanTransferOwnershipResult
parseCanTransferOwnershipResultPasswordTooFresh = String
-> (Object -> Parser CanTransferOwnershipResult)
-> Value
-> Parser CanTransferOwnershipResult
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"CanTransferOwnershipResultPasswordTooFresh" ((Object -> Parser CanTransferOwnershipResult)
-> Value -> Parser CanTransferOwnershipResult)
-> (Object -> Parser CanTransferOwnershipResult)
-> Value
-> Parser CanTransferOwnershipResult
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Int
retry_after_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"retry_after"
CanTransferOwnershipResult -> Parser CanTransferOwnershipResult
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (CanTransferOwnershipResult -> Parser CanTransferOwnershipResult)
-> CanTransferOwnershipResult -> Parser CanTransferOwnershipResult
forall a b. (a -> b) -> a -> b
$ CanTransferOwnershipResultPasswordTooFresh
{ retry_after :: Maybe Int
retry_after = Maybe Int
retry_after_
}
parseCanTransferOwnershipResultSessionTooFresh :: A.Value -> AT.Parser CanTransferOwnershipResult
parseCanTransferOwnershipResultSessionTooFresh :: Value -> Parser CanTransferOwnershipResult
parseCanTransferOwnershipResultSessionTooFresh = String
-> (Object -> Parser CanTransferOwnershipResult)
-> Value
-> Parser CanTransferOwnershipResult
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"CanTransferOwnershipResultSessionTooFresh" ((Object -> Parser CanTransferOwnershipResult)
-> Value -> Parser CanTransferOwnershipResult)
-> (Object -> Parser CanTransferOwnershipResult)
-> Value
-> Parser CanTransferOwnershipResult
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Int
retry_after_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"retry_after"
CanTransferOwnershipResult -> Parser CanTransferOwnershipResult
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (CanTransferOwnershipResult -> Parser CanTransferOwnershipResult)
-> CanTransferOwnershipResult -> Parser CanTransferOwnershipResult
forall a b. (a -> b) -> a -> b
$ CanTransferOwnershipResultSessionTooFresh
{ retry_after :: Maybe Int
retry_after = Maybe Int
retry_after_
}
parseJSON Value
_ = Parser CanTransferOwnershipResult
forall a. Monoid a => a
mempty