Spaces:
Runtime error
Runtime error
File size: 1,996 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 61 62 63 64 | <?php
declare(strict_types=1);
namespace OpenWA\Resources;
use OpenWA\Http\HttpExecutor;
/**
* Webhooks resource — configure event delivery to external HTTP endpoints.
*
* Backed by src/modules/webhook/webhook.controller.ts.
*/
class WebhooksResource
{
private HttpExecutor $http;
public function __construct(HttpExecutor $http)
{
$this->http = $http;
}
/** @return array<int,array<string,mixed>> */
public function list(string $sessionId): array
{
return $this->http->request('GET', "/api/sessions/{$this->http->encodeSegment($sessionId)}/webhooks") ?? [];
}
/** @return array<string,mixed> */
public function get(string $sessionId, string $id): array
{
return $this->http->request('GET', "/api/sessions/{$this->http->encodeSegment($sessionId)}/webhooks/{$this->http->encodeSegment($id)}");
}
/**
* @param array<string,mixed> $body
* @return array<string,mixed>
*/
public function create(string $sessionId, array $body): array
{
return $this->http->request('POST', "/api/sessions/{$this->http->encodeSegment($sessionId)}/webhooks", [], $body);
}
/**
* @param array<string,mixed> $body
* @return array<string,mixed>
*/
public function update(string $sessionId, string $id, array $body): array
{
return $this->http->request('PUT', "/api/sessions/{$this->http->encodeSegment($sessionId)}/webhooks/{$this->http->encodeSegment($id)}", [], $body);
}
public function delete(string $sessionId, string $id): void
{
$this->http->request('DELETE', "/api/sessions/{$this->http->encodeSegment($sessionId)}/webhooks/{$this->http->encodeSegment($id)}");
}
/** @return array<string,mixed> */
public function test(string $sessionId, string $id): array
{
return $this->http->request('POST', "/api/sessions/{$this->http->encodeSegment($sessionId)}/webhooks/{$this->http->encodeSegment($id)}/test");
}
}
|