-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
unpinAllForumTopicMessages
and `unpinAllGeneralForumTopicMessag…
…es` methods (#66)
- Loading branch information
Showing
7 changed files
with
210 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Vjik\TelegramBot\Api\Method; | ||
|
||
use Vjik\TelegramBot\Api\ParseResult\ValueHelper; | ||
use Vjik\TelegramBot\Api\Request\HttpMethod; | ||
use Vjik\TelegramBot\Api\Request\TelegramRequestWithResultPreparingInterface; | ||
|
||
/** | ||
* @see https://core.telegram.org/bots/api#unpinallforumtopicmessages | ||
*/ | ||
final readonly class UnpinAllForumTopicMessages implements TelegramRequestWithResultPreparingInterface | ||
{ | ||
public function __construct( | ||
private int|string $chatId, | ||
private int $messageThreadId, | ||
) { | ||
} | ||
|
||
public function getHttpMethod(): HttpMethod | ||
{ | ||
return HttpMethod::POST; | ||
} | ||
|
||
public function getApiMethod(): string | ||
{ | ||
return 'unpinAllForumTopicMessages'; | ||
} | ||
|
||
public function getData(): array | ||
{ | ||
return [ | ||
'chat_id' => $this->chatId, | ||
'message_thread_id' => $this->messageThreadId, | ||
]; | ||
} | ||
|
||
public function prepareResult(mixed $result): true | ||
{ | ||
ValueHelper::assertTrueResult($result); | ||
return $result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Vjik\TelegramBot\Api\Method; | ||
|
||
use Vjik\TelegramBot\Api\ParseResult\ValueHelper; | ||
use Vjik\TelegramBot\Api\Request\HttpMethod; | ||
use Vjik\TelegramBot\Api\Request\TelegramRequestWithResultPreparingInterface; | ||
|
||
/** | ||
* @see https://core.telegram.org/bots/api#unpinallgeneralforumtopicmessages | ||
*/ | ||
final readonly class UnpinAllGeneralForumTopicMessages implements TelegramRequestWithResultPreparingInterface | ||
{ | ||
public function __construct( | ||
private int|string $chatId, | ||
) { | ||
} | ||
|
||
public function getHttpMethod(): HttpMethod | ||
{ | ||
return HttpMethod::POST; | ||
} | ||
|
||
public function getApiMethod(): string | ||
{ | ||
return 'unpinAllGeneralForumTopicMessages'; | ||
} | ||
|
||
public function getData(): array | ||
{ | ||
return [ | ||
'chat_id' => $this->chatId, | ||
]; | ||
} | ||
|
||
public function prepareResult(mixed $result): true | ||
{ | ||
ValueHelper::assertTrueResult($result); | ||
return $result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Vjik\TelegramBot\Api\Tests\Method; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Vjik\TelegramBot\Api\Method\UnpinAllForumTopicMessages; | ||
use Vjik\TelegramBot\Api\Request\HttpMethod; | ||
|
||
final class UnpinAllForumTopicMessagesTest extends TestCase | ||
{ | ||
public function testBase(): void | ||
{ | ||
$method = new UnpinAllForumTopicMessages(1, 2); | ||
|
||
$this->assertSame(HttpMethod::POST, $method->getHttpMethod()); | ||
$this->assertSame('unpinAllForumTopicMessages', $method->getApiMethod()); | ||
$this->assertSame( | ||
[ | ||
'chat_id' => 1, | ||
'message_thread_id' => 2, | ||
], | ||
$method->getData(), | ||
); | ||
} | ||
|
||
public function testPrepareResult(): void | ||
{ | ||
$method = new UnpinAllForumTopicMessages(1, 2); | ||
|
||
$preparedResult = $method->prepareResult(true); | ||
|
||
$this->assertTrue($preparedResult); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Vjik\TelegramBot\Api\Tests\Method; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Vjik\TelegramBot\Api\Method\UnpinAllGeneralForumTopicMessages; | ||
use Vjik\TelegramBot\Api\Request\HttpMethod; | ||
|
||
final class UnpinAllGeneralForumTopicMessagesTest extends TestCase | ||
{ | ||
public function testBase(): void | ||
{ | ||
$method = new UnpinAllGeneralForumTopicMessages(1); | ||
|
||
$this->assertSame(HttpMethod::POST, $method->getHttpMethod()); | ||
$this->assertSame('unpinAllGeneralForumTopicMessages', $method->getApiMethod()); | ||
$this->assertSame( | ||
[ | ||
'chat_id' => 1, | ||
], | ||
$method->getData(), | ||
); | ||
} | ||
|
||
public function testPrepareResult(): void | ||
{ | ||
$method = new UnpinAllGeneralForumTopicMessages(1); | ||
|
||
$preparedResult = $method->prepareResult(true); | ||
|
||
$this->assertTrue($preparedResult); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters