$data * @return array */ public function createRoom(array $data): array { return $this->post('rooms', array_merge($data, [ 'owner_ref' => $this->ownerRef, 'host_user_ref' => $data['host_user_ref'] ?? $this->ownerRef, ])); } private function client(): PendingRequest { return Http::baseUrl((string) config('meet.url')) ->withToken((string) config('meet.key')) ->acceptJson() ->asJson() ->connectTimeout(10) ->timeout(20); } /** * @return array */ private function post(string $path, array $data): array { try { $response = $this->client()->post($path, $data); } catch (ConnectionException) { throw ValidationException::withMessages([ 'meet' => ['Could not reach the Meet service. Please try again in a moment.'], ]); } if ($response->status() === 422) { throw ValidationException::withMessages( $response->json('errors') ?: ['meet' => [$response->json('message') ?: 'Request failed.']] ); } if ($response->failed()) { abort($response->status() === 404 ? 404 : 502, 'Meet service error.'); } return (array) $response->json(); } }