Scaffold Ladill Woo Manager for WooCommerce order fulfillment.
Deploy Ladill Woo Manager / deploy (push) Failing after 2s
Deploy Ladill Woo Manager / deploy (push) Failing after 2s
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>
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
<?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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user