diff --git a/docs/swagger.json b/docs/swagger.json index 1957f60..a33ea0a 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -4656,4 +4656,4 @@ } } } -} \ No newline at end of file +} diff --git a/src/Enums/ChatAdminPermission.php b/src/Enums/ChatAdminPermission.php index 2357fa9..609d231 100644 --- a/src/Enums/ChatAdminPermission.php +++ b/src/Enums/ChatAdminPermission.php @@ -15,4 +15,5 @@ enum ChatAdminPermission: string case ChangeChatInfo = 'change_chat_info'; case PinMessage = 'pin_message'; case Write = 'write'; + case EditLink = 'edit_link'; } diff --git a/src/ModelFactory.php b/src/ModelFactory.php index 15223e4..3e8f482 100644 --- a/src/ModelFactory.php +++ b/src/ModelFactory.php @@ -15,6 +15,7 @@ use BushlanovDev\MaxMessengerBot\Models\Attachments\Buttons\Inline\AbstractInlin use BushlanovDev\MaxMessengerBot\Models\Attachments\Buttons\Inline\CallbackButton; use BushlanovDev\MaxMessengerBot\Models\Attachments\Buttons\Inline\ChatButton; use BushlanovDev\MaxMessengerBot\Models\Attachments\Buttons\Inline\LinkButton; +use BushlanovDev\MaxMessengerBot\Models\Attachments\Buttons\Inline\MessageButton; use BushlanovDev\MaxMessengerBot\Models\Attachments\Buttons\Inline\OpenAppButton; use BushlanovDev\MaxMessengerBot\Models\Attachments\Buttons\Inline\RequestContactButton; use BushlanovDev\MaxMessengerBot\Models\Attachments\Buttons\Inline\RequestGeoLocationButton; @@ -311,6 +312,7 @@ readonly class ModelFactory InlineButtonType::RequestGeoLocation => RequestGeoLocationButton::fromArray($data), InlineButtonType::Chat => ChatButton::fromArray($data), InlineButtonType::OpenApp => OpenAppButton::fromArray($data), + InlineButtonType::Message => MessageButton::fromArray($data), default => throw new LogicException( 'Unknown or unsupported inline button type: ' . ($data['type'] ?? 'none') ), diff --git a/src/Models/Attachments/Buttons/Inline/MessageButton.php b/src/Models/Attachments/Buttons/Inline/MessageButton.php new file mode 100644 index 0000000..c2746bc --- /dev/null +++ b/src/Models/Attachments/Buttons/Inline/MessageButton.php @@ -0,0 +1,21 @@ +|null $participants List of participants in chat. Returned only when single chat is requested. */ public function __construct( public int $chatId, @@ -45,6 +46,7 @@ final readonly class Chat extends AbstractModel public ?int $messagesCount, public ?string $chatMessageId, public ?Message $pinnedMessage, + public ?array $participants, ) { } } diff --git a/src/Models/ChatAdmin.php b/src/Models/ChatAdmin.php index 03ceaa8..3c264f4 100644 --- a/src/Models/ChatAdmin.php +++ b/src/Models/ChatAdmin.php @@ -15,11 +15,13 @@ final readonly class ChatAdmin extends AbstractModel /** * @param int $userId The identifier of the user to be made an admin. * @param ChatAdminPermission[] $permissions The list of permissions to grant to the user. + * @param string|null $alias Alias of the user. */ public function __construct( public int $userId, #[ArrayOf(ChatAdminPermission::class)] public array $permissions, + public ?string $alias = null, ) { } } diff --git a/src/Models/ChatMember.php b/src/Models/ChatMember.php index a9cf1a4..c6ad0d3 100644 --- a/src/Models/ChatMember.php +++ b/src/Models/ChatMember.php @@ -27,6 +27,7 @@ final readonly class ChatMember extends AbstractModel * @param bool $isAdmin True if this member is an administrator of the chat. * @param int $joinTime The time the user joined the chat. * @param ChatAdminPermission[]|null $permissions A list of permissions if the member is an admin, otherwise null. + * @param string|null $alias Alias of the user. */ public function __construct( public int $userId, @@ -44,6 +45,7 @@ final readonly class ChatMember extends AbstractModel public int $joinTime, #[ArrayOf(ChatAdminPermission::class)] public ?array $permissions, + public ?string $alias, ) { } } diff --git a/tests/ApiTest.php b/tests/ApiTest.php index eca9644..0cf28fa 100644 --- a/tests/ApiTest.php +++ b/tests/ApiTest.php @@ -1671,8 +1671,8 @@ final class ApiTest extends TestCase $expectedBody = [ 'admins' => [ - ['user_id' => 101, 'permissions' => ['write']], - ['user_id' => 202, 'permissions' => ['pin_message']], + ['user_id' => 101, 'permissions' => ['write'], 'alias' => null], + ['user_id' => 202, 'permissions' => ['pin_message'], 'alias' => null], ], ]; $rawResponse = ['success' => true]; diff --git a/tests/ModelFactoryTest.php b/tests/ModelFactoryTest.php index 84f819d..e4b78d1 100644 --- a/tests/ModelFactoryTest.php +++ b/tests/ModelFactoryTest.php @@ -458,6 +458,7 @@ final class ModelFactoryTest extends TestCase 'is_admin' => true, 'join_time' => 1678000000, 'permissions' => ['pin_message', 'write'], + 'alias' => null, ]; $chatMember = $this->factory->createChatMember($rawData); diff --git a/tests/Models/Attachments/Buttons/Inline/MessageButtonTest.php b/tests/Models/Attachments/Buttons/Inline/MessageButtonTest.php new file mode 100644 index 0000000..98d7c8e --- /dev/null +++ b/tests/Models/Attachments/Buttons/Inline/MessageButtonTest.php @@ -0,0 +1,30 @@ + InlineButtonType::Message->value, + 'text' => 'Test Button', + ]; + + $resultArray = $button->toArray(); + + $this->assertSame($expectedArray, $resultArray); + } +} diff --git a/tests/Models/BotPatchTest.php b/tests/Models/BotPatchTest.php index 93ad912..4270257 100644 --- a/tests/Models/BotPatchTest.php +++ b/tests/Models/BotPatchTest.php @@ -58,4 +58,11 @@ final class BotPatchTest extends TestCase $patch = new BotPatch(); $this->assertEmpty($patch->toArray()); } + + #[Test] + public function toArrayFirstAndLastName(): void + { + $patch = new BotPatch(first_name: 'New Name', last_name: null); + $this->assertEquals(['first_name' => 'New Name', 'last_name' => null], $patch->toArray()); + } } diff --git a/tests/Models/ChatAdminTest.php b/tests/Models/ChatAdminTest.php index 9671125..64fa712 100644 --- a/tests/Models/ChatAdminTest.php +++ b/tests/Models/ChatAdminTest.php @@ -24,6 +24,7 @@ final class ChatAdminTest extends TestCase $expected = [ 'user_id' => 123, 'permissions' => ['write', 'pin_message'], + 'alias' => null, ]; $this->assertEquals($expected, $admin->toArray()); diff --git a/tests/Models/ChatMemberTest.php b/tests/Models/ChatMemberTest.php index 4f207e0..fabdd96 100644 --- a/tests/Models/ChatMemberTest.php +++ b/tests/Models/ChatMemberTest.php @@ -34,6 +34,7 @@ final class ChatMemberTest extends TestCase 'is_admin' => true, 'join_time' => 1678000000, 'permissions' => ['pin_message', 'write'], + 'alias' => null, ]; $member = ChatMember::fromArray($data); @@ -66,6 +67,7 @@ final class ChatMemberTest extends TestCase 'is_admin' => false, 'join_time' => 1678000001, 'permissions' => null, + 'alias' => null, ]; $member = ChatMember::fromArray($data); diff --git a/tests/Models/ChatTest.php b/tests/Models/ChatTest.php index 269d942..dc01d3c 100644 --- a/tests/Models/ChatTest.php +++ b/tests/Models/ChatTest.php @@ -48,6 +48,10 @@ final class ChatTest extends TestCase ], 'messages_count' => 100, 'chat_message_id' => 'mid.123', + 'participants' => [ + '456' => 1678886400000, + '789' => 1678886500000, + ], ]; $chat = Chat::fromArray($data); @@ -99,5 +103,6 @@ final class ChatTest extends TestCase $this->assertNull($chat->dialogWithUser); $this->assertNull($chat->messagesCount); $this->assertNull($chat->chatMessageId); + $this->assertNull($chat->participants); } }