module TD.Query.CheckAuthenticationEmailCode
  (CheckAuthenticationEmailCode(..)
  ) 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.EmailAddressAuthentication as EmailAddressAuthentication

-- | Checks the authentication of an email address. Works only when the current authorization state is authorizationStateWaitEmailCode. Returns 'TD.Data.Ok.Ok'
data CheckAuthenticationEmailCode
  = CheckAuthenticationEmailCode
    { CheckAuthenticationEmailCode -> Maybe EmailAddressAuthentication
code :: Maybe EmailAddressAuthentication.EmailAddressAuthentication -- ^ Email address authentication to check
    }
  deriving (CheckAuthenticationEmailCode
-> CheckAuthenticationEmailCode -> Bool
(CheckAuthenticationEmailCode
 -> CheckAuthenticationEmailCode -> Bool)
-> (CheckAuthenticationEmailCode
    -> CheckAuthenticationEmailCode -> Bool)
-> Eq CheckAuthenticationEmailCode
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CheckAuthenticationEmailCode
-> CheckAuthenticationEmailCode -> Bool
== :: CheckAuthenticationEmailCode
-> CheckAuthenticationEmailCode -> Bool
$c/= :: CheckAuthenticationEmailCode
-> CheckAuthenticationEmailCode -> Bool
/= :: CheckAuthenticationEmailCode
-> CheckAuthenticationEmailCode -> Bool
Eq, Int -> CheckAuthenticationEmailCode -> ShowS
[CheckAuthenticationEmailCode] -> ShowS
CheckAuthenticationEmailCode -> String
(Int -> CheckAuthenticationEmailCode -> ShowS)
-> (CheckAuthenticationEmailCode -> String)
-> ([CheckAuthenticationEmailCode] -> ShowS)
-> Show CheckAuthenticationEmailCode
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CheckAuthenticationEmailCode -> ShowS
showsPrec :: Int -> CheckAuthenticationEmailCode -> ShowS
$cshow :: CheckAuthenticationEmailCode -> String
show :: CheckAuthenticationEmailCode -> String
$cshowList :: [CheckAuthenticationEmailCode] -> ShowS
showList :: [CheckAuthenticationEmailCode] -> ShowS
Show)

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

instance AT.ToJSON CheckAuthenticationEmailCode where
  toJSON :: CheckAuthenticationEmailCode -> Value
toJSON
    CheckAuthenticationEmailCode
      { code :: CheckAuthenticationEmailCode -> Maybe EmailAddressAuthentication
code = Maybe EmailAddressAuthentication
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
"checkAuthenticationEmailCode"
          , Key
"code"  Key -> Maybe EmailAddressAuthentication -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe EmailAddressAuthentication
code_
          ]