module TD.Query.CheckBotUsername
  (CheckBotUsername(..)
  , defaultCheckBotUsername
  ) 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 username can be set for a new bot or assigned as a secondary username to an existing bot. Use checkChatUsername to check username for other chat types. Returns 'TD.Data.CheckChatUsernameResult.CheckChatUsernameResult'
data CheckBotUsername
  = CheckBotUsername
    { CheckBotUsername -> Maybe Text
username     :: Maybe T.Text -- ^ Username to be checked
    , CheckBotUsername -> Maybe Bool
is_secondary :: Maybe Bool   -- ^ Pass true to check whether the username is suitable as a secondary username for an existing bot; pass false to check whether the username is suitable for createBot
    }
  deriving (CheckBotUsername -> CheckBotUsername -> Bool
(CheckBotUsername -> CheckBotUsername -> Bool)
-> (CheckBotUsername -> CheckBotUsername -> Bool)
-> Eq CheckBotUsername
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: CheckBotUsername -> CheckBotUsername -> Bool
== :: CheckBotUsername -> CheckBotUsername -> Bool
$c/= :: CheckBotUsername -> CheckBotUsername -> Bool
/= :: CheckBotUsername -> CheckBotUsername -> Bool
Eq, Int -> CheckBotUsername -> ShowS
[CheckBotUsername] -> ShowS
CheckBotUsername -> String
(Int -> CheckBotUsername -> ShowS)
-> (CheckBotUsername -> String)
-> ([CheckBotUsername] -> ShowS)
-> Show CheckBotUsername
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CheckBotUsername -> ShowS
showsPrec :: Int -> CheckBotUsername -> ShowS
$cshow :: CheckBotUsername -> String
show :: CheckBotUsername -> String
$cshowList :: [CheckBotUsername] -> ShowS
showList :: [CheckBotUsername] -> ShowS
Show)

instance I.ShortShow CheckBotUsername where
  shortShow :: CheckBotUsername -> String
shortShow
    CheckBotUsername
      { username :: CheckBotUsername -> Maybe Text
username     = Maybe Text
username_
      , is_secondary :: CheckBotUsername -> Maybe Bool
is_secondary = Maybe Bool
is_secondary_
      }
        = String
"CheckBotUsername"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"username"     String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
username_
          , String
"is_secondary" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_secondary_
          ]

instance AT.ToJSON CheckBotUsername where
  toJSON :: CheckBotUsername -> Value
toJSON
    CheckBotUsername
      { username :: CheckBotUsername -> Maybe Text
username     = Maybe Text
username_
      , is_secondary :: CheckBotUsername -> Maybe Bool
is_secondary = Maybe Bool
is_secondary_
      }
        = [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
"checkBotUsername"
          , Key
"username"     Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
username_
          , Key
"is_secondary" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
is_secondary_
          ]

defaultCheckBotUsername :: CheckBotUsername
defaultCheckBotUsername :: CheckBotUsername
defaultCheckBotUsername =
  CheckBotUsername
    { username :: Maybe Text
username     = Maybe Text
forall a. Maybe a
Nothing
    , is_secondary :: Maybe Bool
is_secondary = Maybe Bool
forall a. Maybe a
Nothing
    }