module TD.Query.AddBotSecondaryUsername
  (AddBotSecondaryUsername(..)
  , defaultAddBotSecondaryUsername
  ) 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

-- | Adds a secondary username to a bot. Can be called only if userTypeBot.can_be_edited, the bot has no secondary username and the current user has Telegram Premium subscription. May return an error with a message "OWNER_USERNAMES_LIMIT_EXCEEDED" if the current user already owns at least getOption("secondary_bot_username_count_max") bots with a secondary username. Returns 'TD.Data.Ok.Ok'
data AddBotSecondaryUsername
  = AddBotSecondaryUsername
    { AddBotSecondaryUsername -> Maybe Int
bot_user_id :: Maybe Int    -- ^ Identifier of the target bot
    , AddBotSecondaryUsername -> Maybe Text
username    :: Maybe T.Text -- ^ The new secondary username; must be non-empty. Use checkBotUsername to check username validness
    }
  deriving (AddBotSecondaryUsername -> AddBotSecondaryUsername -> Bool
(AddBotSecondaryUsername -> AddBotSecondaryUsername -> Bool)
-> (AddBotSecondaryUsername -> AddBotSecondaryUsername -> Bool)
-> Eq AddBotSecondaryUsername
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AddBotSecondaryUsername -> AddBotSecondaryUsername -> Bool
== :: AddBotSecondaryUsername -> AddBotSecondaryUsername -> Bool
$c/= :: AddBotSecondaryUsername -> AddBotSecondaryUsername -> Bool
/= :: AddBotSecondaryUsername -> AddBotSecondaryUsername -> Bool
Eq, Int -> AddBotSecondaryUsername -> ShowS
[AddBotSecondaryUsername] -> ShowS
AddBotSecondaryUsername -> String
(Int -> AddBotSecondaryUsername -> ShowS)
-> (AddBotSecondaryUsername -> String)
-> ([AddBotSecondaryUsername] -> ShowS)
-> Show AddBotSecondaryUsername
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AddBotSecondaryUsername -> ShowS
showsPrec :: Int -> AddBotSecondaryUsername -> ShowS
$cshow :: AddBotSecondaryUsername -> String
show :: AddBotSecondaryUsername -> String
$cshowList :: [AddBotSecondaryUsername] -> ShowS
showList :: [AddBotSecondaryUsername] -> ShowS
Show)

instance I.ShortShow AddBotSecondaryUsername where
  shortShow :: AddBotSecondaryUsername -> String
shortShow
    AddBotSecondaryUsername
      { bot_user_id :: AddBotSecondaryUsername -> Maybe Int
bot_user_id = Maybe Int
bot_user_id_
      , username :: AddBotSecondaryUsername -> Maybe Text
username    = Maybe Text
username_
      }
        = String
"AddBotSecondaryUsername"
          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
"username"    String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
username_
          ]

instance AT.ToJSON AddBotSecondaryUsername where
  toJSON :: AddBotSecondaryUsername -> Value
toJSON
    AddBotSecondaryUsername
      { bot_user_id :: AddBotSecondaryUsername -> Maybe Int
bot_user_id = Maybe Int
bot_user_id_
      , username :: AddBotSecondaryUsername -> Maybe Text
username    = Maybe Text
username_
      }
        = [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
"addBotSecondaryUsername"
          , 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
"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_
          ]

defaultAddBotSecondaryUsername :: AddBotSecondaryUsername
defaultAddBotSecondaryUsername :: AddBotSecondaryUsername
defaultAddBotSecondaryUsername =
  AddBotSecondaryUsername
    { bot_user_id :: Maybe Int
bot_user_id = Maybe Int
forall a. Maybe a
Nothing
    , username :: Maybe Text
username    = Maybe Text
forall a. Maybe a
Nothing
    }