module TD.Query.GetBotName
  (GetBotName(..)
  , defaultGetBotName
  ) 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

-- | Returns the name of a bot in the given language. Can be called only if userTypeBot.can_be_edited == true. Returns 'TD.Data.Text.Text'
data GetBotName
  = GetBotName
    { GetBotName -> Maybe Int
bot_user_id   :: Maybe Int    -- ^ Identifier of the target bot
    , GetBotName -> Maybe Text
language_code :: Maybe T.Text -- ^ A two-letter ISO 639-1 language code or an empty string
    }
  deriving (GetBotName -> GetBotName -> Bool
(GetBotName -> GetBotName -> Bool)
-> (GetBotName -> GetBotName -> Bool) -> Eq GetBotName
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: GetBotName -> GetBotName -> Bool
== :: GetBotName -> GetBotName -> Bool
$c/= :: GetBotName -> GetBotName -> Bool
/= :: GetBotName -> GetBotName -> Bool
Eq, Int -> GetBotName -> ShowS
[GetBotName] -> ShowS
GetBotName -> String
(Int -> GetBotName -> ShowS)
-> (GetBotName -> String)
-> ([GetBotName] -> ShowS)
-> Show GetBotName
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> GetBotName -> ShowS
showsPrec :: Int -> GetBotName -> ShowS
$cshow :: GetBotName -> String
show :: GetBotName -> String
$cshowList :: [GetBotName] -> ShowS
showList :: [GetBotName] -> ShowS
Show)

instance I.ShortShow GetBotName where
  shortShow :: GetBotName -> String
shortShow
    GetBotName
      { bot_user_id :: GetBotName -> Maybe Int
bot_user_id   = Maybe Int
bot_user_id_
      , language_code :: GetBotName -> Maybe Text
language_code = Maybe Text
language_code_
      }
        = String
"GetBotName"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"bot_user_id"   String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
bot_user_id_
          , String
"language_code" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
language_code_
          ]

instance AT.ToJSON GetBotName where
  toJSON :: GetBotName -> Value
toJSON
    GetBotName
      { bot_user_id :: GetBotName -> Maybe Int
bot_user_id   = Maybe Int
bot_user_id_
      , language_code :: GetBotName -> Maybe Text
language_code = Maybe Text
language_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
"getBotName"
          , Key
"bot_user_id"   Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
bot_user_id_
          , Key
"language_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
language_code_
          ]

defaultGetBotName :: GetBotName
defaultGetBotName :: GetBotName
defaultGetBotName =
  GetBotName
    { bot_user_id :: Maybe Int
bot_user_id   = Maybe Int
forall a. Maybe a
Nothing
    , language_code :: Maybe Text
language_code = Maybe Text
forall a. Maybe a
Nothing
    }