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

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

instance AT.ToJSON CheckAuthenticationCode where
  toJSON :: CheckAuthenticationCode -> Value
toJSON
    CheckAuthenticationCode
      { code :: CheckAuthenticationCode -> Maybe Text
code = Maybe Text
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
"checkAuthenticationCode"
          , Key
"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
code_
          ]