module TD.Query.SetCommands
  (SetCommands(..)
  , defaultSetCommands
  ) where

import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
import qualified TD.Data.BotCommandScope as BotCommandScope
import qualified Data.Text as T
import qualified TD.Data.BotCommand as BotCommand

-- | Sets the list of commands supported by the bot for the given user scope and language; for bots only. Returns 'TD.Data.Ok.Ok'
data SetCommands
  = SetCommands
    { SetCommands -> Maybe BotCommandScope
scope         :: Maybe BotCommandScope.BotCommandScope -- ^ The scope to which the commands are relevant; pass null to change commands in the default bot command scope
    , SetCommands -> Maybe Text
language_code :: Maybe T.Text                          -- ^ A two-letter ISO 639-1 language code. If empty, the commands will be applied to all users from the given scope, for which language there are no dedicated commands
    , SetCommands -> Maybe [BotCommand]
commands      :: Maybe [BotCommand.BotCommand]         -- ^ List of the bot's commands
    }
  deriving (SetCommands -> SetCommands -> Bool
(SetCommands -> SetCommands -> Bool)
-> (SetCommands -> SetCommands -> Bool) -> Eq SetCommands
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SetCommands -> SetCommands -> Bool
== :: SetCommands -> SetCommands -> Bool
$c/= :: SetCommands -> SetCommands -> Bool
/= :: SetCommands -> SetCommands -> Bool
Eq, Int -> SetCommands -> ShowS
[SetCommands] -> ShowS
SetCommands -> String
(Int -> SetCommands -> ShowS)
-> (SetCommands -> String)
-> ([SetCommands] -> ShowS)
-> Show SetCommands
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SetCommands -> ShowS
showsPrec :: Int -> SetCommands -> ShowS
$cshow :: SetCommands -> String
show :: SetCommands -> String
$cshowList :: [SetCommands] -> ShowS
showList :: [SetCommands] -> ShowS
Show)

instance I.ShortShow SetCommands where
  shortShow :: SetCommands -> String
shortShow
    SetCommands
      { scope :: SetCommands -> Maybe BotCommandScope
scope         = Maybe BotCommandScope
scope_
      , language_code :: SetCommands -> Maybe Text
language_code = Maybe Text
language_code_
      , commands :: SetCommands -> Maybe [BotCommand]
commands      = Maybe [BotCommand]
commands_
      }
        = String
"SetCommands"
          String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
          [ String
"scope"         String -> Maybe BotCommandScope -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe BotCommandScope
scope_
          , String
"language_code" String -> Maybe Text -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Text
language_code_
          , String
"commands"      String -> Maybe [BotCommand] -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe [BotCommand]
commands_
          ]

instance AT.ToJSON SetCommands where
  toJSON :: SetCommands -> Value
toJSON
    SetCommands
      { scope :: SetCommands -> Maybe BotCommandScope
scope         = Maybe BotCommandScope
scope_
      , language_code :: SetCommands -> Maybe Text
language_code = Maybe Text
language_code_
      , commands :: SetCommands -> Maybe [BotCommand]
commands      = Maybe [BotCommand]
commands_
      }
        = [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
"setCommands"
          , Key
"scope"         Key -> Maybe BotCommandScope -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe BotCommandScope
scope_
          , 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
"commands"      Key -> Maybe [BotCommand] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe [BotCommand]
commands_
          ]

defaultSetCommands :: SetCommands
defaultSetCommands :: SetCommands
defaultSetCommands =
  SetCommands
    { scope :: Maybe BotCommandScope
scope         = Maybe BotCommandScope
forall a. Maybe a
Nothing
    , language_code :: Maybe Text
language_code = Maybe Text
forall a. Maybe a
Nothing
    , commands :: Maybe [BotCommand]
commands      = Maybe [BotCommand]
forall a. Maybe a
Nothing
    }