Spaces:
Runtime error
Runtime error
File size: 1,822 Bytes
46252cd | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | <?php
declare(strict_types=1);
namespace OpenWA\Resources;
use OpenWA\Http\HttpExecutor;
/**
* Chats resource — chat-list operations (read/unread/delete/typing state).
*
* These endpoints live under the session controller (/api/sessions/:id/chats/*)
* but are surfaced here as a dedicated resource for clarity.
*/
class ChatsResource
{
private HttpExecutor $http;
public function __construct(HttpExecutor $http)
{
$this->http = $http;
}
/**
* @param array<string,mixed> $query
* @return array<int,array<string,mixed>>
*/
public function list(string $sessionId, array $query = []): array
{
return $this->http->request('GET', "/api/sessions/{$this->http->encodeSegment($sessionId)}/chats", $query) ?? [];
}
/**
* @param array<string,mixed> $body
* @return array<string,mixed>
*/
public function markRead(string $sessionId, array $body): array
{
return $this->http->request('POST', "/api/sessions/{$this->http->encodeSegment($sessionId)}/chats/read", [], $body);
}
/** @return array<string,mixed> */
public function markUnread(string $sessionId, array $body): array
{
return $this->http->request('POST', "/api/sessions/{$this->http->encodeSegment($sessionId)}/chats/unread", [], $body);
}
/** @return array<string,mixed> */
public function delete(string $sessionId, array $body): array
{
return $this->http->request('POST', "/api/sessions/{$this->http->encodeSegment($sessionId)}/chats/delete", [], $body);
}
/** @return array<string,mixed> */
public function sendState(string $sessionId, array $body): array
{
return $this->http->request('POST', "/api/sessions/{$this->http->encodeSegment($sessionId)}/chats/typing", [], $body);
}
}
|