module TD.Data.AuthorizationState
  (AuthorizationState(..)) where

import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
import qualified TD.Data.EmailAddressAuthenticationCodeInfo as EmailAddressAuthenticationCodeInfo
import qualified TD.Data.EmailAddressResetState as EmailAddressResetState
import qualified TD.Data.AuthenticationCodeInfo as AuthenticationCodeInfo
import qualified Data.Text as T
import qualified TD.Data.TermsOfService as TermsOfService

-- | Represents the current authorization state of the TDLib client
data AuthorizationState
  = AuthorizationStateWaitTdlibParameters -- ^ Initialization parameters are needed. Call setTdlibParameters to provide them
  | AuthorizationStateWaitPhoneNumber -- ^ TDLib needs the user's phone number to authorize. Call setAuthenticationPhoneNumber to provide the phone number, or use requestQrCodeAuthentication or checkAuthenticationBotToken for other authentication options
  | AuthorizationStateWaitEmailAddress -- ^ TDLib needs the user's email address to authorize. Call setAuthenticationEmailAddress to provide the email address, or directly call checkAuthenticationEmailCode with Apple ID/Google ID token if allowed
    { AuthorizationState -> Maybe Bool
allow_apple_id  :: Maybe Bool -- ^ True, if authorization through Apple ID is allowed
    , AuthorizationState -> Maybe Bool
allow_google_id :: Maybe Bool -- ^ True, if authorization through Google ID is allowed
    }
  | AuthorizationStateWaitEmailCode -- ^ TDLib needs the user's authentication code sent to an email address to authorize. Call checkAuthenticationEmailCode to provide the code
    { allow_apple_id            :: Maybe Bool                                                                  -- ^ True, if authorization through Apple ID is allowed
    , allow_google_id           :: Maybe Bool                                                                  -- ^ True, if authorization through Google ID is allowed
    , AuthorizationState -> Maybe EmailAddressAuthenticationCodeInfo
code_info                 :: Maybe EmailAddressAuthenticationCodeInfo.EmailAddressAuthenticationCodeInfo -- ^ Information about the sent authentication code
    , AuthorizationState -> Maybe EmailAddressResetState
email_address_reset_state :: Maybe EmailAddressResetState.EmailAddressResetState                         -- ^ Reset state of the email address; may be null if the email address can't be reset
    }
  | AuthorizationStateWaitCode -- ^ TDLib needs the user's authentication code to authorize. Call checkAuthenticationCode to check the code
    { AuthorizationState -> Maybe AuthenticationCodeInfo
_code_info :: Maybe AuthenticationCodeInfo.AuthenticationCodeInfo -- ^ Information about the authorization code that was sent
    }
  | AuthorizationStateWaitOtherDeviceConfirmation -- ^ The user needs to confirm authorization on another logged in device by scanning a QR code with the provided link
    { AuthorizationState -> Maybe Text
link :: Maybe T.Text -- ^ A tg:// URL for the QR code. The link will be updated frequently
    }
  | AuthorizationStateWaitRegistration -- ^ The user is unregistered and need to accept terms of service and enter their first name and last name to finish registration. Call registerUser to accept the terms of service and provide the data
    { AuthorizationState -> Maybe TermsOfService
terms_of_service :: Maybe TermsOfService.TermsOfService -- ^ Telegram terms of service
    }
  | AuthorizationStateWaitPassword -- ^ The user has been authorized, but needs to enter a 2-step verification password to start using the application. Call checkAuthenticationPassword to provide the password, or requestAuthenticationPasswordRecovery to recover the password, or deleteAccount to delete the account after a week
    { AuthorizationState -> Maybe Text
password_hint                  :: Maybe T.Text -- ^ Hint for the password; may be empty
    , AuthorizationState -> Maybe Bool
has_recovery_email_address     :: Maybe Bool   -- ^ True, if a recovery email address has been set up
    , AuthorizationState -> Maybe Bool
has_passport_data              :: Maybe Bool   -- ^ True, if some Telegram Passport elements were saved
    , AuthorizationState -> Maybe Text
recovery_email_address_pattern :: Maybe T.Text -- ^ Pattern of the email address to which the recovery email was sent; empty until a recovery email has been sent
    }
  | AuthorizationStateReady -- ^ The user has been successfully authorized. TDLib is now ready to answer general requests
  | AuthorizationStateLoggingOut -- ^ The user is currently logging out
  | AuthorizationStateClosing -- ^ TDLib is closing, all subsequent queries will be answered with the error 500. Note that closing TDLib can take a while. All resources will be freed only after authorizationStateClosed has been received
  | AuthorizationStateClosed -- ^ TDLib client is in its final state. All databases are closed and all resources are released. No other updates will be received after this. All queries will be responded to with error code 500. To continue working, one must create a new instance of the TDLib client
  deriving (AuthorizationState -> AuthorizationState -> Bool
(AuthorizationState -> AuthorizationState -> Bool)
-> (AuthorizationState -> AuthorizationState -> Bool)
-> Eq AuthorizationState
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AuthorizationState -> AuthorizationState -> Bool
== :: AuthorizationState -> AuthorizationState -> Bool
$c/= :: AuthorizationState -> AuthorizationState -> Bool
/= :: AuthorizationState -> AuthorizationState -> Bool
Eq, Int -> AuthorizationState -> ShowS
[AuthorizationState] -> ShowS
AuthorizationState -> String
(Int -> AuthorizationState -> ShowS)
-> (AuthorizationState -> String)
-> ([AuthorizationState] -> ShowS)
-> Show AuthorizationState
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AuthorizationState -> ShowS
showsPrec :: Int -> AuthorizationState -> ShowS
$cshow :: AuthorizationState -> String
show :: AuthorizationState -> String
$cshowList :: [AuthorizationState] -> ShowS
showList :: [AuthorizationState] -> ShowS
Show)

