Automation/app/Libraries/MySocket/Cloudflare/AccountSocket.php
2024-09-19 19:37:28 +09:00

31 lines
720 B
PHP

<?php
namespace App\Libraries\MySocket\Cloudflare;
use App\Entities\Cloudflare\AccountEntity;
use App\Libraries\CommonLibrary;
use App\Libraries\MySocket\CloudflareSocket;
use Cloudflare\API\Auth\APIKey;
class AccountSocket extends CloudflareSocket
{
public function __construct(string $email, string $api_key)
{
parent::__construct($email, $api_key);
}
final public function create(string $name, string $type = "standard")
{
$datas = [
'name' => $name . "'s Account",
'type' => $type,
];
$result = $this->getClient()->post("accounts", $datas);
$result = json_decode($result->getBody());
if (!$result->success) {
throw new \Exception(var_export($result, true));
}
return $result;
}
}