-
Notifications
You must be signed in to change notification settings - Fork 325
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: #465 add Chat Boost as defined in api 7.0
- Loading branch information
1 parent
742afb8
commit d9d4fe5
Showing
9 changed files
with
266 additions
and
2 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
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 |
---|---|---|
|
@@ -3,6 +3,7 @@ | |
namespace TelegramBot\Api; | ||
|
||
use TelegramBot\Api\Http\CurlHttpClient; | ||
use TelegramBot\Api\Types\UserChatBoosts; | ||
use TelegramBot\Api\Types\ReplyParameters; | ||
use TelegramBot\Api\Http\HttpClientInterface; | ||
use TelegramBot\Api\Types\ArrayOfBotCommand; | ||
|
@@ -3160,6 +3161,26 @@ public function copyMessages( | |
]); | ||
} | ||
|
||
/** | ||
* Use this method to get the list of boosts added to a chat by a user. Requires administrator rights in the chat. | ||
* Returns a UserChatBoosts object. | ||
* | ||
* @param string|int $chatId Unique identifier for the chat or username of the channel (in the format @channelusername) | ||
* @param int $userId Unique identifier of the target user | ||
* | ||
* @return UserChatBoosts | ||
* @throws Exception | ||
* | ||
* @author bernard-ng <[email protected]> | ||
*/ | ||
public function getUserChatBoosts($chatId, $userId) | ||
{ | ||
return UserChatBoosts::fromResponse($this->call('getUserChatBoosts', [ | ||
'chat_id' => $chatId, | ||
'user_id' => $userId | ||
])); | ||
} | ||
|
||
/** | ||
* Set an option for a cURL transfer | ||
* | ||
|
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,50 @@ | ||
<?php | ||
|
||
namespace TelegramBot\Api\Test\Types; | ||
|
||
use TelegramBot\Api\Test\AbstractTypeTest; | ||
use TelegramBot\Api\Types\ChatBoostRemoved; | ||
|
||
class ChatBoostRemovedTest extends AbstractTypeTest | ||
{ | ||
protected static function getType() | ||
{ | ||
return ChatBoostRemoved::class; | ||
} | ||
|
||
public static function getMinResponse() | ||
{ | ||
return [ | ||
'chat' => ChatTest::getMinResponse(), | ||
'boost_id' => 1, | ||
'remove_date' => 1682343643, | ||
'source' => ChatBoostSourceTest::getMinResponse() | ||
]; | ||
} | ||
|
||
public static function getFullResponse() | ||
{ | ||
return [ | ||
'chat' => ChatTest::getMinResponse(), | ||
'boost_id' => 1, | ||
'remove_date' => 1682343643, | ||
'source' => ChatBoostSourceTest::getMinResponse() | ||
]; | ||
} | ||
|
||
protected function assertMinItem($item) | ||
{ | ||
$this->assertEquals(ChatTest::createMinInstance(), $item->getChat()); | ||
$this->assertEquals(1, $item->getBoostId()); | ||
$this->assertEquals(1682343643, $item->getRemoveDate()); | ||
$this->assertEquals(ChatBoostSourceTest::createMinInstance(), $item->getSource()); | ||
} | ||
|
||
protected function assertFullItem($item) | ||
{ | ||
$this->assertEquals(ChatTest::createMinInstance(), $item->getChat()); | ||
$this->assertEquals(1, $item->getBoostId()); | ||
$this->assertEquals(1682343643, $item->getRemoveDate()); | ||
$this->assertEquals(ChatBoostSourceTest::createMinInstance(), $item->getSource()); | ||
} | ||
} |
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,42 @@ | ||
<?php | ||
|
||
namespace TelegramBot\Api\Test\Types; | ||
|
||
use TelegramBot\Api\Test\AbstractTypeTest; | ||
use TelegramBot\Api\Types\ChatBoostSource; | ||
|
||
class ChatBoostSourceTest extends AbstractTypeTest | ||
{ | ||
protected static function getType() | ||
{ | ||
return ChatBoostSource::class; | ||
} | ||
|
||
public static function getMinResponse() | ||
{ | ||
return [ | ||
'source' => 'premium', | ||
'user' => UserTest::getMinResponse(), | ||
]; | ||
} | ||
|
||
public static function getFullResponse() | ||
{ | ||
return [ | ||
'source' => 'premium', | ||
'user' => UserTest::getMinResponse(), | ||
]; | ||
} | ||
|
||
protected function assertMinItem($item) | ||
{ | ||
$this->assertEquals('premium', $item->getSource()); | ||
$this->assertEquals(UserTest::createMinInstance(), $item->getUser()); | ||
} | ||
|
||
protected function assertFullItem($item) | ||
{ | ||
$this->assertEquals('premium', $item->getSource()); | ||
$this->assertEquals(UserTest::createMinInstance(), $item->getUser()); | ||
} | ||
} |
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,50 @@ | ||
<?php | ||
|
||
namespace TelegramBot\Api\Test\Types; | ||
|
||
use TelegramBot\Api\Types\ChatBoost; | ||
use TelegramBot\Api\Test\AbstractTypeTest; | ||
|
||
class ChatBoostTest extends AbstractTypeTest | ||
{ | ||
protected static function getType() | ||
{ | ||
return ChatBoost::class; | ||
} | ||
|
||
public static function getMinResponse() | ||
{ | ||
return [ | ||
'boost_id' => 1, | ||
'add_date' => 1682343643, | ||
'expiration_date' => 1725042370, | ||
'source' => ChatBoostSourceTest::getMinResponse() | ||
]; | ||
} | ||
|
||
public static function getFullResponse() | ||
{ | ||
return [ | ||
'boost_id' => 1, | ||
'add_date' => 1682343643, | ||
'expiration_date' => 1725042370, | ||
'source' => ChatBoostSourceTest::getMinResponse() | ||
]; | ||
} | ||
|
||
protected function assertMinItem($item) | ||
{ | ||
$this->assertEquals(1, $item->getBoostId()); | ||
$this->assertEquals(1682343643, $item->getAddDate()); | ||
$this->assertEquals(1725042370, $item->getExpirationDate()); | ||
$this->assertEquals(ChatBoostSourceTest::createMinInstance(), $item->getSource()); | ||
} | ||
|
||
protected function assertFullItem($item) | ||
{ | ||
$this->assertEquals(1, $item->getBoostId()); | ||
$this->assertEquals(1682343643, $item->getAddDate()); | ||
$this->assertEquals(1725042370, $item->getExpirationDate()); | ||
$this->assertEquals(ChatBoostSourceTest::createMinInstance(), $item->getSource()); | ||
} | ||
} |
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,42 @@ | ||
<?php | ||
|
||
namespace TelegramBot\Api\Test\Types; | ||
|
||
use TelegramBot\Api\Test\AbstractTypeTest; | ||
use TelegramBot\Api\Types\ChatBoostUpdated; | ||
|
||
class ChatBoostUpdatedTest extends AbstractTypeTest | ||
{ | ||
protected static function getType() | ||
{ | ||
return ChatBoostUpdated::class; | ||
} | ||
|
||
public static function getMinResponse() | ||
{ | ||
return [ | ||
'chat' => ChatTest::getMinResponse(), | ||
'boost' => ChatBoostTest::getMinResponse(), | ||
]; | ||
} | ||
|
||
public static function getFullResponse() | ||
{ | ||
return [ | ||
'chat' => ChatTest::getMinResponse(), | ||
'boost' => ChatBoostTest::getMinResponse(), | ||
]; | ||
} | ||
|
||
protected function assertMinItem($item) | ||
{ | ||
$this->assertEquals(ChatTest::createMinInstance(), $item->getChat()); | ||
$this->assertEquals(ChatBoostTest::createMinInstance(), $item->getBoost()); | ||
} | ||
|
||
protected function assertFullItem($item) | ||
{ | ||
$this->assertEquals(ChatTest::createMinInstance(), $item->getChat()); | ||
$this->assertEquals(ChatBoostTest::createMinInstance(), $item->getBoost()); | ||
} | ||
} |
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