module TD.Query.CheckAuthenticationPasswordRecoveryCode
  (CheckAuthenticationPasswordRecoveryCode(..)
  ) 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

-- | Checks whether a 2-step verification password recovery code sent to an email address is valid. Works only when the current authorization state is authorizationStateWaitPassword. Returns 'TD.Data.Ok.Ok'
data CheckAuthenticationPasswordRecoveryCode
  = CheckAuthenticationPasswordRecoveryCode
    { CheckAuthenticationPasswordRecoveryCode -> Maybe Text
recovery_code :: Maybe T.Text -- ^ Recovery code to check
    }
  deriving (CheckAuthenticationPasswordRecoveryCode
-> CheckAuthenticationPasswordRecoveryCode -> Bool
(CheckAuthenticationPasswordRecoveryCode
 -> CheckAuthenticationPasswordRecoveryCode -> Bool)
-> (CheckAuthenticationPasswordRecoveryCode
    -> CheckAuthenticationPasswordRecoveryCode -> Bool)
-> Eq CheckAuthenticationPasswordRecoveryCode
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CheckAuthenticationPasswordRecoveryCode
-> CheckAuthenticationPasswordRecoveryCode -> Bool
== :: CheckAuthenticationPasswordRecoveryCode
-> CheckAuthenticationPasswordRecoveryCode -> Bool
$c/= :: CheckAuthenticationPasswordRecoveryCode
-> CheckAuthenticationPasswordRecoveryCode -> Bool
/= :: CheckAuthenticationPasswordRecoveryCode
-> CheckAuthenticationPasswordRecoveryCode -> Bool
Eq, Int -> CheckAuthenticationPasswordRecoveryCode -> ShowS
[CheckAuthenticationPasswordRecoveryCode] -> ShowS
CheckAuthenticationPasswordRecoveryCode -> String
(Int -> CheckAuthenticationPasswordRecoveryCode -> ShowS)
-> (CheckAuthenticationPasswordRecoveryCode -> String)
-> ([CheckAuthenticationPasswordRecoveryCode] -> ShowS)
-> Show CheckAuthenticationPasswordRecoveryCode
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CheckAuthenticationPasswordRecoveryCode -> ShowS
showsPrec :: Int -> CheckAuthenticationPasswordRecoveryCode -> ShowS
$cshow :: CheckAuthenticationPasswordRecoveryCode -> String
show :: CheckAuthenticationPasswordRecoveryCode -> String
$cshowList :: [CheckAuthenticationPasswordRecoveryCode] -> ShowS
showList :: [CheckAuthenticationPasswordRecoveryCode] -> ShowS
Show)

instance I.ShortShow CheckAuthenticationPasswordRecoveryCode where
  shortShow :: CheckAuthenticationPasswordRecoveryCode -> String
shortShow
    CheckAuthenticationPasswordRecoveryCode
      { recovery_code :: CheckAuthenticationPasswordRecoveryCode -> Maybe Text
recovery_code = Maybe Text
recovery_code_
      }
        = String
"CheckAuthenticationPasswordRecoveryCode"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"recovery_code" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
recovery_code_
          ]

instance AT.ToJSON CheckAuthenticationPasswordRecoveryCode where
  toJSON :: CheckAuthenticationPasswordRecoveryCode -> Value
toJSON
    CheckAuthenticationPasswordRecoveryCode
      { recovery_code :: CheckAuthenticationPasswordRecoveryCode -> Maybe Text
recovery_code = Maybe Text
recovery_code_
      }
        = [Pair] -> Value
A.object
          [ Key
"@type"         Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
AT.String Text
"checkAuthenticationPasswordRecoveryCode"
          , Key
"recovery_code" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
recovery_code_
          ]