From 80b7a2af7d20e343d273e998771066b6653c7a89 Mon Sep 17 00:00:00 2001 From: Userator Date: Sat, 4 Apr 2026 18:07:44 +0300 Subject: [PATCH 1/3] Add `certificate` constructor parameter to `SetWebhook` class and add `certificate` field to `TelegramBotApi::setWebhook()` method. --- CHANGELOG.md | 4 ++++ src/Method/Update/SetWebhook.php | 3 +++ src/TelegramBotApi.php | 3 ++- tests/Method/Update/SetWebhookTest.php | 4 ++++ 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 631d5271..e923c30f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Telegram Bot API for PHP Change Log +## 0.19 April 4, 2026 + +- New #192: Add `certificate` constructor parameter to `SetWebhook` class and add `certificate` field to `TelegramBotApi::setWebhook()` method. + ## 0.18 April 4, 2026 - Enh #190: Open file in binary mode in `InputFile::fromLocalFile()` method. diff --git a/src/Method/Update/SetWebhook.php b/src/Method/Update/SetWebhook.php index 726f3cb8..18b9a27d 100644 --- a/src/Method/Update/SetWebhook.php +++ b/src/Method/Update/SetWebhook.php @@ -4,6 +4,7 @@ namespace Phptg\BotApi\Method\Update; +use Phptg\BotApi\Type\InputFile; use SensitiveParameter; use Phptg\BotApi\ParseResult\ValueProcessor\TrueValue; use Phptg\BotApi\Transport\HttpMethod; @@ -24,6 +25,7 @@ public function __construct( private ?bool $dropPendingUpdates = null, #[SensitiveParameter] private ?string $secretToken = null, + private ?InputFile $certificate = null, ) {} public function getHttpMethod(): HttpMethod @@ -46,6 +48,7 @@ public function getData(): array 'allowed_updates' => $this->allowUpdates, 'drop_pending_updates' => $this->dropPendingUpdates, 'secret_token' => $this->secretToken, + 'certificate' => $this->certificate, ], static fn(mixed $value): bool => $value !== null, ); diff --git a/src/TelegramBotApi.php b/src/TelegramBotApi.php index e4c7e1ee..45c9da1d 100644 --- a/src/TelegramBotApi.php +++ b/src/TelegramBotApi.php @@ -3169,9 +3169,10 @@ public function setWebhook( ?bool $dropPendingUpdates = null, #[SensitiveParameter] ?string $secretToken = null, + ?InputFile $certificate = null, ): FailResult|true { return $this->call( - new SetWebhook($url, $ipAddress, $maxConnections, $allowUpdates, $dropPendingUpdates, $secretToken), + new SetWebhook($url, $ipAddress, $maxConnections, $allowUpdates, $dropPendingUpdates, $secretToken, $certificate), ); } diff --git a/tests/Method/Update/SetWebhookTest.php b/tests/Method/Update/SetWebhookTest.php index 085498db..2ced80b5 100644 --- a/tests/Method/Update/SetWebhookTest.php +++ b/tests/Method/Update/SetWebhookTest.php @@ -4,6 +4,7 @@ namespace Phptg\BotApi\Tests\Method\Update; +use Phptg\BotApi\Type\InputFile; use PHPUnit\Framework\TestCase; use Phptg\BotApi\Transport\HttpMethod; use Phptg\BotApi\Method\Update\SetWebhook; @@ -30,6 +31,7 @@ public function testBase(): void public function testFull(): void { + $file = new InputFile(null); $method = new SetWebhook( 'https://example.com/hook', '127.0.0.1', @@ -37,6 +39,7 @@ public function testFull(): void ['update1', 'update2'], true, 'asdg23y', + $file, ); assertSame(HttpMethod::POST, $method->getHttpMethod()); @@ -49,6 +52,7 @@ public function testFull(): void 'allowed_updates' => ['update1', 'update2'], 'drop_pending_updates' => true, 'secret_token' => 'asdg23y', + 'certificate' => $file, ], $method->getData(), ); From d3341118e37418d81520dc5ddeebf218b36e9324 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Sun, 5 Apr 2026 08:31:56 +0300 Subject: [PATCH 2/3] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e923c30f..4e9eb6a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## 0.19 April 4, 2026 -- New #192: Add `certificate` constructor parameter to `SetWebhook` class and add `certificate` field to `TelegramBotApi::setWebhook()` method. +- Bug #192: Add missed `certificate` parameter to `SetWebhook` method. ## 0.18 April 4, 2026 From 629dd53d33a6c32b7f4ad58247b4d0aff5562962 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Sun, 5 Apr 2026 08:32:05 +0300 Subject: [PATCH 3/3] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e9eb6a2..6c6c9f3a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Telegram Bot API for PHP Change Log -## 0.19 April 4, 2026 +## 0.18.1 April 5, 2026 - Bug #192: Add missed `certificate` parameter to `SetWebhook` method.