module TD.Query.CheckAuthenticationBotToken
  (CheckAuthenticationBotToken(..)
  ) 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 token of a bot; to log in as a bot. Works only when the current authorization state is authorizationStateWaitPhoneNumber. Can be used instead of setAuthenticationPhoneNumber and checkAuthenticationCode to log in. Returns 'TD.Data.Ok.Ok'
data CheckAuthenticationBotToken
  = CheckAuthenticationBotToken
    { CheckAuthenticationBotToken -> Maybe Text
token :: Maybe T.Text -- ^ The bot token
    }
  deriving (CheckAuthenticationBotToken -> CheckAuthenticationBotToken -> Bool
(CheckAuthenticationBotToken
 -> CheckAuthenticationBotToken -> Bool)
-> (CheckAuthenticationBotToken
    -> CheckAuthenticationBotToken -> Bool)
-> Eq CheckAuthenticationBotToken
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CheckAuthenticationBotToken -> CheckAuthenticationBotToken -> Bool
== :: CheckAuthenticationBotToken -> CheckAuthenticationBotToken -> Bool
$c/= :: CheckAuthenticationBotToken -> CheckAuthenticationBotToken -> Bool
/= :: CheckAuthenticationBotToken -> CheckAuthenticationBotToken -> Bool
Eq, Int -> CheckAuthenticationBotToken -> ShowS
[CheckAuthenticationBotToken] -> ShowS
CheckAuthenticationBotToken -> String
(Int -> CheckAuthenticationBotToken -> ShowS)
-> (CheckAuthenticationBotToken -> String)
-> ([CheckAuthenticationBotToken] -> ShowS)
-> Show CheckAuthenticationBotToken
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CheckAuthenticationBotToken -> ShowS
showsPrec :: Int -> CheckAuthenticationBotToken -> ShowS
$cshow :: CheckAuthenticationBotToken -> String
show :: CheckAuthenticationBotToken -> String
$cshowList :: [CheckAuthenticationBotToken] -> ShowS
showList :: [CheckAuthenticationBotToken] -> ShowS
Show)

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

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