From e014246077581463bf877ac3f43bcf759a60dd42 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Thu, 1 Aug 2024 10:07:21 +0300 Subject: [PATCH 1/3] Add `hasMainWebApp` field to `User` type --- CHANGELOG.md | 4 ++++ src/Type/User.php | 2 ++ tests/Type/UserTest.php | 5 +++++ 3 files changed, 11 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b00c6db..165f143 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Telegram Bot API for PHP Change Log +## 0.4.1 under development + +- New #115: Add `hasMainWebApp` field to `User` type. + ## 0.4.0 July 10, 2024 - New #103: Add `Update::getRaw()` method that returns raw data if type created by `Update::fromJson()` or diff --git a/src/Type/User.php b/src/Type/User.php index 3b71a22..35ff84f 100644 --- a/src/Type/User.php +++ b/src/Type/User.php @@ -22,6 +22,7 @@ public function __construct( public ?bool $canReadAllGroupMessages = null, public ?bool $supportsInlineQueries = null, public ?bool $canConnectToBusiness = null, + public ?bool $hasMainWebApp = null, ) {} public function toRequestArray(): array @@ -40,6 +41,7 @@ public function toRequestArray(): array 'can_read_all_group_messages' => $this->canReadAllGroupMessages, 'supports_inline_queries' => $this->supportsInlineQueries, 'can_connect_to_business' => $this->canConnectToBusiness, + 'has_main_web_app' => $this->hasMainWebApp, ], static fn(mixed $value): bool => $value !== null, ); diff --git a/tests/Type/UserTest.php b/tests/Type/UserTest.php index 0667874..cd89284 100644 --- a/tests/Type/UserTest.php +++ b/tests/Type/UserTest.php @@ -26,6 +26,7 @@ public function testBase(): void $this->assertNull($user->canReadAllGroupMessages); $this->assertNull($user->supportsInlineQueries); $this->assertNull($user->canConnectToBusiness); + $this->assertNull($user->hasMainWebApp); } public function testToRequestArray(): void @@ -43,6 +44,7 @@ public function testToRequestArray(): void true, true, true, + false, ); $this->assertSame( @@ -59,6 +61,7 @@ public function testToRequestArray(): void 'can_read_all_group_messages' => true, 'supports_inline_queries' => true, 'can_connect_to_business' => true, + 'has_main_web_app' => false, ], $user->toRequestArray(), ); @@ -79,6 +82,7 @@ public function testFromTelegramResult(): void 'can_read_all_group_messages' => true, 'supports_inline_queries' => true, 'can_connect_to_business' => true, + 'has_main_web_app' => false, ], null, User::class); $this->assertInstanceOf(User::class, $user); @@ -94,5 +98,6 @@ public function testFromTelegramResult(): void $this->assertSame(true, $user->canReadAllGroupMessages); $this->assertSame(true, $user->supportsInlineQueries); $this->assertSame(true, $user->canConnectToBusiness); + $this->assertSame(false, $user->hasMainWebApp); } } From f3577714cd2f1b2a852e5151f18e9694f88cd4da Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Thu, 1 Aug 2024 10:12:51 +0300 Subject: [PATCH 2/3] Add `businessConnectionId` parameter to `PinChatMessage` and `UnpinChatMessage` methods --- CHANGELOG.md | 1 + src/Method/PinChatMessage.php | 2 ++ src/Method/UnpinChatMessage.php | 2 ++ tests/Method/PinChatMessageTest.php | 3 ++- tests/Method/UnpinChatMessageTest.php | 3 ++- 5 files changed, 9 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 165f143..10e3b49 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## 0.4.1 under development - New #115: Add `hasMainWebApp` field to `User` type. +- New #115: Add `businessConnectionId` parameter to `PinChatMessage` and `UnpinChatMessage` methods. ## 0.4.0 July 10, 2024 diff --git a/src/Method/PinChatMessage.php b/src/Method/PinChatMessage.php index e2a65f7..97e817e 100644 --- a/src/Method/PinChatMessage.php +++ b/src/Method/PinChatMessage.php @@ -17,6 +17,7 @@ public function __construct( private int|string $chatId, private int $messageId, private ?bool $disableNotification = null, + private ?string $businessConnectionId = null, ) {} public function getHttpMethod(): HttpMethod @@ -33,6 +34,7 @@ public function getData(): array { return array_filter( [ + 'business_connection_id' => $this->businessConnectionId, 'chat_id' => $this->chatId, 'message_id' => $this->messageId, 'disable_notification' => $this->disableNotification, diff --git a/src/Method/UnpinChatMessage.php b/src/Method/UnpinChatMessage.php index 0e1c1a0..768391b 100644 --- a/src/Method/UnpinChatMessage.php +++ b/src/Method/UnpinChatMessage.php @@ -16,6 +16,7 @@ public function __construct( private int|string $chatId, private ?int $messageId = null, + private ?string $businessConnectionId = null, ) {} public function getHttpMethod(): HttpMethod @@ -32,6 +33,7 @@ public function getData(): array { return array_filter( [ + 'business_connection_id' => $this->businessConnectionId, 'chat_id' => $this->chatId, 'message_id' => $this->messageId, ], diff --git a/tests/Method/PinChatMessageTest.php b/tests/Method/PinChatMessageTest.php index 237819c..2c320e5 100644 --- a/tests/Method/PinChatMessageTest.php +++ b/tests/Method/PinChatMessageTest.php @@ -28,12 +28,13 @@ public function testBase(): void public function testFull(): void { - $method = new PinChatMessage(1, 2, true); + $method = new PinChatMessage(1, 2, true, 'bid'); $this->assertSame(HttpMethod::POST, $method->getHttpMethod()); $this->assertSame('pinChatMessage', $method->getApiMethod()); $this->assertSame( [ + 'business_connection_id' => 'bid', 'chat_id' => 1, 'message_id' => 2, 'disable_notification' => true, diff --git a/tests/Method/UnpinChatMessageTest.php b/tests/Method/UnpinChatMessageTest.php index 47b416d..c787e3c 100644 --- a/tests/Method/UnpinChatMessageTest.php +++ b/tests/Method/UnpinChatMessageTest.php @@ -27,12 +27,13 @@ public function testBase(): void public function testFull(): void { - $method = new UnpinChatMessage(1, 2); + $method = new UnpinChatMessage(1, 2, 'bid'); $this->assertSame(HttpMethod::POST, $method->getHttpMethod()); $this->assertSame('unpinChatMessage', $method->getApiMethod()); $this->assertSame( [ + 'business_connection_id' => 'bid', 'chat_id' => 1, 'message_id' => 2, ], From 050a423da9e763a7d034922245da1f73a8e7928f Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Thu, 1 Aug 2024 10:13:15 +0300 Subject: [PATCH 3/3] Fix readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 575d685..739e079 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ The package provides a simple and convenient way to interact with the Telegram Bot API. -✔️ Telegram Bot API 7.7 (July 7, 2024) is **full supported**. +✔️ Telegram Bot API 7.8 (July 31, 2024) is **full supported**. ## Requirements