module TD.Query.CheckAuthenticationPassword
  (CheckAuthenticationPassword(..)
  ) 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 the 2-step verification password for correctness. Works only when the current authorization state is authorizationStateWaitPassword. Returns 'TD.Data.Ok.Ok'
data CheckAuthenticationPassword
  = CheckAuthenticationPassword
    { CheckAuthenticationPassword -> Maybe Text
password :: Maybe T.Text -- ^ The 2-step verification password to check
    }
  deriving (CheckAuthenticationPassword -> CheckAuthenticationPassword -> Bool
(CheckAuthenticationPassword
 -> CheckAuthenticationPassword -> Bool)
-> (CheckAuthenticationPassword
    -> CheckAuthenticationPassword -> Bool)
-> Eq CheckAuthenticationPassword
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CheckAuthenticationPassword -> CheckAuthenticationPassword -> Bool
== :: CheckAuthenticationPassword -> CheckAuthenticationPassword -> Bool
$c/= :: CheckAuthenticationPassword -> CheckAuthenticationPassword -> Bool
/= :: CheckAuthenticationPassword -> CheckAuthenticationPassword -> Bool
Eq, Int -> CheckAuthenticationPassword -> ShowS
[CheckAuthenticationPassword] -> ShowS
CheckAuthenticationPassword -> String
(Int -> CheckAuthenticationPassword -> ShowS)
-> (CheckAuthenticationPassword -> String)
-> ([CheckAuthenticationPassword] -> ShowS)
-> Show CheckAuthenticationPassword
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CheckAuthenticationPassword -> ShowS
showsPrec :: Int -> CheckAuthenticationPassword -> ShowS
$cshow :: CheckAuthenticationPassword -> String
show :: CheckAuthenticationPassword -> String
$cshowList :: [CheckAuthenticationPassword] -> ShowS
showList :: [CheckAuthenticationPassword] -> ShowS
Show)

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

instance AT.ToJSON CheckAuthenticationPassword where
  toJSON :: CheckAuthenticationPassword -> Value
toJSON
    CheckAuthenticationPassword
      { password :: CheckAuthenticationPassword -> Maybe Text
password = Maybe Text
password_
      }
        = [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
"checkAuthenticationPassword"
          , Key
"password" Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
password_
          ]