30 lines
851 B
PHP
30 lines
851 B
PHP
<?php
|
|
|
|
namespace App\Services\Plesk;
|
|
|
|
use App\Facades\BaseHelperFacade as BaseHelper;
|
|
use App\Models\DnsServer;
|
|
use Illuminate\Http\Client\PendingRequest;
|
|
use Illuminate\Support\Facades\Crypt;
|
|
use App\Support\TlsHttpClientFactory;
|
|
|
|
class PleskService
|
|
{
|
|
protected array $entryPoints = [
|
|
'clients' => ':8443/api/v2/clients',
|
|
'domains' => ':8443/api/v2/domains',
|
|
];
|
|
|
|
public function client(DnsServer $server, int $timeout = 30): PendingRequest
|
|
{
|
|
return TlsHttpClientFactory::plesk()
|
|
->withBasicAuth($server->username, Crypt::decryptString($server->password))
|
|
->timeout($timeout);
|
|
}
|
|
|
|
public function url(DnsServer $server, string $entryPoint, string $suffix = ''): string
|
|
{
|
|
return BaseHelper::url($server->ip_address) . $this->entryPoints[$entryPoint] . $suffix;
|
|
}
|
|
}
|