52 lines
1.7 KiB
PHP
52 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Libraries\MyCloudflare;
|
|
|
|
use App\Models\Cloudflare\AccountModel;
|
|
use App\Libraries\MyCloudflare\MyCloudflare;
|
|
use App\Entities\Cloudflare\AccountEntity;
|
|
|
|
class Account extends MyCloudflare
|
|
{
|
|
public function __construct($mySocket, $myStorage)
|
|
{
|
|
parent::__construct($mySocket, $myStorage);
|
|
}
|
|
final protected function getMyStorage(): AccountModel
|
|
{
|
|
if ($this->_myStorage === null) {
|
|
throw new \Exception("MyStorage가 정의되지 않았습니다.");
|
|
}
|
|
return $this->_myStorage;
|
|
}
|
|
//Result 형태
|
|
// [
|
|
// {"id":"078e88a7735965b661715af13031ecb0",
|
|
// "name":"Cloudwin002@idcjp.jp's Auth",
|
|
// "type":"standard",
|
|
// "settings":{
|
|
// "enforce_twofactor":false,
|
|
// "api_access_enabled":null,
|
|
// "access_approval_expiry":null,
|
|
// "use_account_custom_ns_by_default":false
|
|
// },
|
|
// "legacy_flags":{"enterprise_zone_quota":{"maximum":0,"current":0,"available":0}},
|
|
// "created_on":"2017-06-26T05:44:49.470184Z"}
|
|
// ]
|
|
public function create(array $formDatas): AccountEntity
|
|
{
|
|
//Socket용
|
|
$cf = $this->getMySocket()->getAccount($formDatas['apikey'])->addAccount($formDatas['id']);
|
|
//Storage용
|
|
$formDatas[$this->getMyStorage()->PK()] = $cf->id;
|
|
$formDatas[$this->getMyStorage()->getTitleField()] = $cf->name;
|
|
$formDatas['type'] = $cf->type;
|
|
$formDatas['status'] = 'use';
|
|
$formDatas['updated_at'] = $cf->created_on;
|
|
$formDatas['created_at'] = $cf->created_on;
|
|
$entity = $this->getMyStorage()->create($formDatas);
|
|
log_message("notice", "Account::" . __FUNCTION__ . "=> 작업을 완료하였습니다.");
|
|
return $entity;
|
|
}
|
|
}
|