Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Telegram Bot API for PHP Change Log

## 0.18.1 April 5, 2026

- Bug #192: Add missed `certificate` parameter to `SetWebhook` method.

## 0.18 April 4, 2026

- Enh #190: Open file in binary mode in `InputFile::fromLocalFile()` method.
Expand Down
3 changes: 3 additions & 0 deletions src/Method/Update/SetWebhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -24,6 +25,7 @@ public function __construct(
private ?bool $dropPendingUpdates = null,
#[SensitiveParameter]
private ?string $secretToken = null,
private ?InputFile $certificate = null,
) {}

public function getHttpMethod(): HttpMethod
Expand All @@ -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,
);
Expand Down
3 changes: 2 additions & 1 deletion src/TelegramBotApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
);
}

Expand Down
4 changes: 4 additions & 0 deletions tests/Method/Update/SetWebhookTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -30,13 +31,15 @@ public function testBase(): void

public function testFull(): void
{
$file = new InputFile(null);
$method = new SetWebhook(
'https://example.com/hook',
'127.0.0.1',
12,
['update1', 'update2'],
true,
'asdg23y',
$file,
);

assertSame(HttpMethod::POST, $method->getHttpMethod());
Expand All @@ -49,6 +52,7 @@ public function testFull(): void
'allowed_updates' => ['update1', 'update2'],
'drop_pending_updates' => true,
'secret_token' => 'asdg23y',
'certificate' => $file,
],
$method->getData(),
);
Expand Down
Loading