instance I.ShortShow AuthorizationState where
  shortShow :: AuthorizationState -> String
shortShow AuthorizationState
AuthorizationStateWaitTdlibParameters
      = String
"AuthorizationStateWaitTdlibParameters"
  shortShow AuthorizationState
AuthorizationStateWaitPhoneNumber
      = String
"AuthorizationStateWaitPhoneNumber"
  shortShow AuthorizationStateWaitEmailAddress
    { allow_apple_id :: AuthorizationState -> Maybe Bool
allow_apple_id  = Maybe Bool
allow_apple_id_
    , allow_google_id :: AuthorizationState -> Maybe Bool
allow_google_id = Maybe Bool
allow_google_id_
    }
      = String
"AuthorizationStateWaitEmailAddress"
        String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
        [ String
"allow_apple_id"  String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
allow_apple_id_
        , String
"allow_google_id" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
allow_google_id_
        ]
  shortShow AuthorizationStateWaitEmailCode
    { allow_apple_id :: AuthorizationState -> Maybe Bool
allow_apple_id            = Maybe Bool
allow_apple_id_
    , allow_google_id :: AuthorizationState -> Maybe Bool
allow_google_id           = Maybe Bool
allow_google_id_
    , code_info :: AuthorizationState -> Maybe EmailAddressAuthenticationCodeInfo
code_info                 = Maybe EmailAddressAuthenticationCodeInfo
code_info_
    , email_address_reset_state :: AuthorizationState -> Maybe EmailAddressResetState
email_address_reset_state = Maybe EmailAddressResetState
email_address_reset_state_
    }
      = String
"AuthorizationStateWaitEmailCode"
        String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
        [ String
"allow_apple_id"            String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
allow_apple_id_
        , String
"allow_google_id"           String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
allow_google_id_
        , String
"code_info"                 String -> Maybe EmailAddressAuthenticationCodeInfo -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe EmailAddressAuthenticationCodeInfo
code_info_
        , String
"email_address_reset_state" String -> Maybe EmailAddressResetState -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe EmailAddressResetState
email_address_reset_state_
        ]
  shortShow AuthorizationStateWaitCode
    { _code_info :: AuthorizationState -> Maybe AuthenticationCodeInfo
_code_info = Maybe AuthenticationCodeInfo
_code_info_
    }
      = String
