module TD.Query.SetBotName
  (SetBotName(..)
  , defaultSetBotName
  ) 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

-- | Sets the name of a bot. Can be called only if userTypeBot.can_be_edited == true. Returns 'TD.Data.Ok.Ok'
data SetBotName
  = SetBotName
    { SetBotName -> Maybe Int
bot_user_id   :: Maybe Int    -- ^ Identifier of the target bot
    , SetBotName -> Maybe Text
language_code :: Maybe T.Text -- ^ A two-letter ISO 639-1 language code. If empty, the name will be shown to all users for whose languages there is no dedicated name
    , SetBotName -> Maybe Text
name          :: Maybe T.Text -- ^ New bot's name on the specified language; 0-64 characters; must be non-empty if language code is empty
    }
  deriving (SetBotName -> SetBotName -> Bool
(SetBotName -> SetBotName -> Bool)
-> (SetBotName -> SetBotName -> Bool) -> Eq SetBotName
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetBotName -> SetBotName -> Bool
== :: SetBotName -> SetBotName -> Bool
$c/= :: SetBotName -> SetBotName -> Bool
/= :: SetBotName -> SetBotName -> Bool
Eq, Int -> SetBotName -> ShowS
[SetBotName] -> ShowS
SetBotName -> String
(Int -> SetBotName -> ShowS)
-> (SetBotName -> String)
-> ([SetBotName] -> ShowS)
-> Show SetBotName
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetBotName -> ShowS
showsPrec :: Int -> SetBotName -> ShowS
$cshow :: SetBotName -> String
show :: SetBotName -> String
$cshowList :: [SetBotName] -> ShowS
showList :: [SetBotName] -> ShowS
Show)

instance I.ShortShow SetBotName where
  shortShow :: SetBotName -> String
shortShow
    SetBotName
      { bot_user_id :: SetBotName -> Maybe Int
bot_user_id   = Maybe Int
bot_user_id_
      , language_code :: SetBotName -> Maybe Text
language_code = Maybe Text
language_code_
      , name :: SetBotName -> Maybe Text
name          = Maybe Text
name_
      }
        = String
"SetBotName"
          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_
          , String
"name"          String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
name_
          ]

instance AT.ToJSON SetBotName where
  toJSON :: SetBotName -> Value
toJSON
    SetBotName
      { bot_user_id :: SetBotName -> Maybe Int
bot_user_id   = Maybe Int
bot_user_id_
      , language_code :: SetBotName -> Maybe Text
language_code = Maybe Text
language_code_
      , name :: SetBotName -> Maybe Text
name          = Maybe Text
name_
      }
        = [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
"setBotName"
          , 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_
          , Key
"name"          Key -> Maybe Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Text
name_
          ]

defaultSetBotName :: SetBotName
defaultSetBotName :: SetBotName
defaultSetBotName =
  SetBotName
    { 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
    , name :: Maybe Text
name          = Maybe Text
forall a. Maybe a
Nothing
    }