module TD.Query.CheckPasswordRecoveryCode
  (CheckPasswordRecoveryCode(..)
  ) 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. Returns 'TD.Data.Ok.Ok'
data CheckPasswordRecoveryCode
  = CheckPasswordRecoveryCode
    { CheckPasswordRecoveryCode -> Maybe Text
recovery_code :: Maybe T.Text -- ^ Recovery code to check
    }
  deriving (CheckPasswordRecoveryCode -> CheckPasswordRecoveryCode -> Bool
(CheckPasswordRecoveryCode -> CheckPasswordRecoveryCode -> Bool)
-> (CheckPasswordRecoveryCode -> CheckPasswordRecoveryCode -> Bool)
-> Eq CheckPasswordRecoveryCode
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CheckPasswordRecoveryCode -> CheckPasswordRecoveryCode -> Bool
== :: CheckPasswordRecoveryCode -> CheckPasswordRecoveryCode -> Bool
$c/= :: CheckPasswordRecoveryCode -> CheckPasswordRecoveryCode -> Bool
/= :: CheckPasswordRecoveryCode -> CheckPasswordRecoveryCode -> Bool
Eq, Int -> CheckPasswordRecoveryCode -> ShowS
[CheckPasswordRecoveryCode] -> ShowS
CheckPasswordRecoveryCode -> String
(Int -> CheckPasswordRecoveryCode -> ShowS)
-> (CheckPasswordRecoveryCode -> String)
-> ([CheckPasswordRecoveryCode] -> ShowS)
-> Show CheckPasswordRecoveryCode
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CheckPasswordRecoveryCode -> ShowS
showsPrec :: Int -> CheckPasswordRecoveryCode -> ShowS
$cshow :: CheckPasswordRecoveryCode -> String
show :: CheckPasswordRecoveryCode -> String
$cshowList :: [CheckPasswordRecoveryCode] -> ShowS
showList :: [CheckPasswordRecoveryCode] -> ShowS
Show)

instance I.ShortShow CheckPasswordRecoveryCode where
  shortShow :: CheckPasswordRecoveryCode -> String
shortShow
    CheckPasswordRecoveryCode
      { recovery_code :: CheckPasswordRecoveryCode -> Maybe Text
recovery_code = Maybe Text
recovery_code_
      }
        = String
"CheckPasswordRecoveryCode"
          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 CheckPasswordRecoveryCode where
  toJSON :: CheckPasswordRecoveryCode -> Value
toJSON
    CheckPasswordRecoveryCode
      { recovery_code :: CheckPasswordRecoveryCode -> 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
"checkPasswordRecoveryCode"
          , 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_
          ]