-
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.
- 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,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#deletechatstickerset | ||
*/ | ||
final readonly class DeleteChatStickerSet implements TelegramRequestWithResultPreparingInterface | ||
{ | ||
public function __construct( | ||
private int|string $chatId, | ||
) { | ||
} | ||
|
||
public function getHttpMethod(): HttpMethod | ||
{ | ||
return HttpMethod::POST; | ||
} | ||
|
||
public function getApiMethod(): string | ||
{ | ||
return 'deleteChatStickerSet'; | ||
} | ||
|
||
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
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#setchatstickerset | ||
*/ | ||
final readonly class SetChatStickerSet implements TelegramRequestWithResultPreparingInterface | ||
{ | ||
public function __construct( | ||
private int|string $chatId, | ||
private string $stickerSetName, | ||
) { | ||
} | ||
|
||
public function getHttpMethod(): HttpMethod | ||
{ | ||
return HttpMethod::POST; | ||
} | ||
|
||
public function getApiMethod(): string | ||
{ | ||
return 'setChatStickerSet'; | ||
} | ||
|
||
public function getData(): array | ||
{ | ||
return [ | ||
'chat_id' => $this->chatId, | ||
'sticker_set_name' => $this->stickerSetName, | ||
]; | ||
} | ||
|
||
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,35 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Vjik\TelegramBot\Api\Tests\Method; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Vjik\TelegramBot\Api\Method\DeleteChatStickerSet; | ||
use Vjik\TelegramBot\Api\Request\HttpMethod; | ||
|
||
final class DeleteChatStickerSetTest extends TestCase | ||
{ | ||
public function testBase(): void | ||
{ | ||
$method = new DeleteChatStickerSet(1); | ||
|
||
$this->assertSame(HttpMethod::POST, $method->getHttpMethod()); | ||
$this->assertSame('deleteChatStickerSet', $method->getApiMethod()); | ||
$this->assertSame( | ||
[ | ||
'chat_id' => 1, | ||
], | ||
$method->getData(), | ||
); | ||
} | ||
|
||
public function testPrepareResult(): void | ||
{ | ||
$method = new DeleteChatStickerSet(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
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\SetChatStickerSet; | ||
use Vjik\TelegramBot\Api\Request\HttpMethod; | ||
|
||
final class SetChatStickerSetTest extends TestCase | ||
{ | ||
public function testBase(): void | ||
{ | ||
$method = new SetChatStickerSet(1, 'animals_by_bot'); | ||
|
||
$this->assertSame(HttpMethod::POST, $method->getHttpMethod()); | ||
$this->assertSame('setChatStickerSet', $method->getApiMethod()); | ||
$this->assertSame( | ||
[ | ||
'chat_id' => 1, | ||
'sticker_set_name' => 'animals_by_bot', | ||
], | ||
$method->getData(), | ||
); | ||
} | ||
|
||
public function testPrepareResult(): void | ||
{ | ||
$method = new SetChatStickerSet(1, 'animals_by_bot'); | ||
|
||
$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