"AuthorizationStateWaitCode"
        String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
        [ String
"_code_info" String -> Maybe AuthenticationCodeInfo -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe AuthenticationCodeInfo
_code_info_
        ]
  shortShow AuthorizationStateWaitOtherDeviceConfirmation
    { link :: AuthorizationState -> Maybe Text
link = Maybe Text
link_
    }
      = String
"AuthorizationStateWaitOtherDeviceConfirmation"
        String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
        [ String
"link" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
link_
        ]
  shortShow AuthorizationStateWaitRegistration
    { terms_of_service :: AuthorizationState -> Maybe TermsOfService
terms_of_service = Maybe TermsOfService
terms_of_service_
    }
      = String
"AuthorizationStateWaitRegistration"
        String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
        [ String
"terms_of_service" String -> Maybe TermsOfService -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe TermsOfService
terms_of_service_
        ]
  shortShow AuthorizationStateWaitPassword
    { password_hint :: AuthorizationState -> Maybe Text
password_hint                  = Maybe Text
password_hint_
    , has_recovery_email_address :: AuthorizationState -> Maybe Bool
has_recovery_email_address     = Maybe Bool
has_recovery_email_address_
    , has_passport_data :: AuthorizationState -> Maybe Bool
has_passport_data              = Maybe Bool
has_passport_data_
    , recovery_email_address_pattern :: AuthorizationState -> Maybe Text
recovery_email_address_pattern = Maybe Text
recovery_email_address_pattern_
    }
      = String
"AuthorizationStateWaitPassword"
        String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
        [ String
"password_hint"                  String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
password_hint_
        , String
"has_recovery_email_address"     String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
has_recovery_email_address_
        , String
"has_passport_data"              String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
has_passport_data_
        , String
"recovery_email_address_pattern" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
recovery_email_address_pattern_
        ]
  shortShow AuthorizationState
AuthorizationStateReady
      = String
"AuthorizationStateReady"
  shortShow AuthorizationState
AuthorizationStateLoggingOut
      = String
"AuthorizationStateLoggingOut"
  shortShow AuthorizationState
AuthorizationStateClosing
      = String
"AuthorizationStateClosing"
  shortShow AuthorizationState
AuthorizationStateClosed
      = String
"AuthorizationStateClosed"

instance AT.FromJSON AuthorizationState where
  parseJSON :: Value -> Parser AuthorizationState
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
"authorizationStateWaitTdlibParameters"         -> AuthorizationState -> Parser AuthorizationState
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure AuthorizationState
AuthorizationStateWaitTdlibParameters
      String
"authorizationStateWaitPhoneNumber"             -> AuthorizationState -> Parser AuthorizationState
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure AuthorizationState
AuthorizationStateWaitPhoneNumber
      String
"authorizationStateWaitEmailAddress"            -> Value -> Parser AuthorizationState
parseAuthorizationStateWaitEmailAddress Value
v
      String
"authorizationStateWaitEmailCode"               -> Value -> Parser AuthorizationState
parseAuthorizationStateWaitEmailCode Value
v
      String
"authorizationStateWaitCode"                    -> Value -> Parser AuthorizationState
parseAuthorizationStateWaitCode Value
v
      String
"authorizationStateWaitOtherDeviceConfirmation" -> Value -> Parser AuthorizationState
parseAuthorizationStateWaitOtherDeviceConfirmation Value
v
      String
"authorizationStateWaitRegistration"            -> Value -> Parser AuthorizationState
parseAuthorizationStateWaitRegistration Value
v
      String
"authorizationStateWaitPassword"                -> Value -> Parser AuthorizationState
parseAuthorizationStateWaitPassword Value
v
      String
"authorizationStateReady"                       -> AuthorizationState -> Parser AuthorizationState
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure AuthorizationState
AuthorizationStateReady
      String
"authorizationStateLoggingOut"                  -> AuthorizationState -> Parser AuthorizationState
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure AuthorizationState
AuthorizationStateLoggingOut
      String
"authorizationStateClosing"                     -> AuthorizationState -> Parser AuthorizationState
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure AuthorizationState
AuthorizationStateClosing
      String
"authorizationStateClosed"                      -> AuthorizationState -> Parser AuthorizationState
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure AuthorizationState
AuthorizationStateClosed
      String
_                                               -> Parser AuthorizationState
forall a. Monoid a => a
mempty
    
    where
      parseAuthorizationStateWaitEmailAddress :: A.Value -> AT.Parser AuthorizationState
      parseAuthorizationStateWaitEmailAddress :: Value -> Parser AuthorizationState
parseAuthorizationStateWaitEmailAddress = String
-> (Object -> Parser AuthorizationState)
-> Value
-> Parser AuthorizationState
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"AuthorizationStateWaitEmailAddress" ((Object -> Parser AuthorizationState)
 -> Value -> Parser AuthorizationState)
-> (Object -> Parser AuthorizationState)
-> Value
-> Parser AuthorizationState
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
        Maybe Bool
allow_apple_id_  <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"allow_apple_id"
        Maybe Bool
allow_google_id_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"allow_google_id"
        AuthorizationState -> Parser AuthorizationState
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (AuthorizationState -> Parser AuthorizationState)
-> AuthorizationState -> Parser AuthorizationState
forall a b. (a -> b) -> a -> b
$ AuthorizationStateWaitEmailAddress
          { allow_apple_id :: Maybe Bool
allow_apple_id  = Maybe Bool
allow_apple_id_
          , allow_google_id :: Maybe Bool
allow_google_id = Maybe Bool
allow_google_id_
          }
      parseAuthorizationStateWaitEmailCode :: A.Value -> AT.Parser AuthorizationState
      parseAuthorizationStateWaitEmailCode :: Value -> Parser AuthorizationState
parseAuthorizationStateWaitEmailCode = String
-> (Object -> Parser AuthorizationState)
-> Value
-> Parser AuthorizationState
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"AuthorizationStateWaitEmailCode" ((Object -> Parser AuthorizationState)
 -> Value -> Parser AuthorizationState)
-> (Object -> Parser AuthorizationState)
-> Value
-> Parser AuthorizationState
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
        Maybe Bool
allow_apple_id_            <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"allow_apple_id"
        Maybe Bool
allow_google_id_           <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"allow_google_id"
        Maybe EmailAddressAuthenticationCodeInfo
code_info_                 <- Object
o Object -> Key -> Parser (Maybe EmailAddressAuthenticationCodeInfo)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"code_info"
        Maybe EmailAddressResetState
email_address_reset_state_ <- Object
o Object -> Key -> Parser (Maybe EmailAddressResetState)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"email_address_reset_state"
        AuthorizationState -> Parser AuthorizationState
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (AuthorizationState -> Parser AuthorizationState)
-> AuthorizationState -> Parser AuthorizationState
forall a b. (a -> b) -> a -> b
$ AuthorizationStateWaitEmailCode
          { allow_apple_id :: Maybe Bool
allow_apple_id            = Maybe Bool
allow_apple_id_
          , allow_google_id :: Maybe Bool
allow_google_id           = Maybe Bool
allow_google_id_
          , code_info :: Maybe EmailAddressAuthenticationCodeInfo
code_info                 = Maybe EmailAddressAuthenticationCodeInfo
code_info_
          , email_address_reset_state :: Maybe EmailAddressResetState
email_address_reset_state = Maybe EmailAddressResetState
email_address_reset_state_
          }
      parseAuthorizationStateWaitCode :: A.Value -> AT.Parser AuthorizationState
      parseAuthorizationStateWaitCode :: Value -> Parser AuthorizationState
parseAuthorizationStateWaitCode = String
-> (Object -> Parser AuthorizationState)
-> Value
-> Parser AuthorizationState
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"AuthorizationStateWaitCode" ((Object -> Parser AuthorizationState)
 -> Value -> Parser AuthorizationState)
-> (Object -> Parser AuthorizationState)
-> Value
-> Parser AuthorizationState
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
        Maybe AuthenticationCodeInfo
