From 96797a17bc41e9df1fb881411d202108fa53c5fa Mon Sep 17 00:00:00 2001 From: netkas Date: Mon, 7 Oct 2024 11:53:39 -0400 Subject: [PATCH] Add parameter retrieval methods to bot library --- src/TgBotLib/Abstracts/Method.php | 14 ++++++++++++++ src/TgBotLib/Methods/Close.php | 16 ++++++++++++++++ src/TgBotLib/Methods/GetMe.php | 16 ++++++++++++++++ src/TgBotLib/Methods/Logout.php | 16 ++++++++++++++++ src/TgBotLib/Methods/SendMessage.php | 16 ++++++++++++++++ 5 files changed, 78 insertions(+) diff --git a/src/TgBotLib/Abstracts/Method.php b/src/TgBotLib/Abstracts/Method.php index 58054e8..790f587 100644 --- a/src/TgBotLib/Abstracts/Method.php +++ b/src/TgBotLib/Abstracts/Method.php @@ -22,6 +22,20 @@ */ public abstract static function execute(Bot $bot, array $parameters=[]): mixed; + /** + * Retrieves a list of required parameters for a specific operation. + * + * @return array|null An array of required parameters. + */ + public abstract static function getRequiredParameters(): ?array; + + /** + * Retrieves the optional parameters for a request. + * + * @return array|null An array of optional parameters. + */ + public abstract static function getOptionalParameters(): ?array; + /** * Builds a cURL handle for making a POST request to a bot's endpoint. * diff --git a/src/TgBotLib/Methods/Close.php b/src/TgBotLib/Methods/Close.php index 085da19..e349116 100644 --- a/src/TgBotLib/Methods/Close.php +++ b/src/TgBotLib/Methods/Close.php @@ -15,4 +15,20 @@ { return (bool) self::executeCurl(self::buildPost($bot, Methods::CLOSE->value)); } + + /** + * @inheritDoc + */ + public static function getRequiredParameters(): ?array + { + return null; + } + + /** + * @inheritDoc + */ + public static function getOptionalParameters(): ?array + { + return null; + } } \ No newline at end of file diff --git a/src/TgBotLib/Methods/GetMe.php b/src/TgBotLib/Methods/GetMe.php index a499c32..eaca635 100644 --- a/src/TgBotLib/Methods/GetMe.php +++ b/src/TgBotLib/Methods/GetMe.php @@ -16,4 +16,20 @@ { return User::fromArray(self::executeCurl(self::buildPost($bot, Methods::GET_ME->value))); } + + /** + * @inheritDoc + */ + public static function getRequiredParameters(): ?array + { + return null; + } + + /** + * @inheritDoc + */ + public static function getOptionalParameters(): ?array + { + return null; + } } \ No newline at end of file diff --git a/src/TgBotLib/Methods/Logout.php b/src/TgBotLib/Methods/Logout.php index 9ca24ea..6f1f50b 100644 --- a/src/TgBotLib/Methods/Logout.php +++ b/src/TgBotLib/Methods/Logout.php @@ -15,4 +15,20 @@ { return (bool) self::executeCurl(self::buildPost($bot, Methods::LOGOUT->value)); } + + /** + * @inheritDoc + */ + public static function getRequiredParameters(): ?array + { + return null; + } + + /** + * @inheritDoc + */ + public static function getOptionalParameters(): ?array + { + return null; + } } \ No newline at end of file diff --git a/src/TgBotLib/Methods/SendMessage.php b/src/TgBotLib/Methods/SendMessage.php index 4e79a18..cf0c576 100644 --- a/src/TgBotLib/Methods/SendMessage.php +++ b/src/TgBotLib/Methods/SendMessage.php @@ -27,4 +27,20 @@ return Message::fromArray(self::executeCurl(self::buildPost($bot, Methods::SEND_MESSAGE->value, $parameters))); } + + public static function getRequiredParameters(): ?array + { + return [ + 'chat_id', + 'text' + ]; + } + + public static function getOptionalParameters(): ?array + { + return [ + 'business_connection_id', + 'parse_mode', + ]; + } } \ No newline at end of file