Added Chat

This commit is contained in:
Alex
2025-07-20 14:17:19 +03:00
parent 4661edffdf
commit 07c6bb35b4
7 changed files with 192 additions and 3 deletions
+23 -3
View File
@@ -14,6 +14,7 @@ use BushlanovDev\MaxMessengerBot\Models\AbstractModel;
use BushlanovDev\MaxMessengerBot\Models\Attachments\Requests\AbstractAttachmentRequest;
use BushlanovDev\MaxMessengerBot\Models\Attachments\Requests\PhotoAttachmentRequest;
use BushlanovDev\MaxMessengerBot\Models\BotInfo;
use BushlanovDev\MaxMessengerBot\Models\Chat;
use BushlanovDev\MaxMessengerBot\Models\Message;
use BushlanovDev\MaxMessengerBot\Models\MessageLink;
use BushlanovDev\MaxMessengerBot\Models\Result;
@@ -43,6 +44,7 @@ class Api
private const string ACTION_SUBSCRIPTIONS = '/subscriptions';
private const string ACTION_MESSAGES = '/messages';
private const string ACTION_UPLOADS = '/uploads';
private const string ACTION_CHATS = '/chats';
private readonly ClientApiInterface $client;
@@ -237,13 +239,13 @@ class Api
* @param string $filePath Path to the file on the local disk.
*
* @return AbstractAttachmentRequest
* @throws ReflectionException
* @throws SerializationException
* @throws InvalidArgumentException
* @throws RuntimeException
* @throws LogicException
* @throws NetworkException
* @throws ClientApiException
* @throws NetworkException
* @throws SerializationException
* @throws ReflectionException
*/
public function uploadAttachment(UploadType $type, string $filePath): AbstractAttachmentRequest
{
@@ -277,4 +279,22 @@ class Api
),
};
}
/**
* Returns info about chat.
*
* @param int $chatId Requested chat identifier.
*
* @return Chat
* @throws ClientApiException
* @throws NetworkException
* @throws SerializationException
* @throws ReflectionException
*/
public function getChat(int $chatId): Chat
{
return $this->modelFactory->createChat(
$this->client->request(self::METHOD_GET, self::ACTION_CHATS . '/' . $chatId)
);
}
}