Files
ladill-woo-manager/app/Services/Meet/MeetClient.php
T
isaaccladandCursor ffe0b9d877
Deploy Ladill Woo Manager / deploy (push) Failing after 2s
Scaffold Ladill Woo Manager for WooCommerce order fulfillment.
Standalone app with SSO shell, WordPress plugin connect flow, webhook ingest,
fulfillment inbox, and plugin activation API — no payment processing.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-06 22:39:38 +00:00

67 lines
1.8 KiB
PHP

<?php
namespace App\Services\Meet;
use Illuminate\Http\Client\ConnectionException;
use Illuminate\Http\Client\PendingRequest;
use Illuminate\Support\Facades\Http;
use Illuminate\Validation\ValidationException;
class MeetClient
{
public function __construct(private readonly string $ownerRef) {}
public static function for(string $ownerRef): self
{
return new self($ownerRef);
}
/**
* @param array<string, mixed> $data
* @return array<string, mixed>
*/
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<string, mixed>
*/
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();
}
}