diff --git a/CHANGELOG.md b/CHANGELOG.md index 60817072..739458d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,13 @@ All Notable changes to `PHP Telegram Bot Api` will be documented in this file ## 3.0.0 - YYYY-MM-DD +- Add `\TelegramBot\Api\BotApi::replaceStickerInSet` api method +- Add Added the parameter `business_connection_id` to `\TelegramBot\Api\BotApi` send methods +- Add `\TelegramBot\Api\BotApi::getBusinessConnection` api method +- Add `\TelegramBot\Api\Types\Update::$deletedBusinessMessages` field +- Add `\TelegramBot\Api\Types\Update::$editedBusinessMessage` field +- Add `\TelegramBot\Api\Types\Update::$businessMessage` field +- Add `\TelegramBot\Api\Types\Update::$businessConnection` field - Add `\TelegramBot\Api\Types\Update::$myChatMember` field - Add `\TelegramBot\Api\Types\Update::$chatMember` field - Add `\TelegramBot\Api\Types\Update::$chatJoinRequest` field diff --git a/src/BotApi.php b/src/BotApi.php index ef9ddccd..3174e953 100644 --- a/src/BotApi.php +++ b/src/BotApi.php @@ -2,12 +2,14 @@ namespace TelegramBot\Api; +use TelegramBot\Api\Types\InputSticker; 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; use TelegramBot\Api\Types\LinkPreviewOptions; +use TelegramBot\Api\Types\BusinessConnection; use TelegramBot\Api\Types\ArrayOfReactionType; use TelegramBot\Api\Types\ArrayOfChatMemberEntity; use TelegramBot\Api\Types\ArrayOfMessageEntity; @@ -343,6 +345,7 @@ public static function jsonValidate($jsonString, $asArray) * @param bool|null $allowSendingWithoutReply * @param ReplyParameters|null $replyParameters Description of the message to reply to. * @param LinkPreviewOptions|null $linkPreviewOptions Link preview generation options for the message. + * @param string|null $businessConnectionId Unique identifier of the business connection on behalf of which the message will be sent * * @return Message * @throws InvalidArgumentException @@ -360,7 +363,8 @@ public function sendMessage( $protectContent = null, $allowSendingWithoutReply = null, $replyParameters = null, - $linkPreviewOptions = null + $linkPreviewOptions = null, + $businessConnectionId = null ) { if (null !== $replyToMessageId || null !== $allowSendingWithoutReply) { @trigger_error( @@ -393,7 +397,8 @@ public function sendMessage( 'disable_notification' => (bool) $disableNotification, 'protect_content' => (bool) $protectContent, 'reply_parameters' => is_null($replyParameters) ? $replyParameters : $replyParameters->toJson(), - 'link_preview_options' => is_null($linkPreviewOptions) ? $linkPreviewOptions : $linkPreviewOptions->toJson() + 'link_preview_options' => is_null($linkPreviewOptions) ? $linkPreviewOptions : $linkPreviewOptions->toJson(), + 'business_connection_id' => $businessConnectionId ])); } @@ -474,6 +479,7 @@ public function copyMessage( * @param bool|null $protectContent * @param bool|null $allowSendingWithoutReply * @param ReplyParameters|null $replyParameters Description of the message to reply to. + * @param string|null $businessConnectionId Unique identifier of the business connection on behalf of which the message will be sent * * @return Message * @throws Exception @@ -489,7 +495,8 @@ public function sendContact( $messageThreadId = null, $protectContent = null, $allowSendingWithoutReply = null, - $replyParameters = null + $replyParameters = null, + $businessConnectionId = null ) { if (null !== $replyToMessageId || null !== $allowSendingWithoutReply) { @trigger_error( @@ -513,7 +520,8 @@ public function sendContact( 'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(), 'disable_notification' => (bool) $disableNotification, 'protect_content' => (bool) $protectContent, - 'reply_parameters' => is_null($replyParameters) ? $replyParameters : $replyParameters->toJson() + 'reply_parameters' => is_null($replyParameters) ? $replyParameters : $replyParameters->toJson(), + 'business_connection_id' => $businessConnectionId ])); } @@ -531,15 +539,17 @@ public function sendContact( * * @param int $chatId * @param string $action + * @param string|null $businessConnectionId Unique identifier of the business connection on behalf of which the message will be sent * * @return bool * @throws Exception */ - public function sendChatAction($chatId, $action) + public function sendChatAction($chatId, $action, $businessConnectionId = null) { return $this->call('sendChatAction', [ 'chat_id' => $chatId, 'action' => $action, + 'business_connection_id' => $businessConnectionId ]); } @@ -694,6 +704,7 @@ public function getUpdates($offset = 0, $limit = 100, $timeout = 0) * @param bool|null $protectContent * @param bool|null $allowSendingWithoutReply * @param ReplyParameters|null $replyParameters Description of the message to reply to. + * @param string|null $businessConnectionId Unique identifier of the business connection on behalf of which the message will be sent * * @return Message * @@ -710,7 +721,8 @@ public function sendLocation( $messageThreadId = null, $protectContent = null, $allowSendingWithoutReply = null, - $replyParameters = null + $replyParameters = null, + $businessConnectionId = null ) { if (null !== $replyToMessageId || null !== $allowSendingWithoutReply) { @trigger_error( @@ -734,7 +746,8 @@ public function sendLocation( 'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(), 'disable_notification' => (bool) $disableNotification, 'protect_content' => (bool) $protectContent, - 'reply_parameters' => is_null($replyParameters) ? $replyParameters : $replyParameters->toJson() + 'reply_parameters' => is_null($replyParameters) ? $replyParameters : $replyParameters->toJson(), + 'business_connection_id' => $businessConnectionId ])); } @@ -825,6 +838,7 @@ public function stopMessageLiveLocation( * @param bool|null $protectContent * @param bool|null $allowSendingWithoutReply * @param ReplyParameters|null $replyParameters Description of the message to reply to. + * @param string|null $businessConnectionId Unique identifier of the business connection on behalf of which the message will be sent * * @return Message * @throws Exception @@ -842,7 +856,8 @@ public function sendVenue( $messageThreadId = null, $protectContent = null, $allowSendingWithoutReply = null, - $replyParameters = null + $replyParameters = null, + $businessConnectionId = null ) { if (null !== $replyToMessageId || null !== $allowSendingWithoutReply) { @trigger_error( @@ -868,7 +883,8 @@ public function sendVenue( 'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(), 'disable_notification' => (bool) $disableNotification, 'protect_content' => (bool) $protectContent, - 'reply_parameters' => is_null($replyParameters) ? $replyParameters : $replyParameters->toJson() + 'reply_parameters' => is_null($replyParameters) ? $replyParameters : $replyParameters->toJson(), + 'business_connection_id' => $businessConnectionId ])); } @@ -884,6 +900,7 @@ public function sendVenue( * @param bool $allowSendingWithoutReply Pass True if the message should be sent even if the specified replied-to message is not found * @param string|null $messageThreadId * @param ReplyParameters|null $replyParameters Description of the message to reply to. + * @param string|null $businessConnectionId Unique identifier of the business connection on behalf of which the message will be sent * * @return Message * @throws InvalidArgumentException @@ -898,7 +915,8 @@ public function sendSticker( $protectContent = false, $allowSendingWithoutReply = false, $messageThreadId = null, - $replyParameters = null + $replyParameters = null, + $businessConnectionId = null ) { if (null !== $replyToMessageId || null !== $allowSendingWithoutReply) { @trigger_error( @@ -920,7 +938,8 @@ public function sendSticker( 'reply_markup' => is_null($replyMarkup) ? $replyMarkup : $replyMarkup->toJson(), 'disable_notification' => (bool) $disableNotification, 'protect_content' => (bool) $protectContent, - 'reply_parameters' => is_null($replyParameters) ? $replyParameters : $replyParameters->toJson() + 'reply_parameters' => is_null($replyParameters) ? $replyParameters : $replyParameters->toJson(), + 'business_connection_id' => $businessConnectionId ])); } @@ -1160,6 +1179,7 @@ public function setStickerSetThumb($name, $userId, $thumb = null) * @param bool|null $allowSendingWithoutReply * @param \CURLFile|\CURLStringFile|string|null $thumbnail * @param ReplyParameters|null $replyParameters Description of the message to reply to. + * @param string|null $businessConnectionId Unique identifier of the business connection on behalf of which the message will be sent * * @return Message * @throws InvalidArgumentException @@ -1179,7 +1199,8 @@ public function sendVideo( $protectContent = null, $allowSendingWithoutReply = null, $thumbnail = null, - $replyParameters = null + $replyParameters = null, + $businessConnectionId = null ) { if (null !== $replyToMessageId || null !== $allowSendingWithoutReply) { @trigger_error( @@ -1206,7 +1227,8 @@ public function sendVideo( 'parse_mode' => $parseMode, 'protect_content' => (bool) $protectContent, 'thumbnail' => $thumbnail, - 'reply_parameters' => is_null($replyParameters) ? $replyParameters : $replyParameters->toJson() + 'reply_parameters' => is_null($replyParameters) ? $replyParameters : $replyParameters->toJson(), + 'business_connection_id' => $businessConnectionId ])); } @@ -1228,6 +1250,7 @@ public function sendVideo( * @param bool|null $allowSendingWithoutReply * @param \CURLFile|\CURLStringFile|string|null $thumbnail * @param ReplyParameters|null $replyParameters Description of the message to reply to. + * @param string|null $businessConnectionId Unique identifier of the business connection on behalf of which the message will be sent * * @return Message * @throws InvalidArgumentException @@ -1246,7 +1269,8 @@ public function sendAnimation( $protectContent = null, $allowSendingWithoutReply = null, $thumbnail = null, - $replyParameters = null + $replyParameters = null, + $businessConnectionId = null ) { if (null !== $replyToMessageId || null !== $allowSendingWithoutReply) { @trigger_error( @@ -1272,7 +1296,8 @@ public function sendAnimation( 'parse_mode' => $parseMode, 'protect_content' => (bool) $protectContent, 'thumbnail' => $thumbnail, - 'reply_parameters' => is_null($replyParameters) ? $replyParameters : $replyParameters->toJson() + 'reply_parameters' => is_null($replyParameters) ? $replyParameters : $replyParameters->toJson(), + 'business_connection_id' => $businessConnectionId ])); } @@ -1297,6 +1322,7 @@ public function sendAnimation( * @param int|null $messageThreadId * @param bool|null $protectContent * @param ReplyParameters|null $replyParameters Description of the message to reply to. + * @param string|null $businessConnectionId Unique identifier of the business connection on behalf of which the message will be sent * * @return Message * @throws InvalidArgumentException @@ -1314,7 +1340,8 @@ public function sendVoice( $parseMode = null, $messageThreadId = null, $protectContent = null, - $replyParameters = null + $replyParameters = null, + $businessConnectionId = null ) { if (null !== $replyToMessageId || null !== $allowSendingWithoutReply) { @trigger_error( @@ -1339,7 +1366,8 @@ public function sendVoice( 'disable_notification' => (bool) $disableNotification, 'parse_mode' => $parseMode, 'protect_content' => (bool) $protectContent, - 'reply_parameters' => is_null($replyParameters) ? $replyParameters : $replyParameters->toJson() + 'reply_parameters' => is_null($replyParameters) ? $replyParameters : $replyParameters->toJson(), + 'business_connection_id' => $businessConnectionId ])); } @@ -1402,6 +1430,7 @@ public function forwardMessage( * @param bool|null $allowSendingWithoutReply * @param \CURLFile|\CURLStringFile|string|null $thumbnail * @param ReplyParameters|null $replyParameters Description of the message to reply to. + * @param string|null $businessConnectionId Unique identifier of the business connection on behalf of which the message will be sent * * @return Message * @throws InvalidArgumentException @@ -1424,7 +1453,8 @@ public function sendAudio( $protectContent = null, $allowSendingWithoutReply = null, $thumbnail = null, - $replyParameters = null + $replyParameters = null, + $businessConnectionId = null ) { if (null !== $replyToMessageId || null !== $allowSendingWithoutReply) { @trigger_error( @@ -1450,7 +1480,8 @@ public function sendAudio( 'parse_mode' => $parseMode, 'protect_content' => (bool) $protectContent, 'thumbnail' => $thumbnail, - 'reply_parameters' => is_null($replyParameters) ? $replyParameters : $replyParameters->toJson() + 'reply_parameters' => is_null($replyParameters) ? $replyParameters : $replyParameters->toJson(), + 'business_connection_id' => $businessConnectionId ])); } @@ -1468,6 +1499,7 @@ public function sendAudio( * @param bool|null $protectContent * @param bool|null $allowSendingWithoutReply * @param ReplyParameters|null $replyParameters Description of the message to reply to. + * @param string|null $businessConnectionId Unique identifier of the business connection on behalf of which the message will be sent * * @return Message * @throws InvalidArgumentException @@ -1484,7 +1516,8 @@ public function sendPhoto( $messageThreadId = null, $protectContent = null, $allowSendingWithoutReply = null, - $replyParameters = null + $replyParameters = null, + $businessConnectionId = null ) { if (null !== $replyToMessageId || null !== $allowSendingWithoutReply) { @trigger_error( @@ -1508,7 +1541,8 @@ public function sendPhoto( 'disable_notification' => (bool) $disableNotification, 'parse_mode' => $parseMode, 'protect_content' => (bool) $protectContent, - 'reply_parameters' => is_null($replyParameters) ? $replyParameters : $replyParameters->toJson() + 'reply_parameters' => is_null($replyParameters) ? $replyParameters : $replyParameters->toJson(), + 'business_connection_id' => $businessConnectionId ])); } @@ -1528,6 +1562,7 @@ public function sendPhoto( * @param bool|null $allowSendingWithoutReply * @param \CURLFile|\CURLStringFile|string|null $thumbnail * @param ReplyParameters|null $replyParameters Description of the message to reply to. + * @param string|null $businessConnectionId Unique identifier of the business connection on behalf of which the message will be sent * * @return Message * @throws InvalidArgumentException @@ -1545,7 +1580,8 @@ public function sendDocument( $protectContent = null, $allowSendingWithoutReply = null, $thumbnail = null, - $replyParameters = null + $replyParameters = null, + $businessConnectionId = null ) { if (null !== $replyToMessageId || null !== $allowSendingWithoutReply) { @trigger_error( @@ -1570,7 +1606,8 @@ public function sendDocument( 'parse_mode' => $parseMode, 'protect_content' => (bool) $protectContent, 'thumbnail' => $thumbnail, - 'reply_parameters' => is_null($replyParameters) ? $replyParameters : $replyParameters->toJson() + 'reply_parameters' => is_null($replyParameters) ? $replyParameters : $replyParameters->toJson(), + 'business_connection_id' => $businessConnectionId ])); } @@ -2580,6 +2617,7 @@ public function getChatAdministrators($chatId) * @param bool|null $allowSendingWithoutReply * @param \CURLFile|\CURLStringFile|string|null $thumbnail * @param ReplyParameters|null $replyParameters Description of the message to reply to. + * @param string|null $businessConnectionId Unique identifier of the business connection on behalf of which the message will be sent * * @return Message * @throws InvalidArgumentException @@ -2597,7 +2635,8 @@ public function sendVideoNote( $protectContent = null, $allowSendingWithoutReply = null, $thumbnail = null, - $replyParameters = null + $replyParameters = null, + $businessConnectionId = null ) { if (null !== $replyToMessageId || null !== $allowSendingWithoutReply) { @trigger_error( @@ -2622,7 +2661,8 @@ public function sendVideoNote( 'disable_notification' => (bool) $disableNotification, 'protect_content' => (bool) $protectContent, 'thumbnail' => $thumbnail, - 'reply_parameters' => is_null($replyParameters) ? $replyParameters : $replyParameters->toJson() + 'reply_parameters' => is_null($replyParameters) ? $replyParameters : $replyParameters->toJson(), + 'business_connection_id' => $businessConnectionId ])); } @@ -2639,6 +2679,7 @@ public function sendVideoNote( * @param bool|null $allowSendingWithoutReply * @param array $attachments Attachments to use in attach:// * @param ReplyParameters|null $replyParameters Description of the message to reply to. + * @param string|null $businessConnectionId Unique identifier of the business connection on behalf of which the message will be sent * * @return Message[] * @throws Exception @@ -2652,7 +2693,8 @@ public function sendMediaGroup( $protectContent = null, $allowSendingWithoutReply = null, $attachments = [], - $replyParameters = null + $replyParameters = null, + $businessConnectionId = null ) { if (null !== $replyToMessageId || null !== $allowSendingWithoutReply) { @trigger_error( @@ -2673,7 +2715,8 @@ public function sendMediaGroup( 'message_thread_id' => $messageThreadId, 'disable_notification' => (bool) $disableNotification, 'protect_content' => (bool) $protectContent, - 'reply_parameters' => is_null($replyParameters) ? $replyParameters : $replyParameters->toJson() + 'reply_parameters' => is_null($replyParameters) ? $replyParameters : $replyParameters->toJson(), + 'business_connection_id' => $businessConnectionId ] + $attachments)); } @@ -2700,6 +2743,7 @@ public function sendMediaGroup( * @param bool|null $protectContent * @param bool|null $allowSendingWithoutReply * @param ReplyParameters|null $replyParameters Description of the message to reply to. + * @param string|null $businessConnectionId Unique identifier of the business connection on behalf of which the message will be sent * * @return Message * @throws Exception @@ -2721,7 +2765,8 @@ public function sendPoll( $messageThreadId = null, $protectContent = null, $allowSendingWithoutReply = null, - $replyParameters = null + $replyParameters = null, + $businessConnectionId = null ) { if (null !== $replyToMessageId || null !== $allowSendingWithoutReply) { @trigger_error( @@ -2749,7 +2794,8 @@ public function sendPoll( 'message_thread_id' => $messageThreadId, 'reply_markup' => $replyMarkup === null ? $replyMarkup : $replyMarkup->toJson(), 'protect_content' => (bool) $protectContent, - 'reply_parameters' => is_null($replyParameters) ? $replyParameters : $replyParameters->toJson() + 'reply_parameters' => is_null($replyParameters) ? $replyParameters : $replyParameters->toJson(), + 'business_connection_id' => $businessConnectionId ])); } @@ -2773,6 +2819,7 @@ public function sendPoll( * @param int|null $messageThreadId * @param bool|null $protectContent * @param ReplyParameters|null $replyParameters Description of the message to reply to. + * @param string|null $businessConnectionId Unique identifier of the business connection on behalf of which the message will be sent * * @return Message * @throws Exception @@ -2788,7 +2835,8 @@ public function sendDice( $replyMarkup = null, $messageThreadId = null, $protectContent = null, - $replyParameters = null + $replyParameters = null, + $businessConnectionId = null ) { if (null !== $replyToMessageId || null !== $allowSendingWithoutReply) { @trigger_error( @@ -2810,7 +2858,8 @@ public function sendDice( 'message_thread_id' => $messageThreadId, 'reply_markup' => $replyMarkup === null ? $replyMarkup : $replyMarkup->toJson(), 'protect_content' => (bool) $protectContent, - 'reply_parameters' => is_null($replyParameters) ? $replyParameters : $replyParameters->toJson() + 'reply_parameters' => is_null($replyParameters) ? $replyParameters : $replyParameters->toJson(), + 'business_connection_id' => $businessConnectionId ])); } @@ -3181,6 +3230,52 @@ public function getUserChatBoosts($chatId, $userId) ])); } + /** + * Use this method to get information about the connection of the bot with a business account. + * Returns a BusinessConnection object on success. + * + * @param string $businessConnectionId Unique identifier for the business connection + * + * @return BusinessConnection + * @throws Exception + * + * @since Bot API 7.2 + * @author bernard-ng + */ + public function getBusinessConnection($businessConnectionId) + { + return BusinessConnection::fromResponse($this->call('getBusinessConnection', [ + 'business_connection_id' => $businessConnectionId + ])); + } + + /** + * Use this method to replace an existing sticker in a sticker set with a new one. + * The method is equivalent to calling deleteStickerFromSet, then addStickerToSet, then setStickerPositionInSet. + * Returns True on success. + * + * @param int $userId User identifier of the sticker set owner + * @param string $name Sticker set name + * @param string $oldSticker File identifier of the replaced sticker + * @param InputSticker $sticker A JSON-serialized object with information about the added sticker. + * If exactly the same sticker had already been added to the set, then the set remains unchanged. + * + * @return bool + * @throws Exception + * + * @since Bot API 7.2 + * @auther bernard-ng + */ + public function replaceStickerInSet($userId, $name, $oldSticker, $sticker) + { + return $this->call('replaceStickerInSet', [ + 'user_id' => $userId, + 'name' => $name, + 'old_sticker' => $oldSticker, + 'sticker' => $sticker + ]); + } + /** * Set an option for a cURL transfer * diff --git a/src/Types/InputSticker.php b/src/Types/InputSticker.php new file mode 100644 index 00000000..d46b3fcb --- /dev/null +++ b/src/Types/InputSticker.php @@ -0,0 +1,164 @@ + + */ +class InputSticker extends BaseType implements TypeInterface +{ + /** + * {@inheritdoc} + * + * @var array + */ + protected static $requiredParams = ['sticker', 'format', 'emoji_list']; + + /** + * {@inheritdoc} + * + * @var array + */ + protected static $map = [ + 'sticker' => true, + 'format' => true, + 'emoji_list' => true, + 'mask_position' => MaskPosition::class, + 'keywords' => true, + ]; + + /** + * The added sticker. + * Pass a file_id as a String to send a file that already exists on the Telegram servers, + * pass an HTTP URL as a String for Telegram to get a file from the Internet, + * upload a new one using multipart/form-data, or pass “attach://” to upload a new one using multipart/form-data under name. + * Animated and video stickers can't be uploaded via HTTP URL. + * + * @var string + * @see https://core.telegram.org/bots/api#sending-files + */ + protected string $sticker; + + /** + * Format of the added sticker, must be one of “static” + * for a .WEBP or .PNG image, “animated” for a .TGS animation, “video” for a WEBM video + * + * @var string + */ + protected string $format; + + /** + * List of 1-20 emoji associated with the sticker + * + * @var string[] + */ + protected array $emojiList; + + /** + * Optional. Position where the mask should be placed on faces. For “mask” stickers only. + * + * @var MaskPosition|null + */ + protected $maskPosition; + + /** + * Optional. List of 0-20 search keywords for the sticker with total length of up to 64 characters. + * For “regular” and “custom_emoji” stickers only. + * + * @var string[] + */ + protected $keywords; + + /** + * @return string + */ + public function getSticker() + { + return $this->sticker; + } + + /** + * @param string $sticker + * @return void + */ + public function setSticker(string $sticker) + { + $this->sticker = $sticker; + } + + /** + * @return string + */ + public function getFormat() + { + return $this->format; + } + + /** + * @param string $format + * @return void + */ + public function setFormat(string $format) + { + $this->format = $format; + } + + /** + * @return string[] + */ + public function getEmojiList() + { + return $this->emojiList; + } + + /** + * @param string[] $emojiList + * @return void + */ + public function setEmojiList(array $emojiList) + { + $this->emojiList = $emojiList; + } + + /** + * @return MaskPosition|null + */ + public function getMaskPosition() + { + return $this->maskPosition; + } + + /** + * @param MaskPosition|null $maskPosition + * @return void + */ + public function setMaskPosition($maskPosition) + { + $this->maskPosition = $maskPosition; + } + + /** + * @return string[] + */ + public function getKeywords() + { + return $this->keywords; + } + + /** + * @param string[] $keywords + * @return void + */ + public function setKeywords(array $keywords) + { + $this->keywords = $keywords; + } +} diff --git a/src/Types/Update.php b/src/Types/Update.php index 0294b71e..3e9044b0 100644 --- a/src/Types/Update.php +++ b/src/Types/Update.php @@ -50,6 +50,10 @@ class Update extends BaseType implements TypeInterface 'message_reaction_count' => MessageReactionCountUpdated::class, 'chat_boost' => ChatBoostUpdated::class, 'chat_boost_removed' => ChatBoostRemoved::class, + 'business_connection' => BusinessConnection::class, + 'business_message' => Message::class, + 'edited_business_message' => Message::class, + 'deleted_business_messages' => BusinessMessagesDeleted::class ]; /** @@ -198,6 +202,35 @@ class Update extends BaseType implements TypeInterface */ protected $chatBoostRemoved; + /** + * Optional. The bot was connected to or disconnected from a business account, + * or a user edited an existing connection with the bot + * + * @var BusinessConnection|null + */ + protected $businessConnection; + + /** + * Optional. New message from a connected business account + * + * @var Message|null + */ + protected $businessMessage; + + /** + * Optional. New version of a message from a connected business account + * + * @var Message|null + */ + protected $editedBusinessMessage; + + /** + * Optional. Messages were deleted from a connected business account + * + * @var BusinessMessagesDeleted|null + */ + protected $deletedBusinessMessages; + /** * @return int */ @@ -540,4 +573,72 @@ public function setChatBoostRemoved($chatBoostRemoved) { $this->chatBoostRemoved = $chatBoostRemoved; } + + /** + * @return BusinessConnection|null + */ + public function getBusinessConnection() + { + return $this->businessConnection; + } + + /** + * @param BusinessConnection|null $businessConnection + * @return void + */ + public function setBusinessConnection($businessConnection) + { + $this->businessConnection = $businessConnection; + } + + /** + * @return Message|null + */ + public function getBusinessMessage() + { + return $this->businessMessage; + } + + /** + * @param Message|null $businessMessage + * @return void + */ + public function setBusinessMessage($businessMessage) + { + $this->businessMessage = $businessMessage; + } + + /** + * @return Message|null + */ + public function getEditedBusinessMessage() + { + return $this->editedBusinessMessage; + } + + /** + * @param Message|null $editedBusinessMessage + * @return void + */ + public function setEditedBusinessMessage($editedBusinessMessage) + { + $this->editedBusinessMessage = $editedBusinessMessage; + } + + /** + * @return BusinessMessagesDeleted|null + */ + public function getDeletedBusinessMessages() + { + return $this->deletedBusinessMessages; + } + + /** + * @param BusinessMessagesDeleted|null $deletedBusinessMessages + * @return void + */ + public function setDeletedBusinessMessages($deletedBusinessMessages) + { + $this->deletedBusinessMessages = $deletedBusinessMessages; + } } diff --git a/tests/Types/BusinessConnectionTest.php b/tests/Types/BusinessConnectionTest.php new file mode 100644 index 00000000..9caa52a8 --- /dev/null +++ b/tests/Types/BusinessConnectionTest.php @@ -0,0 +1,58 @@ + 1, + 'user' => UserTest::getMinResponse(), + 'user_chat_id' => 1, + 'date' => 1682343643, + 'can_reply' => true, + 'is_enabled' => true + ]; + } + + public static function getFullResponse() + { + return [ + 'id' => 1, + 'user' => UserTest::getMinResponse(), + 'user_chat_id' => 1, + 'date' => 1682343643, + 'can_reply' => true, + 'is_enabled' => true + ]; + } + + protected function assertMinItem($item) + { + $this->assertEquals(1, $item->getId()); + $this->assertEquals(UserTest::createMinInstance(), $item->getUser()); + $this->assertEquals(1, $item->getUserChatId()); + $this->assertEquals(1682343643, $item->getDate()); + $this->assertTrue($item->getCanReply()); + $this->assertTrue($item->getIsEnabled()); + } + + protected function assertFullItem($item) + { + $this->assertEquals(1, $item->getId()); + $this->assertEquals(UserTest::createMinInstance(), $item->getUser()); + $this->assertEquals(1, $item->getUserChatId()); + $this->assertEquals(1682343643, $item->getDate()); + $this->assertTrue($item->getCanReply()); + $this->assertTrue($item->getIsEnabled()); + } +} diff --git a/tests/Types/BusinessMessagesDeletedTest.php b/tests/Types/BusinessMessagesDeletedTest.php new file mode 100644 index 00000000..e20a6149 --- /dev/null +++ b/tests/Types/BusinessMessagesDeletedTest.php @@ -0,0 +1,48 @@ + 'id', + 'chat' => ChatTest::getMinResponse(), + 'message_ids' => [1, 2, 3], + ]; + } + + public static function getFullResponse() + { + return [ + 'business_connection_id' => 'id', + 'chat' => ChatTest::getMinResponse(), + 'message_ids' => [1, 2, 3], + ]; + } + + protected function assertMinItem($item) + { + $this->assertEquals('id', $item->getBusinessConnectionId()); + $this->assertEquals(ChatTest::createMinInstance(), $item->getChat()); + $this->assertEquals([1, 2, 3], $item->getMessageIds()); + } + + protected function assertFullItem($item) + { + $this->assertEquals('id', $item->getBusinessConnectionId()); + $this->assertEquals(ChatTest::createMinInstance(), $item->getChat()); + $this->assertEquals([1, 2, 3], $item->getMessageIds()); + } +} diff --git a/tests/Types/InputStickerTest.php b/tests/Types/InputStickerTest.php new file mode 100644 index 00000000..2aea6d10 --- /dev/null +++ b/tests/Types/InputStickerTest.php @@ -0,0 +1,50 @@ + 'file', + 'format' => 'static', + 'emoji_list' => ['😀'] + ]; + } + + public static function getFullResponse() + { + return [ + 'sticker' => 'file', + 'format' => 'static', + 'emoji_list' => ['😀'], + 'mask_position' => MaskPositionTest::getMinResponse(), + 'keywords' => ['keywords'] + ]; + } + + protected function assertMinItem($item) + { + $this->assertEquals('file', $item->getSticker()); + $this->assertEquals('static', $item->getFormat()); + $this->assertEquals(['😀'], $item->getEmojiList()); + } + + protected function assertFullItem($item) + { + $this->assertEquals('file', $item->getSticker()); + $this->assertEquals('static', $item->getFormat()); + $this->assertEquals(['😀'], $item->getEmojiList()); + $this->assertEquals(MaskPositionTest::createMinInstance(), $item->getMaskPosition()); + $this->assertEquals(['keywords'], $item->getKeywords()); + } +} diff --git a/tests/Types/UpdateTest.php b/tests/Types/UpdateTest.php index fb730af2..66c0cec9 100644 --- a/tests/Types/UpdateTest.php +++ b/tests/Types/UpdateTest.php @@ -43,6 +43,10 @@ public static function getFullResponse() 'message_reaction_count' => MessageReactionCountUpdatedTest::getMinResponse(), 'chat_boost' => ChatBoostUpdatedTest::getMinResponse(), 'chat_boost_removed' => ChatBoostRemovedTest::getMinResponse(), + 'business_connection' => BusinessConnectionTest::getMinResponse(), + 'business_message' => MessageTest::getMinResponse(), + 'edited_business_message' => MessageTest::getMinResponse(), + 'deleted_business_messages' => BusinessMessagesDeletedTest::getMinResponse(), ]; } @@ -71,6 +75,10 @@ protected function assertMinItem($item) $this->assertNull($item->getMessageReactionCount()); $this->assertNull($item->getChatBoost()); $this->assertNull($item->getChatBoostRemoved()); + $this->assertNull($item->getBusinessConnection()); + $this->assertNull($item->getBusinessMessage()); + $this->assertNull($item->getEditedBusinessMessage()); + $this->assertNull($item->getDeletedBusinessMessages()); } /** @@ -96,5 +104,9 @@ protected function assertFullItem($item) $this->assertEquals(MessageReactionCountUpdatedTest::createMinInstance(), $item->getMessageReactionCount()); $this->assertEquals(ChatBoostUpdatedTest::createMinInstance(), $item->getChatBoost()); $this->assertEquals(ChatBoostRemovedTest::createMinInstance(), $item->getChatBoostRemoved()); + $this->assertEquals(BusinessConnectionTest::createMinInstance(), $item->getBusinessConnection()); + $this->assertEquals(MessageTest::createMinInstance(), $item->getBusinessMessage()); + $this->assertEquals(MessageTest::createMinInstance(), $item->getEditedBusinessMessage()); + $this->assertEquals(BusinessMessagesDeletedTest::createMinInstance(), $item->getDeletedBusinessMessages()); } }