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