Add editBotCommands for PATCH /me/commands, deprecate editBotInfo

The API no longer accepts PATCH /me: it answers "Path /me is not
recognized", so editBotInfo() fails, including for commands. Commands
now have their own endpoint, PATCH /me/commands (editMyCommands in the
official schema); bot name, description and photo are edited on the
MAX partner platform.

- Api::editBotCommands(BotCommand[]): BotCommandsInfo
- BotCommandsInfo model and ModelFactory::createBotCommandsInfo()
- editBotInfo() and BotPatch marked @deprecated
- README coverage map and docs updated
This commit is contained in:
Timofey
2026-09-28 00:08:35 +05:00
parent bf5219af7a
commit ca5ed4c100
9 changed files with 213 additions and 3 deletions
+19
View File
@@ -27,6 +27,7 @@ use BushlanovDev\MaxMessengerBot\Models\Attachments\Payloads\ShareAttachmentRequ
use BushlanovDev\MaxMessengerBot\Models\Attachments\PhotoAttachment;
use BushlanovDev\MaxMessengerBot\Models\Attachments\ShareAttachment;
use BushlanovDev\MaxMessengerBot\Models\BotCommand;
use BushlanovDev\MaxMessengerBot\Models\BotCommandsInfo;
use BushlanovDev\MaxMessengerBot\Models\BotInfo;
use BushlanovDev\MaxMessengerBot\Models\Chat;
use BushlanovDev\MaxMessengerBot\Models\ChatList;
@@ -61,6 +62,7 @@ use Psr\Log\LoggerInterface;
#[CoversClass(ModelFactory::class)]
#[UsesClass(BotInfo::class)]
#[UsesClass(BotCommand::class)]
#[UsesClass(BotCommandsInfo::class)]
#[UsesClass(Result::class)]
#[UsesClass(Subscription::class)]
#[UsesClass(ArrayOf::class)]
@@ -171,6 +173,23 @@ final class ModelFactoryTest extends TestCase
$this->assertSame('help', $botInfo->commands[1]->name);
}
#[Test]
public function createBotCommandsInfoHydratesCommands(): void
{
$botCommands = $this->factory->createBotCommandsInfo([
'commands' => [
['name' => 'start', 'description' => 'Start the bot'],
['name' => 'help', 'description' => null],
],
]);
$this->assertInstanceOf(BotCommandsInfo::class, $botCommands);
$this->assertCount(2, $botCommands->commands);
$this->assertInstanceOf(BotCommand::class, $botCommands->commands[0]);
$this->assertSame('start', $botCommands->commands[0]->name);
$this->assertNull($botCommands->commands[1]->description);
}
#[Test]
public function createBotInfoHandlesNullCommands(): void
{