もっと追加した

This commit is contained in:
2026-04-30 19:28:07 +09:00
parent 1588201998
commit d3e04ace96

View File

@@ -69,7 +69,8 @@ class Openprovider {
*/
public function login(): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$cache = $this->getCache('login');
$cacheName = 'login';
$cache = $this->getCache($cacheName);
if (time() < ($this->lastAuth + $this->tokenDuration)) {
$this->token = $cache['data']['token'];
$this->lastAuth = $cache['last_auth'];
@@ -109,7 +110,7 @@ class Openprovider {
$this->token = $res['data']['token'];
$this->lastAuth = time();
$res['last_auth'] = $this->lastAuth;
$this->setCache('login', $res);
$this->setCache($cacheName, $res);
return Result::Success('', $res);
}
@@ -149,13 +150,14 @@ class Openprovider {
*/
public function listDomains(array $query = []): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$cache = $this->getCache('listdomains');
$cacheName = 'listdomains'
$cache = $this->getCache($cacheName);
if ($this->isValidLifespan($cache, $query)) return Result::Success('', $cache);
$curl = $this->setupCurl('/domains');
$res = $this->curlResult($curl);
if (isset($res['data']['results'])) {
$this->setCache('listdomains', $res->data);
$this->setCache($cacheName, $res->data);
return Result::Success('', $res['data']['results']);
}
@@ -400,7 +402,8 @@ class Openprovider {
*/
public function listTlds(array $query = []): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$cache = $this->getCache('listtlds');
$cacheName = 'listtlds';
$cache = $this->getCache($cacheName);
if ($this->isValidLifespan($cache)) return Result::Success('', $cache);
if (empty($query)) $query = [ 'limit' => 10, 'offset' => 0, 'order' => 'ASC' ];
@@ -410,7 +413,7 @@ class Openprovider {
$curl = $this->setupCurl($uri);
$res = $this->curlResult($curl);
if (isset($res->data['data'])) {
$this->setCache('listtlds', $res->data);
$this->setCache($cacheName, $res->data);
return Result::Success('', $res->data);
}
@@ -556,7 +559,251 @@ class Openprovider {
}
//// ネームサーバー
/**
* ネームサーバー一覧
* @todo テスト
*
* @param array $query
* @return Result
*/
public function listNameservers(array $query = []): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$cacheName = 'listnameservers';
$cache = $this->getCache($cacheName);
if ($this->isValidLifespan($cache, $query)) return Result::Success('', $cache);
if (empty($query)) $query = [ 'limit' => 25, 'offset' => 0, 'order_by.name' => 'asc' ];
foreach ($query as $k => $v) if (is_bool($v)) $query[$k] = $v ? 'true' : 'false';
$uri = "/dns/nameservers?".http_build_query($query, '', '&', PHP_QUERY_RFC3986);
$curl = $this->setupCurl($uri);
$res = $this->curlResult($curl);
if (isset($res->data['data'])) {
$this->setCache($cacheName, $res->data);
return Result::Success('', $res->data);
}
return Result::Error('ネームサーバー一覧の受け取りに失敗。');
}
/**
* ネームサーバーの作成
* @todo テスト
*
* @param array $payload フォームデータ
* @return Result
*/
public function createNameserver(array $payload = []): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$uri = '/dns/nameservers';
$curl = $this->setupCurl($uri, 'POST', $payload);
$res = $this->curlResult($curl);
if (isset($res->data['data'])) {
$this->murderCache('listnameservers');
return Result::Success('ネームサーバーの追加に成功。', $res->data);
}
return Result::Error('ネームサーバーの追加に失敗。');
}
/**
* ネームサーバー一覧
* @todo テスト
*
* @param string $domain ドメイン名
* @param array $query 検索クエリー
* @return Result
*/
public function getNameserver(string $domain, array $query = []): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$cacheName = "listnameserver-{$domain}";
$cache = $this->getCache($cacheName);
if ($this->isValidLifespan($cache)) return Result::Success('', $cache);
if (empty($query)) $query = [ 'limit' => 100, 'offset' => 0, 'order_by.name' => 'asc' ];
foreach ($query as $k => $v) if (is_bool($v)) $query[$k] = $v ? 'true' : 'false';
$uri = "/dns/nameservers/{$domain}?".http_build_query($query, '', '&', PHP_QUERY_RFC3986);
$curl = $this->setupCurl($uri);
$res = $this->curlResult($curl);
if (isset($res->data['data'])) {
$this->setCache($cacheName, $res->data);
return Result::Success('', $res->data);
}
return Result::Error('ネームサーバー一覧の受け取りに失敗。');
}
/**
* ネームサーバーの更新
* @todo テスト
*
* @param string $domain ドメイン名
* @param array $payload フォームデータ
* @return Result
*/
public function updateNameserver(string $domain, array $payload = []): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$uri = "/dns/nameservers/{$domain}";
$curl = $this->setupCurl($uri, 'PUT', $payload);
$res = $this->curlResult($curl);
if (isset($res->data['data'])) {
$this->murderCache('listnameservers');
$this->murderCache("listnameserver-{$domain}");
if ($res->data['data']['success']) return Result::Success('ネームサーバーの更新に成功。', $res->data);
}
return Result::Error('ネームサーバーの更新に失敗。');
}
/**
* ネームサーバーの削除
* @todo テスト
*
* @param string $domain ドメイン名
* @return Result
*/
public function deleteNameserver(string $domain): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$uri = "/dns/nameservers/{$domain}";
$curl = $this->setupCurl($uri, 'DELETE');
$res = $this->curlResult($curl);
if (isset($res->data['data'])) {
$this->murderCache('listnameservers');
$this->murderCache("listnameserver-{$domain}");
if ($res->data['data']['success']) return Result::Success('ネームサーバーの削除に成功。', $res->data);
}
return Result::Error('ネームサーバーの削除に失敗。');
}
//// NSグループ
/**
* NSグループ一覧
* @todo テスト
*
* @param array $query
* @return Result
*/
public function listNsGroups(array $query = []): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$cacheName = 'listnsgroups';
$cache = $this->getCache($cacheName);
if ($this->isValidLifespan($cache, $query)) return Result::Success('', $cache);
if (empty($query)) $query = [ 'limit' => 25, 'offset' => 0, 'order_by.name' => 'asc' ];
foreach ($query as $k => $v) if (is_bool($v)) $query[$k] = $v ? 'true' : 'false';
$uri = "/dns/nameservers/groups?".http_build_query($query, '', '&', PHP_QUERY_RFC3986);
$curl = $this->setupCurl($uri);
$res = $this->curlResult($curl);
if (isset($res->data['data'])) {
$this->setCache($cacheName, $res->data);
return Result::Success('', $res->data);
}
return Result::Error('NSグループ一覧の受け取りに失敗。');
}
/**
* NSグループの作成
* @todo テスト
*
* @param array $payload フォームデータ
* @return Result
*/
public function createNsGroup(array $payload = []): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$uri = '/dns/nameservers/groups';
$curl = $this->setupCurl($uri, 'POST', $payload);
$res = $this->curlResult($curl);
if (isset($res->data['data'])) {
$this->murderCache('listnsgroups');
return Result::Success('NSグループの追加に成功。', $res->data);
}
return Result::Error('NSグループの追加に失敗。');
}
/**
* NSグループ一覧
* @todo テスト
*
* @param string $nsGroup ネームサーバー名
* @param array $query 検索クエリー
* @return Result
*/
public function getNsGroup(string $nsGroup, array $query = []): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$cacheName = "listnsgroup-{$nsGroup}";
$cache = $this->getCache($cacheName);
if ($this->isValidLifespan($cache)) return Result::Success('', $cache);
if (empty($query)) $query = [ 'limit' => 100, 'offset' => 0, 'order_by.name' => 'asc' ];
foreach ($query as $k => $v) if (is_bool($v)) $query[$k] = $v ? 'true' : 'false';
$uri = "/dns/nameservers/groups/{$nsGroup}?".http_build_query($query, '', '&', PHP_QUERY_RFC3986);
$curl = $this->setupCurl($uri);
$res = $this->curlResult($curl);
if (isset($res->data['data'])) {
$this->setCache($cacheName, $res->data);
return Result::Success('', $res->data);
}
return Result::Error('NSグループ一覧の受け取りに失敗。');
}
/**
* NSグループの更新
* @todo テスト
*
* @param string $nsGroup ネームサーバー名
* @param array $payload フォームデータ
* @return Result
*/
public function updateNsGroup(string $nsGroup, array $payload = []): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$uri = "/dns/nameservers/groups/{$nsGroup}";
$curl = $this->setupCurl($uri, 'PUT', $payload);
$res = $this->curlResult($curl);
if (isset($res->data['data'])) {
$this->murderCache('listnsgroups');
$this->murderCache("listnsgroup-{$nsGroup}");
if ($res->data['data']['success']) return Result::Success('NSグループの更新に成功。', $res->data);
}
return Result::Error('NSグループの更新に失敗。');
}
/**
* NSグループの削除
* @todo テスト
*
* @param string $nsGroup ネームサーバー名
* @return Result
*/
public function deleteNsGroup(string $nsGroup): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$uri = "/dns/nameservers/groups/{$nsGroup}";
$curl = $this->setupCurl($uri, 'DELETE');
$res = $this->curlResult($curl);
if (isset($res->data['data'])) {
$this->murderCache('listnsgroups');
$this->murderCache("listnsgroup-{$nsGroup}");
if ($res->data['data']['success']) return Result::Success('NSグループの削除に成功。', $res->data);
}
return Result::Error('NSグループの削除に失敗。');
}
//// テンプレート
/**
@@ -645,13 +892,14 @@ class Openprovider {
$res = $this->curlResult($curl);
if (isset($res->data['data'])) {
$this->murderCache('listdnstemplates');
$this->murderCache("getdnstemplate-{$id}");
if ($res->data['data']['success']) return Result::Success('DNSテンプレートの削除に成功。', $res->data);
}
return Result::Error('DNSテンプレートの削除に失敗。');
}
//// ゾーン
//// DNSゾーン
/**
* DNSゾーン一覧
@@ -661,7 +909,8 @@ class Openprovider {
*/
public function listDnsZones(array $query = []): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$cache = $this->getCache('listdnszones');
$cacheName = 'listdnszones';
$cache = $this->getCache($cacheName);
if ($this->isValidLifespan($cache, $query)) return Result::Success('', $cache);
if (empty($query)) $query = [ 'limit' => 25, 'offset' => 0, 'order_by.name' => 'asc' ];
@@ -671,11 +920,32 @@ class Openprovider {
$curl = $this->setupCurl($uri);
$res = $this->curlResult($curl);
if (isset($res->data['data'])) {
$this->setCache('listdnszones', $res->data);
$this->setCache($cacheName, $res->data);
return Result::Success('', $res->data);
}
return Result::Error('TLD一覧の受け取りに失敗。');
return Result::Error('DNSゾーン一覧の受け取りに失敗。');
}
/**
* DNSゾーンの作成
* @todo テスト
*
* @param array $payload フォームデータ
* @return Result
*/
public function createDnsZone(array $payload = []): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$uri = '/dns/zones';
$curl = $this->setupCurl($uri, 'POST', $payload);
$res = $this->curlResult($curl);
if (isset($res->data['data'])) {
$this->murderCache('listdnszones');
return Result::Success('DNSゾーンの追加に成功。', $res->data);
}
return Result::Error('DNSゾーンの追加に失敗。');
}
/**
@@ -687,7 +957,8 @@ class Openprovider {
*/
public function getDnsZone(string $domain, array $query = []): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$cache = $this->getCache("getdnszone-{$domain}");
$cacheName = "getdnszone-{$domain}";
$cache = $this->getCache($cacheName);
if ($this->isValidLifespan($cache)) return Result::Success('', $cache);
if (empty($query)) $query = [ 'limit' => 100, 'offset' => 0, 'order_by.name' => 'asc' ];
@@ -697,11 +968,56 @@ class Openprovider {
$curl = $this->setupCurl($uri);
$res = $this->curlResult($curl);
if (isset($res->data['data'])) {
$this->setCache("getdnszone-{$domain}", $res->data);
$this->setCache($cacheName, $res->data);
return Result::Success('', $res->data);
}
return Result::Error('TLD一覧の受け取りに失敗。');
return Result::Error('DNSゾーン一覧の受け取りに失敗。');
}
/**
* DNSゾーンの更新
* @todo テスト
*
* @param string $domain ドメイン名
* @param array $payload フォームデータ
* @return Result
*/
public function updateDnsZone(string $domain, array $payload = []): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$uri = "/dns/zones/{$domain}";
$curl = $this->setupCurl($uri, 'PUT', $payload);
$res = $this->curlResult($curl);
if (isset($res->data['data'])) {
$this->murderCache('listdnszones');
$this->murderCache("getdnszone-{$domain}");
if ($res->data['data']['success']) return Result::Success('DNSゾーンの更新に成功。', $res->data);
}
return Result::Error('DNSゾーンの更新に失敗。');
}
/**
* DNSゾーンの削除
* @todo テスト
*
* @param string $domain ドメイン名
* @return Result
*/
public function deleteDnsZone(string $domain): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$uri = "/dns/zones/{$domain}";
$curl = $this->setupCurl($uri, 'DELETE');
$res = $this->curlResult($curl);
if (isset($res->data['data'])) {
$this->murderCache('listdnszones');
$this->murderCache("getdnszone-{$domain}");
if ($res->data['data']['success']) return Result::Success('DNSゾーンの削除に成功。', $res->data);
}
return Result::Error('DNSゾーンの削除に失敗。');
}
//// ゾーンレコード
@@ -714,13 +1030,14 @@ class Openprovider {
*/
public function listZoneRecords(string $domain): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$cache = $this->getCache("getzonerecords-{$domain}");
$cacheName = "getzonerecords-{$domain}";
$cache = $this->getCache($cacheName);
if ($this->isValidLifespan($cache)) return Result::Success('', $cache);
$curl = $this->setupCurl("/dns/zones/{$domain}/records");
$res = $this->curlResult($curl);
if (isset($res->data['data'])) {
$this->setCache("getzonerecords-{$domain}", $res->data);
$this->setCache($cacheName, $res->data);
return Result::Success('', $res->data);
}
@@ -829,6 +1146,122 @@ class Openprovider {
//// 連絡先
/**
* 連絡先の一覧
*
* @param array $query 検索クエリー
* @return Result
*/
public function listContacts(array $query = []): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$cacheName = 'listcontacts';
$cache = $this->getCache($cacheName);
if ($this->isValidLifespan($cache, $query)) return Result::Success('', $cache);
foreach ($query as $k => $v) { if (is_bool($v)) $query[$k] = $v ? 'true' : 'false'; }
$uri = '/contacts?'.http_build_query($query, '', '&', PHP_QUERY_RFC3986);
$curl = $this->setupCurl($uri);
$res = $this->curlResult($curl);
if (isset($res->data['data'])) {
$res->data['query'] = $query;
$this->setCache($cacheName, $res->data);
return Result::Success('', $res->data);
}
return Result::Error('連絡先一覧の受け取りに失敗。');
}
/**
* 連絡先の作成
*
* @param array $payload
* @return Result
*/
public function createContact(array $payload): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$uri = '/contacts';
$curl = $this->setupCurl($uri, 'POST', $payload);
$res = $this->curlResult($curl);
if (isset($res)) {
$this->murderCache('listcontacts');
return Result::Success('', $res->data);
}
return Result::Error("連絡先の作成に失敗。");
}
/**
* 連絡先の表示
*
* @param int $id 連絡先ID
* @param bool $withAdditionalData 詳細データ含むか?
* @return Result
*/
public function getContact(int $id, bool $withAdditionalData = false): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$cacheName = "getcontact-{$id}";
$cache = $this->getCache($cacheName);
if ($this->isValidLifespan($cache, $id, 'id')) return Result::Success('', $cache);
$query = [ 'with_additional_data' => $withAdditionalData ? 'true' : 'false' ];
$uri = "/contacts/{$id}?".http_build_query($query, '', '&', PHP_QUERY_RFC3986);
// kys($uri);
$curl = $this->setupCurl($uri);
$res = $this->curlResult($curl);
if (isset($res->data['data'])) {
$res->data['id'] = $id;
$this->setCache($cacheName, $res->data);
return Result::Success('', $res->data);
}
return Result::Error('連絡先の受け取りに失敗。');
}
/**
* 連絡先の更新
* @todo テスト
*
* @param int $id 連絡先ID
* @param array $payload フォームデータ
* @return Result
*/
public function updateContact(int $id, array $payload = []): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$uri = "/contacts/{$id}";
$curl = $this->setupCurl($uri, 'PUT', $payload);
$res = $this->curlResult($curl);
if (isset($res->data['data'])) {
$this->murderCache("getcontact-{$id}");
$this->murderCache('listcontacts');
if ($res->data['data']['success']) return Result::Success('連絡先の更新に成功。', $res->data);
}
return Result::Error('連絡先の更新に失敗。');
}
/**
* 連絡先の削除
*
* @param int $id 連絡先ID
* @return Result
*/
public function deleteContact(int $id): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$uri = "/contacts/{$id}";
$curl = $this->setupCurl($uri, 'DELETE');
$res = $this->curlResult($curl);
if (isset($res->data['data'])) {
$this->murderCache("getcontact-{$id}");
$this->murderCache('listcontacts');
if ($res->data['data']['success']) return Result::Success('連絡先の削除に成功。');
}
return Result::Error('連絡先の削除に失敗。');
}
//// 顧客様
/**
@@ -1192,8 +1625,294 @@ class Openprovider {
// SpamExpert
//// SEDomain
/**
* SEDomainの作成
* @todo テスト
*
* @param array $payload
* @return Result
*/
public function createSeDomain(array $payload): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$uri = '/spam-expert/domains';
$curl = $this->setupCurl($uri, 'POST', $payload);
$res = $this->curlResult($curl);
if (isset($res)) {
$this->murderCache('listdomains');
return Result::Success('', $res->data);
}
return Result::Error("SEDomainの作成に失敗。");
}
/**
* SEDomainの表示
* @todo テスト
*
* @param string $domain ドメイン名
* @param array $query 検索クエリー
* @return Result
*/
public function getSeDomain(string $domain, array $query = []): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$cacheName = "getsedomain-{$domain}";
$cache = $this->getCache($cacheName);
if ($this->isValidLifespan($cache, $domain, 'domain')) return Result::Success('', $cache);
$uri = "/spam-expert/domains/{$domain}?".http_build_query($query, '', '&', PHP_QUERY_RFC3986);
// kys($uri);
$curl = $this->setupCurl($uri);
$res = $this->curlResult($curl);
if (isset($res->data['data'])) {
$res->data['domain'] = $domain;
$this->setCache($cacheName, $res->data);
return Result::Success('', $res->data);
}
return Result::Error('SEDomainの受け取りに失敗。');
}
/**
* SEDomainの更新
* @todo テスト
*
* @param string $domain ドメイン名
* @param array $payload フォームデータ
* @return Result
*/
public function updateSeDomain(string $domain, array $payload = []): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$uri = "/spam-expert/domains/{$domain}";
$curl = $this->setupCurl($uri, 'PUT', $payload);
$res = $this->curlResult($curl);
if (isset($res->data['data'])) {
$this->murderCache('listdomains');
$this->murderCache("getsedomain-{$domain}");
if ($res->data['data']['success']) return Result::Success('SEDomainの更新に成功。', $res->data);
}
return Result::Error('SEDomainの更新に失敗。');
}
/**
* SEDomainの削除
* @todo テスト
*
* @param string $domain ドメイン名
* @return Result
*/
public function deleteSeDomain(string $domain): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$uri = "/spam-expert/domains/{$domain}";
$curl = $this->setupCurl($uri, 'DELETE');
$res = $this->curlResult($curl);
if (isset($res->data['data'])) {
$this->murderCache('listdomains');
$this->murderCache("getsedomain-{$domain}");
if ($res->data['data']['success']) return Result::Success('SEDomainの削除に成功。');
}
return Result::Error('SEDomainの削除に失敗。');
}
// SSL証明書
//// 確認担当者メール
/**
* 確認担当者メール一覧
* @todo テスト
*
* @param array $query 検索クエリー
* @return Result
*/
public function listApproverEmails(array $query = []): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$cacheName = 'listapproveremails';
$cache = $this->getCache($cacheName);
if ($this->isValidLifespan($cache, $query)) return Result::Success('', $cache);
foreach ($query as $k => $v) { if (is_bool($v)) $query[$k] = $v ? 'true' : 'false'; }
$uri = '/ssl/approver-emails?'.http_build_query($query, '', '&', PHP_QUERY_RFC3986);
$curl = $this->setupCurl($uri);
$res = $this->curlResult($curl);
if (isset($res->data['data'])) {
$res->data['query'] = $query;
$this->setCache($cacheName, $res->data);
return Result::Success('', $res->data);
}
return Result::Error('確認担当者メール一覧の受け取りに失敗。');
}
//// CSR
/**
* 注文確認担当者メールの再送信
* @todo テスト
*
* @param array $payload
* @return Result
*/
public function createCsr(array $payload): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$uri = '/ssl/csr';
$curl = $this->setupCurl($uri, 'POST', $payload);
$res = $this->curlResult($curl);
if (isset($res)) {
return Result::Success('', $res->data);
}
return Result::Error("注文確認担当者メールの再送信に失敗。");
}
/**
* 注文確認担当者メールの再送信
* @todo テスト
*
* @param string $csr
* @return Result
*/
public function decodeCsr(string $csr): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$uri = '/ssl/csr/decode';
$curl = $this->setupCurl($uri, 'POST', ['csr' => $csr]);
$res = $this->curlResult($curl);
if (isset($res)) {
return Result::Success('', $res->data);
}
return Result::Error("注文確認担当者メールの再送信に失敗。");
}
//// 注文
//// 注文確認担当者メール
/**
* 注文確認担当者メールの更新
* @todo テスト
*
* @param int $id
* @param string $approverEmail
* @return Result
*/
public function updateSslApproverEmail(int $id, string $approverEmail): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$uri = "/ssl/orders/{$id}/approver-email";
$curl = $this->setupCurl($uri, 'PUT', ['id' => $id, 'approver_email' => $approverEmail]);
$res = $this->curlResult($curl);
if (isset($res)) {
$this->murderCache('listapproveremails');
return Result::Success('', $res->data);
}
return Result::Error("注文確認担当者メールの更新に失敗。");
}
/**
* 注文確認担当者メールの再送信
* @todo テスト
*
* @param int $id
* @return Result
*/
public function resendSslApproverEmail(int $id): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$uri = "/ssl/orders/{$id}/approver-email/resend";
$curl = $this->setupCurl($uri, 'POST', ['id' => $id]);
$res = $this->curlResult($curl);
if (isset($res)) {
$this->murderCache('listapproveremails');
return Result::Success('', $res->data);
}
return Result::Error("注文確認担当者メールの再送信に失敗。");
}
//// OTPトークン
/**
* OTPトークンの作成
* @todo テスト
*
* @param int $id
* @return Result
*/
public function createSslOtpToken(int $id): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$uri = "/ssl/orders/{$id}/otp-tokens";
$curl = $this->setupCurl($uri, 'POST');
$res = $this->curlResult($curl);
if (isset($res)) {
return Result::Success('', $res->data);
}
return Result::Error("OTPトークンの作成に失敗。");
}
//// 商品
/**
* 商品一覧
* @todo テスト
*
* @param array $query 検索クエリー
* @return Result
*/
public function listSslProducts(array $query = []): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$cacheName = 'listsslproducts';
$cache = $this->getCache($cacheName);
if ($this->isValidLifespan($cache, $query)) return Result::Success('', $cache);
foreach ($query as $k => $v) { if (is_bool($v)) $query[$k] = $v ? 'true' : 'false'; }
$uri = '/ssl/products?'.http_build_query($query, '', '&', PHP_QUERY_RFC3986);
$curl = $this->setupCurl($uri);
$res = $this->curlResult($curl);
if (isset($res->data['data'])) {
$res->data['query'] = $query;
$this->setCache($cacheName, $res->data);
return Result::Success('', $res->data);
}
return Result::Error('商品一覧の受け取りに失敗。');
}
/**
* 商品の表示
* @todo テスト
*
* @param int $id 商品ID
* @return Result
*/
public function getSslProduct(int $id): Result {
if (!OPENPROVIDER_ENABLED) return Result::error('エラーOpenProviderは無効です。');
$cacheName = "getsslproduct-{$id}";
$cache = $this->getCache($cacheName);
if ($this->isValidLifespan($cache, $id, 'id')) return Result::Success('', $cache);
// kys($uri);
$curl = $this->setupCurl($uri);
$res = $this->curlResult($curl);
if (isset($res->data['data'])) {
$res->data['id'] = $id;
$this->setCache($cacheName, $res->data);
return Result::Success('', $res->data);
}
return Result::Error('商品の受け取りに失敗。');
}
////////
/**