Files
ladill-meet/app/Services/Integrations/EventsClient.php
T
isaaccladandCursor 34d0a9c504
Deploy Ladill Meet / deploy (push) Successful in 1m26s
Route webinar and conference registration through Ladill Events.
Add Events linking UI and service client, remove Meet-native registration and invitation flows for these room types, and redirect attendees to Events registration when joining.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-02 07:38:50 +00:00

82 lines
2.2 KiB
PHP

<?php
namespace App\Services\Integrations;
use Illuminate\Http\Client\ConnectionException;
use Illuminate\Support\Facades\Http;
class EventsClient
{
private function client()
{
return Http::baseUrl(rtrim((string) config('meet.events_api_url'), '/'))
->withToken((string) config('meet.events_api_key'))
->acceptJson()
->asJson()
->connectTimeout(10)
->timeout(20);
}
public function isConfigured(): bool
{
return filled(config('meet.events_api_url')) && filled(config('meet.events_api_key'));
}
/**
* @return list<array<string, mixed>>
*/
public function linkableEvents(string $ownerRef): array
{
$response = $this->get('events', ['owner_ref' => $ownerRef]);
return (array) ($response['events'] ?? []);
}
/**
* @param array<string, mixed> $payload
* @return array<string, mixed>
*/
public function linkRoom(int $eventId, array $payload): array
{
$response = $this->post("events/{$eventId}/link-room", $payload);
return (array) ($response['event'] ?? []);
}
/**
* @return array<string, mixed>
*/
private function get(string $path, array $query = []): array
{
try {
$response = $this->client()->get($path, $query);
} catch (ConnectionException) {
throw new \RuntimeException('Could not reach Ladill Events.');
}
if ($response->failed()) {
throw new \RuntimeException('Events service error: '.($response->json('message') ?? $response->body()));
}
return (array) $response->json();
}
/**
* @return array<string, mixed>
*/
private function post(string $path, array $data): array
{
try {
$response = $this->client()->post($path, $data);
} catch (ConnectionException) {
throw new \RuntimeException('Could not reach Ladill Events.');
}
if ($response->failed()) {
throw new \RuntimeException('Events service error: '.($response->json('message') ?? $response->body()));
}
return (array) $response->json();
}
}