Deploy Ladill Hosting / deploy (push) Successful in 23s
Consolidate the inline HostingAccountMember lookups (Overview/Search/Hosting Product/Afia controllers) into HostingAccessResolver, which can source hosting developer-access from the monolith's central /identity/hosting/developer-access (correlating cPanel usernames to local account ids). Shadow mode by default (HOSTING_CENTRAL_DEV_ACCESS=false): local hosting_account_members stays authoritative and divergence from central is logged; flip the flag to cut over. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
75 lines
1.9 KiB
PHP
75 lines
1.9 KiB
PHP
<?php
|
|
|
|
namespace App\Services\Identity;
|
|
|
|
use Illuminate\Support\Facades\Http;
|
|
|
|
class IdentityClient
|
|
{
|
|
/** @return array<string, mixed> */
|
|
public function mailboxLinkStatus(string $publicId): array
|
|
{
|
|
$response = $this->request()->get($this->url('/identity/mailbox-link'), [
|
|
'user' => $publicId,
|
|
]);
|
|
|
|
$response->throw();
|
|
|
|
return (array) $response->json('data', []);
|
|
}
|
|
|
|
/** @return array<string, mixed> */
|
|
public function linkMailbox(string $publicId, string $mailboxAddress): array
|
|
{
|
|
$response = $this->request()->put($this->url('/identity/mailbox-link'), [
|
|
'user' => $publicId,
|
|
'mailbox_address' => $mailboxAddress,
|
|
]);
|
|
|
|
$response->throw();
|
|
|
|
return (array) $response->json('data', []);
|
|
}
|
|
|
|
/** @return array<string, mixed> */
|
|
public function unlinkMailbox(string $publicId): array
|
|
{
|
|
$response = $this->request()->delete($this->url('/identity/mailbox-link'), [
|
|
'user' => $publicId,
|
|
]);
|
|
|
|
$response->throw();
|
|
|
|
return (array) $response->json('data', []);
|
|
}
|
|
|
|
/**
|
|
* Hosting accounts (by cPanel username) the user can access as a developer,
|
|
* from the central monolith (source of truth for hosting developer access).
|
|
*
|
|
* @return list<array<string, mixed>>
|
|
*/
|
|
public function hostingDeveloperAccess(string $publicId): array
|
|
{
|
|
$response = $this->request()->get($this->url('/identity/hosting/developer-access'), [
|
|
'user' => $publicId,
|
|
]);
|
|
|
|
$response->throw();
|
|
|
|
return (array) $response->json('data', []);
|
|
}
|
|
|
|
private function request()
|
|
{
|
|
return Http::withToken((string) config('identity.api_key'))
|
|
->acceptJson()
|
|
->timeout(15);
|
|
}
|
|
|
|
private function url(string $path): string
|
|
{
|
|
return rtrim((string) config('identity.api_url'), '/').$path;
|
|
}
|
|
}
|