Added ChatButton & ReplyButtons

This commit is contained in:
Alex
2025-08-02 09:24:11 +03:00
parent f5acd0ee88
commit 51b105b847
35 changed files with 625 additions and 92 deletions
+22 -2
View File
@@ -48,9 +48,10 @@ use RuntimeException;
*/
class Api
{
private const string API_BASE_URL = 'https://botapi.max.ru';
public const string API_VERSION = '0.0.6';
private const string API_BASE_URL = 'https://botapi.max.ru';
private const string METHOD_GET = 'GET';
private const string METHOD_POST = 'POST';
private const string METHOD_DELETE = 'DELETE';
@@ -88,7 +89,7 @@ class Api
public function __construct(
string $accessToken,
?ClientApiInterface $client = null,
?ModelFactory $modelFactory = null
?ModelFactory $modelFactory = null,
) {
if ($client === null) {
if (!class_exists(\GuzzleHttp\Client::class) || !class_exists(\GuzzleHttp\Psr7\HttpFactory::class)) {
@@ -114,6 +115,25 @@ class Api
$this->modelFactory = $modelFactory ?? new ModelFactory();
}
/**
* Performs a request to the Max Bot API.
*
* @param string $method The HTTP method (GET, POST, PATCH, etc.).
* @param string $uri The API endpoint (e.g., '/me', '/messages').
* @param array<string, mixed> $queryParams Query parameters for the request.
* @param array<string, mixed> $body The request body.
*
* @return array<string, mixed> The decoded JSON response as an associative array.
* @throws ClientApiException for API-level errors (4xx, 5xx).
* @throws NetworkException for network-related issues.
* @throws SerializationException for JSON encoding/decoding failures.
* @codeCoverageIgnore
*/
public function request(string $method, string $uri, array $queryParams = [], array $body = []): array
{
return $this->client->request($method, $uri, $queryParams, $body);
}
/**
* Creates a WebhookHandler instance, pre-configured with the necessary dependencies.
*