module TD.Data.ResetPasswordResult
(ResetPasswordResult(..)) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
data ResetPasswordResult
= ResetPasswordResultOk
| ResetPasswordResultPending
{ ResetPasswordResult -> Maybe Int
pending_reset_date :: Maybe Int
}
| ResetPasswordResultDeclined
{ ResetPasswordResult -> Maybe Int
retry_date :: Maybe Int
}
deriving (ResetPasswordResult -> ResetPasswordResult -> Bool
(ResetPasswordResult -> ResetPasswordResult -> Bool)
-> (ResetPasswordResult -> ResetPasswordResult -> Bool)
-> Eq ResetPasswordResult
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ResetPasswordResult -> ResetPasswordResult -> Bool
== :: ResetPasswordResult -> ResetPasswordResult -> Bool
$c/= :: ResetPasswordResult -> ResetPasswordResult -> Bool
/= :: ResetPasswordResult -> ResetPasswordResult -> Bool
Eq, Int -> ResetPasswordResult -> ShowS
[ResetPasswordResult] -> ShowS
ResetPasswordResult -> String
(Int -> ResetPasswordResult -> ShowS)
-> (ResetPasswordResult -> String)
-> ([ResetPasswordResult] -> ShowS)
-> Show ResetPasswordResult
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ResetPasswordResult -> ShowS
showsPrec :: Int -> ResetPasswordResult -> ShowS
$cshow :: ResetPasswordResult -> String
show :: ResetPasswordResult -> String
$cshowList :: [ResetPasswordResult] -> ShowS
showList :: [ResetPasswordResult] -> ShowS
Show)
instance I.ShortShow ResetPasswordResult where
shortShow :: ResetPasswordResult -> String
shortShow ResetPasswordResult
ResetPasswordResultOk
= String
"ResetPasswordResultOk"
shortShow ResetPasswordResultPending
{ pending_reset_date :: ResetPasswordResult -> Maybe Int
pending_reset_date = Maybe Int
pending_reset_date_
}
= String
"ResetPasswordResultPending"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"pending_reset_date" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
pending_reset_date_
]
shortShow ResetPasswordResultDeclined
{ retry_date :: ResetPasswordResult -> Maybe Int
retry_date = Maybe Int
retry_date_
}
= String
"ResetPasswordResultDeclined"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"retry_date" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
retry_date_
]
instance AT.FromJSON ResetPasswordResult where
parseJSON :: Value -> Parser ResetPasswordResult
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
"resetPasswordResultOk" -> ResetPasswordResult -> Parser ResetPasswordResult
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ResetPasswordResult
ResetPasswordResultOk
String
"resetPasswordResultPending" -> Value -> Parser ResetPasswordResult
parseResetPasswordResultPending Value
v
String
"resetPasswordResultDeclined" -> Value -> Parser ResetPasswordResult
parseResetPasswordResultDeclined Value
v
String
_ -> Parser ResetPasswordResult
forall a. Monoid a => a
mempty
where
parseResetPasswordResultPending :: A.Value -> AT.Parser ResetPasswordResult
parseResetPasswordResultPending :: Value -> Parser ResetPasswordResult
parseResetPasswordResultPending = String
-> (Object -> Parser ResetPasswordResult)
-> Value
-> Parser ResetPasswordResult
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"ResetPasswordResultPending" ((Object -> Parser ResetPasswordResult)
-> Value -> Parser ResetPasswordResult)
-> (Object -> Parser ResetPasswordResult)
-> Value
-> Parser ResetPasswordResult
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Int
pending_reset_date_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"pending_reset_date"
ResetPasswordResult -> Parser ResetPasswordResult
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ResetPasswordResult -> Parser ResetPasswordResult)
-> ResetPasswordResult -> Parser ResetPasswordResult
forall a b. (a -> b) -> a -> b
$ ResetPasswordResultPending
{ pending_reset_date :: Maybe Int
pending_reset_date = Maybe Int
pending_reset_date_
}
parseResetPasswordResultDeclined :: A.Value -> AT.Parser ResetPasswordResult
parseResetPasswordResultDeclined :: Value -> Parser ResetPasswordResult
parseResetPasswordResultDeclined = String
-> (Object -> Parser ResetPasswordResult)
-> Value
-> Parser ResetPasswordResult
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"ResetPasswordResultDeclined" ((Object -> Parser ResetPasswordResult)
-> Value -> Parser ResetPasswordResult)
-> (Object -> Parser ResetPasswordResult)
-> Value
-> Parser ResetPasswordResult
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Int
retry_date_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"retry_date"
ResetPasswordResult -> Parser ResetPasswordResult
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (ResetPasswordResult -> Parser ResetPasswordResult)
-> ResetPasswordResult -> Parser ResetPasswordResult
forall a b. (a -> b) -> a -> b
$ ResetPasswordResultDeclined
{ retry_date :: Maybe Int
retry_date = Maybe Int
retry_date_
}
parseJSON Value
_ = Parser ResetPasswordResult
forall a. Monoid a => a
mempty