_code_info_ <- Object
o Object -> Key -> Parser (Maybe AuthenticationCodeInfo)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"code_info"
        AuthorizationState -> Parser AuthorizationState
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (AuthorizationState -> Parser AuthorizationState)
-> AuthorizationState -> Parser AuthorizationState
forall a b. (a -> b) -> a -> b
$ AuthorizationStateWaitCode
          { _code_info :: Maybe AuthenticationCodeInfo
_code_info = Maybe AuthenticationCodeInfo
_code_info_
          }
      parseAuthorizationStateWaitOtherDeviceConfirmation :: A.Value -> AT.Parser AuthorizationState
      parseAuthorizationStateWaitOtherDeviceConfirmation :: Value -> Parser AuthorizationState
parseAuthorizationStateWaitOtherDeviceConfirmation = String
-> (Object -> Parser AuthorizationState)
-> Value
-> Parser AuthorizationState
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"AuthorizationStateWaitOtherDeviceConfirmation" ((Object -> Parser AuthorizationState)
 -> Value -> Parser AuthorizationState)
-> (Object -> Parser AuthorizationState)
-> Value
-> Parser AuthorizationState
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
        Maybe Text
link_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"link"
        AuthorizationState -> Parser AuthorizationState
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (AuthorizationState -> Parser AuthorizationState)
-> AuthorizationState -> Parser AuthorizationState
forall a b. (a -> b) -> a -> b
$ AuthorizationStateWaitOtherDeviceConfirmation
          { link :: Maybe Text
link = Maybe Text
link_
          }
      parseAuthorizationStateWaitRegistration :: A.Value -> AT.Parser AuthorizationState
      parseAuthorizationStateWaitRegistration :: Value -> Parser AuthorizationState
parseAuthorizationStateWaitRegistration = String
-> (Object -> Parser AuthorizationState)
-> Value
-> Parser AuthorizationState
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"AuthorizationStateWaitRegistration" ((Object -> Parser AuthorizationState)
 -> Value -> Parser AuthorizationState)
-> (Object -> Parser AuthorizationState)
-> Value
-> Parser AuthorizationState
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
        Maybe TermsOfService
terms_of_service_ <- Object
o Object -> Key -> Parser (Maybe TermsOfService)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"terms_of_service"
        AuthorizationState -> Parser AuthorizationState
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (AuthorizationState -> Parser AuthorizationState)
-> AuthorizationState -> Parser AuthorizationState
forall a b. (a -> b) -> a -> b
$ AuthorizationStateWaitRegistration
          { terms_of_service :: Maybe TermsOfService
terms_of_service = Maybe TermsOfService
terms_of_service_
          }
      parseAuthorizationStateWaitPassword :: A.Value -> AT.Parser AuthorizationState
      parseAuthorizationStateWaitPassword :: Value -> Parser AuthorizationState
parseAuthorizationStateWaitPassword = String
-> (Object -> Parser AuthorizationState)
-> Value
-> Parser AuthorizationState
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"AuthorizationStateWaitPassword" ((Object -> Parser AuthorizationState)
 -> Value -> Parser AuthorizationState)
-> (Object -> Parser AuthorizationState)
-> Value
-> Parser AuthorizationState
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
        Maybe Text
password_hint_                  <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"password_hint"
        Maybe Bool
has_recovery_email_address_     <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"has_recovery_email_address"
        Maybe Bool
has_passport_data_              <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"has_passport_data"
        Maybe Text
recovery_email_address_pattern_ <- Object
o Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:?  Key
"recovery_email_address_pattern"
        AuthorizationState -> Parser AuthorizationState
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (AuthorizationState -> Parser AuthorizationState)
-> AuthorizationState -> Parser AuthorizationState
forall a b. (a -> b) -> a -> b
$ AuthorizationStateWaitPassword
          { password_hint :: Maybe Text
password_hint                  = Maybe Text
password_hint_
          , has_recovery_email_address :: Maybe Bool
has_recovery_email_address     = Maybe Bool
has_recovery_email_address_
          , has_passport_data :: Maybe Bool
has_passport_data              = Maybe Bool
has_passport_data_
          , recovery_email_address_pattern :: Maybe Text
recovery_email_address_pattern = Maybe Text
recovery_email_address_pattern_
          }
  parseJSON Value
_ = Parser AuthorizationState
forall a. Monoid a => a
mempty