module TD.Data.AuthenticationCodeInfo
(AuthenticationCodeInfo(..)) 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
import qualified TD.Data.AuthenticationCodeType as AuthenticationCodeType
data AuthenticationCodeInfo
= AuthenticationCodeInfo
{ AuthenticationCodeInfo -> Maybe Text
phone_number :: Maybe T.Text
, AuthenticationCodeInfo -> Maybe AuthenticationCodeType
_type :: Maybe AuthenticationCodeType.AuthenticationCodeType
, AuthenticationCodeInfo -> Maybe AuthenticationCodeType
next_type :: Maybe AuthenticationCodeType.AuthenticationCodeType
, AuthenticationCodeInfo -> Maybe Int
timeout :: Maybe Int
}
deriving (AuthenticationCodeInfo -> AuthenticationCodeInfo -> Bool
(AuthenticationCodeInfo -> AuthenticationCodeInfo -> Bool)
-> (AuthenticationCodeInfo -> AuthenticationCodeInfo -> Bool)
-> Eq AuthenticationCodeInfo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AuthenticationCodeInfo -> AuthenticationCodeInfo -> Bool
== :: AuthenticationCodeInfo -> AuthenticationCodeInfo -> Bool
$c/= :: AuthenticationCodeInfo -> AuthenticationCodeInfo -> Bool
/= :: AuthenticationCodeInfo -> AuthenticationCodeInfo -> Bool
Eq, Int -> AuthenticationCodeInfo -> ShowS
[AuthenticationCodeInfo] -> ShowS
AuthenticationCodeInfo -> String
(Int -> AuthenticationCodeInfo -> ShowS)
-> (AuthenticationCodeInfo -> String)
-> ([AuthenticationCodeInfo] -> ShowS)
-> Show AuthenticationCodeInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AuthenticationCodeInfo -> ShowS
showsPrec :: Int -> AuthenticationCodeInfo -> ShowS
$cshow :: AuthenticationCodeInfo -> String
show :: AuthenticationCodeInfo -> String
$cshowList :: [AuthenticationCodeInfo] -> ShowS
showList :: [AuthenticationCodeInfo] -> ShowS
Show)
instance I.ShortShow AuthenticationCodeInfo where
shortShow :: AuthenticationCodeInfo -> String
shortShow AuthenticationCodeInfo
{ phone_number :: AuthenticationCodeInfo -> Maybe Text
phone_number = Maybe Text
phone_number_
, _type :: AuthenticationCodeInfo -> Maybe AuthenticationCodeType
_type = Maybe AuthenticationCodeType
_type_
, next_type :: AuthenticationCodeInfo -> Maybe AuthenticationCodeType
next_type = Maybe AuthenticationCodeType
next_type_
, timeout :: AuthenticationCodeInfo -> Maybe Int
timeout = Maybe Int
timeout_
}
= String
"AuthenticationCodeInfo"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"phone_number" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
phone_number_
, String
"_type" String -> Maybe AuthenticationCodeType -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe AuthenticationCodeType
_type_
, String
"next_type" String -> Maybe AuthenticationCodeType -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe AuthenticationCodeType
next_type_
, String
"timeout" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
timeout_
]
instance AT.FromJSON AuthenticationCodeInfo where
parseJSON :: Value -> Parser AuthenticationCodeInfo
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
"authenticationCodeInfo" -> Value -> Parser AuthenticationCodeInfo
parseAuthenticationCodeInfo Value
v
String
_ -> Parser AuthenticationCodeInfo
forall a. Monoid a => a
mempty
where
parseAuthenticationCodeInfo :: A.Value -> AT.Parser AuthenticationCodeInfo
parseAuthenticationCodeInfo :: Value -> Parser AuthenticationCodeInfo
parseAuthenticationCodeInfo = String
-> (Object -> Parser AuthenticationCodeInfo)
-> Value
-> Parser AuthenticationCodeInfo
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"AuthenticationCodeInfo" ((Object -> Parser AuthenticationCodeInfo)
-> Value -> Parser AuthenticationCodeInfo)
-> (Object -> Parser AuthenticationCodeInfo)
-> Value
-> Parser AuthenticationCodeInfo
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Text
phone_number_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"phone_number"
Maybe AuthenticationCodeType
_type_ <- Object
o Object -> Key -> Parser (Maybe AuthenticationCodeType)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"type"
Maybe AuthenticationCodeType
next_type_ <- Object
o Object -> Key -> Parser (Maybe AuthenticationCodeType)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"next_type"
Maybe Int
timeout_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"timeout"
AuthenticationCodeInfo -> Parser AuthenticationCodeInfo
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (AuthenticationCodeInfo -> Parser AuthenticationCodeInfo)
-> AuthenticationCodeInfo -> Parser AuthenticationCodeInfo
forall a b. (a -> b) -> a -> b
$ AuthenticationCodeInfo
{ phone_number :: Maybe Text
phone_number = Maybe Text
phone_number_
, _type :: Maybe AuthenticationCodeType
_type = Maybe AuthenticationCodeType
_type_
, next_type :: Maybe AuthenticationCodeType
next_type = Maybe AuthenticationCodeType
next_type_
, timeout :: Maybe Int
timeout = Maybe Int
timeout_
}
parseJSON Value
_ = Parser AuthenticationCodeInfo
forall a. Monoid a => a
mempty