From 2570955b4e816664f2ff003923e98a99842bcb9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AB=8F=E8=A8=AA=E5=AD=90?= Date: Fri, 1 May 2026 16:27:56 +0900 Subject: [PATCH] =?UTF-8?q?=E3=83=A9=E3=82=A4=E3=83=96=E3=83=A9=E3=83=AA?= =?UTF-8?q?=E5=81=B4=E3=81=8C=E5=AE=8C=E4=BA=86=EF=BC=8B=E3=82=AD=E3=83=A3?= =?UTF-8?q?=E3=83=83=E3=82=B7=E3=83=A5=E3=81=AF=E3=80=8Cvalidate=E3=80=8D?= =?UTF-8?q?=E2=86=92=E3=80=8Cresurrect=E3=80=8D=E3=81=AB=E5=90=8D=E5=A4=89?= =?UTF-8?q?=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Std/Lib/Cache.php | 2 +- src/Std/Lib/Openprovider.php | 856 +++++++++++++++++++++++++++++++++-- 2 files changed, 825 insertions(+), 33 deletions(-) diff --git a/src/Std/Lib/Cache.php b/src/Std/Lib/Cache.php index 3aa9dc4..ffe49b3 100644 --- a/src/Std/Lib/Cache.php +++ b/src/Std/Lib/Cache.php @@ -108,7 +108,7 @@ class Cache { * @param string $dataPoint デフォルト=query * @return bool */ - public function validate(array $cache, mixed $data = null, string $dataPoint = 'query'): bool { + public function resurrect(array $cache, mixed $data = null, string $dataPoint = 'query'): bool { if (NULL === $data) return (!empty($cache) && (isset($cache['lifespan']) && time() < ($cache['lifespan'] + $this->dataDuration))); else return (!empty($cache) && (isset($cache[$dataPoint]) diff --git a/src/Std/Lib/Openprovider.php b/src/Std/Lib/Openprovider.php index 367bb2d..c6b2f7c 100644 --- a/src/Std/Lib/Openprovider.php +++ b/src/Std/Lib/Openprovider.php @@ -154,7 +154,7 @@ class Openprovider { if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); $cacheName = 'listdomains'; $cache = $this->cache->get($cacheName); - if ($this->cache->validate($cache, $query)) return Result::Success('', $cache); + if ($this->cache->resurrect($cache, $query)) return Result::Success('', $cache); $curl = $this->setupCurl('/domains'); $res = $this->curlResult($curl); @@ -256,6 +256,245 @@ class Openprovider { return Result::Error('ドメインの確認に失敗。'); } + /** + * ドメイン名を勧められる。 + * @todo テスト + * + * @param array $payload フォームデータ + * @return Result 結果。 + */ + public function suggestDomainname(array $payload = []): Result { + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); + + $curl = $this->setupCurl('/domains/suggest-name', 'POST', $payload); + $res = $this->curlResult($curl); + if (isset($res->data['data']['results'])) { + return Result::Success('ドメインを勧められる事に成功。', $res->data['data']['results']); + } + + return Result::Error('ドメインを勧められる事に失敗。'); + } + + /** + * ドメイン名を交換する。 + * @todo テスト + * + * @param array $payload フォームデータ + * @return Result 結果。 + */ + public function tradeDomainname(array $payload = []): Result { + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); + + $curl = $this->setupCurl('/domains/trade', 'POST', $payload); + $res = $this->curlResult($curl); + if (isset($res->data['data']['results'])) { + $this->cache->murder('listdomains'); + return Result::Success('ドメインの交換に成功。', $res->data['data']['results']); + } + + return Result::Error('ドメインの交換に失敗。'); + } + + /** + * ドメイン名を移転する。 + * @todo テスト + * + * @param array $payload フォームデータ + * @return Result 結果。 + */ + public function transferDomainname(array $payload = []): Result { + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); + + $curl = $this->setupCurl('/domains/transfer', 'POST', $payload); + $res = $this->curlResult($curl); + if (isset($res->data['data']['results'])) { + $this->cache->murder('listdomains'); + return Result::Success('ドメインの移転に成功。', $res->data['data']['results']); + } + + return Result::Error('ドメインの移転に失敗。'); + } + + /** + * ドメイン名の受け取り + * @todo テスト + * + * @param int $id ドメインID + * @param array $payload フォームデータ + * @return Result 結果。 + */ + public function getDomainname(int $id, array $payload = []): Result { + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); + $cacheName = "getdomain-{$id}"; + $cache = $this->cache->get($cacheName); + if ($this->cache->resurrect($cache, $query)) return Result::Success('', $cache); + + $curl = $this->setupCurl("/domains/{$id}", 'POST', $payload); + $res = $this->curlResult($curl); + if (isset($res->data['data']['results'])) { + $this->cache->set($cacheName, $data->data); + return Result::Success('ドメインの受け取りに成功。', $res->data['data']['results']); + } + + return Result::Error('ドメインの受け取りに失敗。'); + } + + /** + * ドメイン名の更新 + * @todo テスト + * + * @param int $id ドメインID + * @param array $payload フォームデータ + * @return Result + */ + public function updateDomainname(int $id, array $payload = []): Result { + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); + + $uri = "/domains/{$id}"; + $curl = $this->setupCurl($uri, 'PUT', $payload); + $res = $this->curlResult($curl); + if (isset($res->data['data'])) { + $this->cache->murder('listdomains'); + $this->cache->murder("listdomain-{$id}"); + if ($res->data['data']['success']) return Result::Success('ドメイン名の更新に成功。', $res->data); + } + + return Result::Error('ドメイン名の更新に失敗。'); + } + + /** + * ドメイン名の削除 + * @todo テスト + * + * @param int $id ドメインID + * @param array $payload フォームデータ + * @return Result + */ + public function deleteDomainname(int $id, array $payload = []): Result { + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); + + $uri = "/domains/{$id}"; + $curl = $this->setupCurl($uri, 'DELETE', $payload); + $res = $this->curlResult($curl); + if (isset($res->data['data'])) { + $this->cache->murder('listdomains'); + $this->cache->murder("listdomain-{$id}"); + if ($res->data['data']['success']) return Result::Success('ドメイン名の削除に成功。', $res->data); + } + + return Result::Error('ドメイン名の削除に失敗。'); + } + + /** + * ドメイン名の最後行動の再度実行 + * @todo テスト + * + * @param int $id ドメインID + * @param array $payload フォームデータ + * @return Result 結果。 + */ + public function retryLastDomainnameOperation(int $id, array $payload = []): Result { + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); + + $curl = $this->setupCurl("/domains/{$id}/last-operation/restart", 'POST', $payload); + $res = $this->curlResult($curl); + if (isset($res->data['data']['results'])) { + $this->cache->murder('listdomains'); + $this->cache->murder("listdomain-{$id}"); + return Result::Success('ドメインの最後行動の再度実行に成功。', $res->data['data']['results']); + } + + return Result::Error('ドメインの最後行動の再度実行に失敗。'); + } + + /** + * ドメイン名の有効期限の更新 + * @todo テスト + * + * @param int $id ドメインID + * @param array $payload フォームデータ + * @return Result 結果。 + */ + public function renewDomainname(int $id, array $payload = []): Result { + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); + + $curl = $this->setupCurl("/domains/{$id}/renew", 'POST', $payload); + $res = $this->curlResult($curl); + if (isset($res->data['data']['results'])) { + $this->cache->murder('listdomains'); + $this->cache->murder("listdomain-{$id}"); + return Result::Success('ドメインの有効期限の更新に成功。', $res->data['data']['results']); + } + + return Result::Error('ドメインの有効期限の更新に失敗。'); + } + + /** + * 削除済みドメイン名の復活 + * @todo テスト + * + * @param int $id ドメインID + * @param array $payload フォームデータ + * @return Result 結果。 + */ + public function restoreDomainname(int $id, array $payload = []): Result { + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); + + $curl = $this->setupCurl("/domains/{$id}/restore", 'POST', $payload); + $res = $this->curlResult($curl); + if (isset($res->data['data']['results'])) { + $this->cache->murder('listdomains'); + $this->cache->murder("listdomain-{$id}"); + return Result::Success('削除済みドメイン名の復活に成功。', $res->data['data']['results']); + } + + return Result::Error('削除済みドメイン名の復活に失敗。'); + } + + /** + * ドメイン名の移動の承諾 + * @todo テスト + * + * @param int $id ドメインID + * @param array $payload フォームデータ + * @return Result 結果。 + */ + public function approveDomainnameTransfer(int $id, array $payload = []): Result { + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); + + $curl = $this->setupCurl("/domains/{$id}/transfer/approve", 'POST', $payload); + $res = $this->curlResult($curl); + if (isset($res->data['data']['results'])) { + $this->cache->murder('listdomains'); + $this->cache->murder("listdomain-{$id}"); + return Result::Success('ドメイン名の移動の承諾に成功。', $res->data['data']['results']); + } + + return Result::Error('ドメイン名の移動の承諾に失敗。'); + } + + /** + * ドメイン名のfoa1の送信 + * @todo テスト + * + * @param int $id ドメインID + * @param array $payload フォームデータ + * @return Result 結果。 + */ + public function sendDomainnameFoa1(int $id, array $payload = []): Result { + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); + + $curl = $this->setupCurl("/domains/{$id}/transfer/send-foa1", 'POST', $payload); + $res = $this->curlResult($curl); + if (isset($res->data['data']['results'])) { + $this->cache->murder('listdomains'); + $this->cache->murder("listdomain-{$id}"); + return Result::Success('ドメイン名のfoa1の送信に成功。', $res->data['data']['results']); + } + + return Result::Error('ドメイン名のfoa1の送信に失敗。'); + } + //// 追加データ /** @@ -274,7 +513,7 @@ class Openprovider { $cacheName = $name && $ext ? "domainadditionaldata-{$name}.{$ext}" : 'domainadditionaldata'; $cache = $this->cache->get($cacheName); - if ($this->cache->validate($cache)) return Result::Success('', $cache); + if ($this->cache->resurrect($cache)) return Result::Success('', $cache); $uri = "/domains/additional-data?".http_build_query($query, '', '&', PHP_QUERY_RFC3986); $curl = $this->setupCurl($uri); @@ -305,7 +544,7 @@ class Openprovider { $cacheName = $name && $ext ? "domainadditionaldata-{$name}.{$ext}" : 'domainadditionaldata'; $cache = $this->cache->get($cacheName); - if ($this->cache->validate($cache)) return Result::Success('', $cache); + if ($this->cache->resurrect($cache)) return Result::Success('', $cache); $uri = "/domains/additional-data/customers?".http_build_query($query, '', '&', PHP_QUERY_RFC3986); $curl = $this->setupCurl($uri); @@ -336,7 +575,7 @@ class Openprovider { $cacheName = $name && $ext ? "domainprices-{$name}.{$ext}" : 'domainprices'; $cache = $this->cache->get($cacheName); - if ($this->cache->validate($cache)) return Result::Success('', $cache); + if ($this->cache->resurrect($cache)) return Result::Success('', $cache); $uri = "/domains/prices?".http_build_query($query, '', '&', PHP_QUERY_RFC3986); $curl = $this->setupCurl($uri); @@ -406,7 +645,7 @@ class Openprovider { if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); $cacheName = 'listtlds'; $cache = $this->cache->get($cacheName); - if ($this->cache->validate($cache)) return Result::Success('', $cache); + if ($this->cache->resurrect($cache)) return Result::Success('', $cache); if (empty($query)) $query = [ 'limit' => 10, 'offset' => 0, 'order' => 'ASC' ]; foreach ($query as $k => $v) if (is_bool($v)) $query[$k] = $v ? 'true' : 'false'; @@ -433,7 +672,7 @@ class Openprovider { if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); $cacheName = "gettld-{$tld}"; $cache = $this->cache->get($cacheName); - if ($this->cache->validate($cache)) return Result::Success('', $cache); + if ($this->cache->resurrect($cache)) return Result::Success('', $cache); if (empty($query)) $query = [ 'limit' => 10, 'offset' => 0 ]; foreach ($query as $k => $v) if (is_bool($v)) $query[$k] = $v ? 'true' : 'false'; @@ -463,7 +702,7 @@ class Openprovider { if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); $cacheName = 'listinvoices'; $cache = $this->cache->get($cacheName); - if ($this->cache->validate($cache)) return Result::Success('', $cache); + if ($this->cache->resurrect($cache)) return Result::Success('', $cache); if (empty($query)) $query = [ 'limit' => 10, 'offset' => 0 ]; foreach ($query as $k => $v) if (is_bool($v)) $query[$k] = $v ? 'true' : 'false'; @@ -492,7 +731,7 @@ class Openprovider { if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); $cacheName = 'listpayments'; $cache = $this->cache->get($cacheName); - if ($this->cache->validate($cache)) return Result::Success('', $cache); + if ($this->cache->resurrect($cache)) return Result::Success('', $cache); if (empty($query)) $query = [ 'limit' => 10, 'offset' => 0 ]; foreach ($query as $k => $v) if (is_bool($v)) $query[$k] = $v ? 'true' : 'false'; @@ -521,7 +760,7 @@ class Openprovider { if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); $cacheName = 'listtransactions'; $cache = $this->cache->get($cacheName); - if ($this->cache->validate($cache)) return Result::Success('', $cache); + if ($this->cache->resurrect($cache)) return Result::Success('', $cache); if (empty($query)) $query = [ 'limit' => 10, 'offset' => 0 ]; foreach ($query as $k => $v) if (is_bool($v)) $query[$k] = $v ? 'true' : 'false'; @@ -573,7 +812,7 @@ class Openprovider { if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); $cacheName = 'listnameservers'; $cache = $this->cache->get($cacheName); - if ($this->cache->validate($cache, $query)) return Result::Success('', $cache); + if ($this->cache->resurrect($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'; @@ -622,7 +861,7 @@ class Openprovider { if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); $cacheName = "listnameserver-{$domain}"; $cache = $this->cache->get($cacheName); - if ($this->cache->validate($cache)) return Result::Success('', $cache); + if ($this->cache->resurrect($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'; @@ -696,7 +935,7 @@ class Openprovider { if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); $cacheName = 'listnsgroups'; $cache = $this->cache->get($cacheName); - if ($this->cache->validate($cache, $query)) return Result::Success('', $cache); + if ($this->cache->resurrect($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'; @@ -745,7 +984,7 @@ class Openprovider { if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); $cacheName = "listnsgroup-{$nsGroup}"; $cache = $this->cache->get($cacheName); - if ($this->cache->validate($cache)) return Result::Success('', $cache); + if ($this->cache->resurrect($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'; @@ -819,7 +1058,7 @@ class Openprovider { if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); $cacheName = 'listdnstemplates'; $cache = $this->cache->get($cacheName); - if ($this->cache->validate($cache, $query)) return Result::Success('', $cache); + if ($this->cache->resurrect($cache, $query)) return Result::Success('', $cache); foreach ($query as $k => $v) { if (is_bool($v)) $query[$k] = $v ? 'true' : 'false'; } $uri = '/dns/templates?'.http_build_query($query, '', '&', PHP_QUERY_RFC3986); @@ -866,7 +1105,7 @@ class Openprovider { if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); $cacheName = "getdnstemplate-{$id}"; $cache = $this->cache->get($cacheName); - if ($this->cache->validate($cache, $query)) return Result::Success('', $cache); + if ($this->cache->resurrect($cache, $query)) return Result::Success('', $cache); $uri = "/dns/templates/{$id}"; $curl = $this->setupCurl($uri); @@ -913,7 +1152,7 @@ class Openprovider { if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); $cacheName = 'listdnszones'; $cache = $this->cache->get($cacheName); - if ($this->cache->validate($cache, $query)) return Result::Success('', $cache); + if ($this->cache->resurrect($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'; @@ -961,7 +1200,7 @@ class Openprovider { if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); $cacheName = "getdnszone-{$domain}"; $cache = $this->cache->get($cacheName); - if ($this->cache->validate($cache)) return Result::Success('', $cache); + if ($this->cache->resurrect($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'; @@ -1034,7 +1273,7 @@ class Openprovider { if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); $cacheName = "getzonerecords-{$domain}"; $cache = $this->cache->get($cacheName); - if ($this->cache->validate($cache)) return Result::Success('', $cache); + if ($this->cache->resurrect($cache)) return Result::Success('', $cache); $curl = $this->setupCurl("/dns/zones/{$domain}/records"); $res = $this->curlResult($curl); @@ -1048,6 +1287,168 @@ class Openprovider { // Easydmarc + /** + * Easydmarc一覧 + * @todo テスト + * + * @param string $domain ドメイン名 + * @return Result + */ + public function getEasydmarc(string $domain): Result { + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); + $cacheName = "listeasydmarc-{$domain}"; + $cache = $this->cache->get($cacheName); + if ($this->cache->resurrect($cache)) return Result::Success('', $cache); + + $parts = explode('.', $domain, 2); + assert_exists($parts[0]); + assert_exists($parts[1]); + $query = [ 'name' => $parts[0], 'extension' => $parts[1] ]; + + $uri = "/dns/easydmarcs?".http_build_query($query, '', '&', PHP_QUERY_RFC3986); + $curl = $this->setupCurl($uri); + $res = $this->curlResult($curl); + if (isset($res->data['data'])) { + $this->cache->set($cacheName, $res->data); + return Result::Success('', $res->data); + } + + return Result::Error('Easydmarc一覧の受け取りに失敗。'); + } + + /** + * Easydmarcの作成 + * @todo テスト + * + * @param string $domain ドメイン名 + * @return Result + */ + public function createEasydmarc(string $domain): Result { + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); + + $parts = explode('.', $domain, 2); + assert_exists($parts[0]); + assert_exists($parts[1]); + $payload = [ 'name' => $parts[0], 'extension' => $parts[1] ]; + + $uri = '/dns/easydmarcs'; + $curl = $this->setupCurl($uri, 'POST', $payload); + $res = $this->curlResult($curl); + if (isset($res->data['data'])) { + $this->cache->murder('listeasydmarcs'); + return Result::Success('Easydmarcの追加に成功。', $res->data); + } + + return Result::Error('Easydmarcの追加に失敗。'); + } + + /** + * Easydmarc一覧 + * @todo テスト + * + * @param array $query + * @return Result + */ + public function listEasydmarcs(array $query = []): Result { + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); + $cacheName = 'listeasydmarcs'; + $cache = $this->cache->get($cacheName); + if ($this->cache->resurrect($cache, $query)) return Result::Success('', $cache); + + if (!empty($query) && isset($query['domain'])) { + $parts = explode('.', $query['domain'], 2); + assert_exists($parts[0]); + assert_exists($parts[1]); + $query['domain.name'] = $parts[0]; + $query['domain.extension'] = $parts[1]; + } + + if (empty($query)) $query = [ 'limit' => 100, 'offset' => 0, 'order_by.id' => 'asc' ]; + foreach ($query as $k => $v) if (is_bool($v)) $query[$k] = $v ? 'true' : 'false'; + + $uri = "/dns/easydmarcs/list?".http_build_query($query, '', '&', PHP_QUERY_RFC3986); + $curl = $this->setupCurl($uri); + $res = $this->curlResult($curl); + if (isset($res->data['data'])) { + $this->cache->set($cacheName, $res->data); + return Result::Success('', $res->data); + } + + return Result::Error('Easydmarc一覧の受け取りに失敗。'); + } + + /** + * Easydmarcの削除 + * @todo テスト + * + * @param int $orderId 注文ID + * @return Result + */ + public function deleteEasydmarc(int $orderId): Result { + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); + + $uri = "/dns/easydmarcs/{$domain}"; + $curl = $this->setupCurl($uri, 'DELETE'); + $res = $this->curlResult($curl); + if (isset($res->data['data'])) { + $this->cache->murder('listeasydmarcs'); + $this->cache->murder("listeasydmarc-{$domain}"); + $this->cache->murder("geteasydmarcssso-{$orderId}"); + if ($res->data['data']['success']) return Result::Success('Easydmarcの削除に成功。', $res->data); + } + + return Result::Error('Easydmarcの削除に失敗。'); + } + + /** + * Easydmarcを再度注文してみる + * @todo テスト + * + * @param int $orderId 注文ID + * @return Result + */ + public function retryEasydmarc(int $orderId): Result { + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); + + $uri = "/dns/easydmarcs/{$domain}/retry"; + $curl = $this->setupCurl($uri, 'POST'); + $res = $this->curlResult($curl); + if (isset($res->data['data'])) { + $this->cache->murder('listeasydmarcs'); + $this->cache->murder("listeasydmarc-{$domain}"); + $this->cache->murder("geteasydmarcssso-{$orderId}"); + if ($res->data['data']['success']) return Result::Success('Easydmarcを再度注文してみる事に成功。', $res->data); + } + + return Result::Error('Easydmarcを再度注文してみる事に失敗。'); + } + + /** + * Easydmarcの削除 + * @todo テスト + * + * @param int $orderId 注文ID + * @return Result + */ + public function getEasydmarcSso(int $orderId): Result { + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); + $cacheName = "geteasydmarcssso-{$orderId}"; + $cache = $this->cache->get($cacheName); + if ($this->cache->resurrect($cache, $query)) return Result::Success('', $cache); + + $uri = "/dns/easydmarcs/{$domain}/sso"; + $curl = $this->setupCurl($uri); + $res = $this->curlResult($curl); + if (isset($res->data['data'])) { + $this->cache->set($cacheName, $data->data); + $this->cache->murder('listeasydmarcs'); + $this->cache->murder("listeasydmarc-{$domain}"); + if ($res->data['data']['success']) return Result::Success('Easydmarcの削除に成功。', $res->data); + } + + return Result::Error('Easydmarcの削除に失敗。'); + } + // メールテンプレート //// メール @@ -1063,7 +1464,7 @@ class Openprovider { if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); $cacheName = 'listemails'; $cache = $this->cache->get($cacheName); - if ($this->cache->validate($cache, $query)) return Result::Success('', $cache); + if ($this->cache->resurrect($cache, $query)) return Result::Success('', $cache); foreach ($query as $k => $v) { if (is_bool($v)) $query[$k] = $v ? 'true' : 'false'; } $uri = '/emails?'.http_build_query($query, '', '&', PHP_QUERY_RFC3986); @@ -1144,12 +1545,235 @@ class Openprovider { // ライセンス + /** + * ライセンス一覧 + * @todo テスト + * + * @param array $query 検索クエリー + * @return Result + */ + public function listLicenses(array $query = []): Result { + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); + $cacheName = 'listlicenses'; + $cache = $this->cache->get($cacheName); + if ($this->cache->resurrect($cache, $query)) return Result::Success('', $cache); + + foreach ($query as $k => $v) { if (is_bool($v)) $query[$k] = $v ? 'true' : 'false'; } + $uri = '/licenses?'.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->cache->set($cacheName, $res->data); + return Result::Success('ライセンス一覧の受け取りに成功。', $res->data); + } + + return Result::Error('ライセンス一覧の受け取りに失敗。'); + } + + /** + * HWIDの再設定 + * @todo テスト + * + * @param string $product 商品種類(Pleskのみ) + * @param int $keyId ライセンスキーID + * @return Result + */ + public function resetLicenseHwid(string $product, int $keyId): Result { + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); + + $payload = ['key_id' => $keyId, 'product' => $product]; + $uri = "/licenses/hwids/reset/{$product}/{$keyId}"; + $curl = $this->setupCurl($uri, 'POST', $payload); + $res = $this->curlResult($curl); + if (isset($res)) { + $this->cache->murder('listlicenses'); + return Result::Success('HWIDの再設定に成功。', $res->data); + } + + return Result::Error("HWIDの再設定に失敗。"); + } + + /** + * 商品一覧 + * @todo テスト + * + * @param array $query 検索クエリー + * @return Result + */ + public function listLicenseItems(array $query = []): Result { + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); + $cacheName = 'listitems'; + $cache = $this->cache->get($cacheName); + if ($this->cache->resurrect($cache, $query)) return Result::Success('', $cache); + + foreach ($query as $k => $v) { if (is_bool($v)) $query[$k] = $v ? 'true' : 'false'; } + $uri = '/licenses/items?'.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->cache->set($cacheName, $res->data); + return Result::Success('商品一覧の受け取りに成功。', $res->data); + } + + return Result::Error('商品一覧の受け取りに失敗。'); + } + + /** + * Pleskライセンス一覧 + * @todo テスト + * + * @param array $query 検索クエリー + * @return Result + */ + public function listPleskLicenses(array $query = []): Result { + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); + $cacheName = 'listplesklicenses'; + $cache = $this->cache->get($cacheName); + if ($this->cache->resurrect($cache, $query)) return Result::Success('', $cache); + + foreach ($query as $k => $v) { if (is_bool($v)) $query[$k] = $v ? 'true' : 'false'; } + $uri = '/licenses/plesk?'.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->cache->set($cacheName, $res->data); + return Result::Success('Pleskライセンス一覧の受け取りに成功。', $res->data); + } + + return Result::Error('Pleskライセンス一覧の受け取りに失敗。'); + } + + /** + * Pleskライセンスの作成 + * @todo テスト + * + * @param array $payload フォームデータ + * @return Result + */ + public function createPleskLicense(array $payload): Result { + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); + + $uri = "/licenses/plesk"; + $curl = $this->setupCurl($uri, 'POST', $payload); + $res = $this->curlResult($curl); + if (isset($res)) { + $this->cache->murder('listlicenses'); + $this->cache->murder('listplesklicenses'); + return Result::Success('Pleskライセンスの作成に成功。', $res->data); + } + + return Result::Error("Pleskライセンスの作成に失敗。"); + } + + /** + * Plesk鍵の受け取り + * @todo テスト + * + * @param int $keyId 鍵ID + * @return Result + */ + public function getPleskKey(int $keyId): Result { + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); + $cacheName = "getpleskkey-{$keyId}"; + $cache = $this->cache->get($cacheName); + if ($this->cache->resurrect($cache)) return Result::Success('', $cache); + + $uri = "/licenses/plesk/key/{$keyId}"; + $curl = $this->setupCurl($uri); + $res = $this->curlResult($curl); + if (isset($res->data['data'])) { + $res->data['query'] = $query; + $this->cache->set($cacheName, $res->data); + return Result::Success('Plesk鍵の受け取りに成功。', $res->data); + } + + return Result::Error('Plesk鍵の受け取りに失敗。'); + } + + /** + * Pleskライセンスの受け取り + * @todo テスト + * + * @param int $keyId 鍵ID + * @return Result + */ + public function getPleskLicense(int $keyId): Result { + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); + $cacheName = "getplesklicense-{$keyId}"; + $cache = $this->cache->get($cacheName); + if ($this->cache->resurrect($cache)) return Result::Success('', $cache); + + $uri = "/licenses/plesk/{$keyId}"; + $curl = $this->setupCurl($uri); + $res = $this->curlResult($curl); + if (isset($res->data['data'])) { + $res->data['query'] = $query; + $this->cache->set($cacheName, $res->data); + return Result::Success('Pleskライセンスの受け取りに成功。', $res->data); + } + + return Result::Error('Pleskライセンスの受け取りに失敗。'); + } + + /** + * 連絡先の更新 + * @todo テスト + * + * @param int $keyId 鍵ID + * @param array $payload フォームデータ + * @return Result + */ + public function updatePleskLicense(int $keyId, array $payload = []): Result { + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); + + $uri = "/licenses/plesk/{$keyId}"; + $curl = $this->setupCurl($uri, 'PUT', $payload); + $res = $this->curlResult($curl); + if (isset($res->data['data'])) { + $this->cache->murder("getpleskkey-{$keyId}"); + $this->cache->murder("getplesklicense-{$keyId}"); + $this->cache->murder('listlicenses'); + $this->cache->murder('listplesklicenses'); + if ($res->data['data']['success']) return Result::Success('連絡先の更新に成功。', $res->data); + } + + return Result::Error('連絡先の更新に失敗。'); + } + + /** + * 連絡先の削除 + * @todo テスト + * + * @param int $keyId 鍵ID + * @return Result + */ + public function deletePleskLicense(int $keyId): Result { + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); + + $uri = "/licenses/plesk/{$keyId}"; + $curl = $this->setupCurl($uri, 'DELETE'); + $res = $this->curlResult($curl); + if (isset($res->data['data'])) { + $this->cache->murder("getpleskkey-{$keyId}"); + $this->cache->murder("getplesklicense-{$keyId}"); + $this->cache->murder('listlicenses'); + $this->cache->murder('listplesklicenses'); + if ($res->data['data']['success']) return Result::Success('連絡先の削除に成功。'); + } + + return Result::Error('連絡先の削除に失敗。'); + } + // リセラー・顧客様 //// 連絡先 /** * 連絡先の一覧 + * @todo テスト * * @param array $query 検索クエリー * @return Result @@ -1158,7 +1782,7 @@ class Openprovider { if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); $cacheName = 'listcontacts'; $cache = $this->cache->get($cacheName); - if ($this->cache->validate($cache, $query)) return Result::Success('', $cache); + if ($this->cache->resurrect($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); @@ -1175,6 +1799,7 @@ class Openprovider { /** * 連絡先の作成 + * @todo テスト * * @param array $payload * @return Result @@ -1195,6 +1820,7 @@ class Openprovider { /** * 連絡先の表示 + * @todo テスト * * @param int $id 連絡先ID * @param bool $withAdditionalData 詳細データ含むか? @@ -1204,7 +1830,7 @@ class Openprovider { if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); $cacheName = "getcontact-{$id}"; $cache = $this->cache->get($cacheName); - if ($this->cache->validate($cache, $id, 'id')) return Result::Success('', $cache); + if ($this->cache->resurrect($cache, $id, 'id')) return Result::Success('', $cache); $query = [ 'with_additional_data' => $withAdditionalData ? 'true' : 'false' ]; $uri = "/contacts/{$id}?".http_build_query($query, '', '&', PHP_QUERY_RFC3986); @@ -1245,6 +1871,7 @@ class Openprovider { /** * 連絡先の削除 + * @todo テスト * * @param int $id 連絡先ID * @return Result @@ -1276,7 +1903,7 @@ class Openprovider { if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); $cacheName = 'listcustomers'; $cache = $this->cache->get($cacheName); - if ($this->cache->validate($cache, $query)) return Result::Success('', $cache); + if ($this->cache->resurrect($cache, $query)) return Result::Success('', $cache); foreach ($query as $k => $v) { if (is_bool($v)) $query[$k] = $v ? 'true' : 'false'; } $uri = '/customers?'.http_build_query($query, '', '&', PHP_QUERY_RFC3986); @@ -1322,7 +1949,7 @@ class Openprovider { if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); $cacheName = "getcustomer-{$handle}"; $cache = $this->cache->get($cacheName); - if ($this->cache->validate($cache, $handle, 'handle')) return Result::Success('', $cache); + if ($this->cache->resurrect($cache, $handle, 'handle')) return Result::Success('', $cache); $query = [ 'with_additional_data' => $withAdditionalData ? 'true' : 'false' ]; $uri = "/customers/{$handle}?".http_build_query($query, '', '&', PHP_QUERY_RFC3986); @@ -1395,7 +2022,7 @@ class Openprovider { if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); $cacheName = 'listemailverifications'; $cache = $this->cache->get($cacheName); - if ($this->cache->validate($cache, $query)) return Result::Success('', $cache); + if ($this->cache->resurrect($cache, $query)) return Result::Success('', $cache); foreach ($query as $k => $v) { if (is_bool($v)) $query[$k] = $v ? 'true' : 'false'; } $uri = '/customers/verifications/emails/domains?'.http_build_query($query, '', '&', PHP_QUERY_RFC3986); @@ -1468,7 +2095,7 @@ class Openprovider { if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); $cacheName = 'getreseller'; $cache = $this->cache->get($cacheName); - if ($this->cache->validate($cache, $query)) return Result::Success('', $cache); + if ($this->cache->resurrect($cache, $query)) return Result::Success('', $cache); foreach ($query as $k => $v) { if (is_bool($v)) $query[$k] = $v ? 'true' : 'false'; } $uri = '/resellers?'.http_build_query($query, '', '&', PHP_QUERY_RFC3986); @@ -1517,7 +2144,7 @@ class Openprovider { if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); $cacheName = 'listsettings'; $cache = $this->cache->get($cacheName); - if ($this->cache->validate($cache, $query)) return Result::Success('', $cache); + if ($this->cache->resurrect($cache, $query)) return Result::Success('', $cache); $uri = '/resellers/settings'; $curl = $this->setupCurl($uri); @@ -1543,7 +2170,7 @@ class Openprovider { if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); $cacheName = 'liststatistics'; $cache = $this->cache->get($cacheName); - if ($this->cache->validate($cache, $query)) return Result::Success('', $cache); + if ($this->cache->resurrect($cache, $query)) return Result::Success('', $cache); $uri = '/resellers/statistics'; $curl = $this->setupCurl($uri); @@ -1570,7 +2197,7 @@ class Openprovider { if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); $cacheName = 'listtags'; $cache = $this->cache->get($cacheName); - if ($this->cache->validate($cache, $query)) return Result::Success('', $cache); + if ($this->cache->resurrect($cache, $query)) return Result::Success('', $cache); foreach ($query as $k => $v) { if (is_bool($v)) $query[$k] = $v ? 'true' : 'false'; } $uri = '/tags?'.http_build_query($query, '', '&', PHP_QUERY_RFC3986); @@ -1664,7 +2291,7 @@ class Openprovider { if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); $cacheName = "getsedomain-{$domain}"; $cache = $this->cache->get($cacheName); - if ($this->cache->validate($cache, $domain, 'domain')) return Result::Success('', $cache); + if ($this->cache->resurrect($cache, $domain, 'domain')) return Result::Success('', $cache); $uri = "/spam-expert/domains/{$domain}?".http_build_query($query, '', '&', PHP_QUERY_RFC3986); // kys($uri); @@ -1739,7 +2366,7 @@ class Openprovider { if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); $cacheName = 'listapproveremails'; $cache = $this->cache->get($cacheName); - if ($this->cache->validate($cache, $query)) return Result::Success('', $cache); + if ($this->cache->resurrect($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); @@ -1798,6 +2425,171 @@ class Openprovider { //// 注文 + /** + * 連絡先の一覧 + * @todo テスト + * + * @param array $query 検索クエリー + * @return Result + */ + public function listSslOrders(array $query = []): Result { + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); + $cacheName = 'listsslorders'; + $cache = $this->cache->get($cacheName); + if ($this->cache->resurrect($cache, $query)) return Result::Success('', $cache); + + foreach ($query as $k => $v) { if (is_bool($v)) $query[$k] = $v ? 'true' : 'false'; } + $uri = '/ssl/orders?'.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->cache->set($cacheName, $res->data); + return Result::Success('連絡先一覧の受け取りに成功。', $res->data); + } + + return Result::Error('連絡先一覧の受け取りに失敗。'); + } + + /** + * SSL注文の作成 + * @todo テスト + * + * @param array $payload + * @return Result + */ + public function createSslOrder(array $payload): Result { + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); + + $uri = '/ssl/orders'; + $curl = $this->setupCurl($uri, 'POST', $payload); + $res = $this->curlResult($curl); + if (isset($res)) { + $this->cache->murder('listsslorders'); + return Result::Success('SSL注文の作成に成功。', $res->data); + } + + return Result::Error("SSL注文の作成に失敗。"); + } + + /** + * SSL注文の表示 + * @todo テスト + * + * @param int $id SSL注文ID + * @return Result + */ + public function getSslOrder(int $id): Result { + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); + $cacheName = "getsslorder-{$id}"; + $cache = $this->cache->get($cacheName); + if ($this->cache->resurrect($cache)) return Result::Success('', $cache); + + $uri = "/ssl/orders/{$id}"; + // kys($uri); + $curl = $this->setupCurl($uri); + $res = $this->curlResult($curl); + if (isset($res->data['data'])) { + $res->data['id'] = $id; + $this->cache->set($cacheName, $res->data); + return Result::Success('SSL注文の受け取りに成功。', $res->data); + } + + return Result::Error('SSL注文の受け取りに失敗。'); + } + + /** + * SSL注文の更新 + * @todo テスト + * + * @param int $id SSL注文ID + * @param array $payload フォームデータ + * @return Result + */ + public function updateSslOrder(int $id, array $payload = []): Result { + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); + + $uri = "/ssl/orders/{$id}"; + $curl = $this->setupCurl($uri, 'PUT', $payload); + $res = $this->curlResult($curl); + if (isset($res->data['data'])) { + $this->cache->murder("getsslorder-{$id}"); + $this->cache->murder('listsslorders'); + if ($res->data['data']['success']) return Result::Success('SSL注文の更新に成功。', $res->data); + } + + return Result::Error('SSL注文の更新に失敗。'); + } + + /** + * SSL注文のキャンセル + * @todo テスト + * + * @param int $id SSL注文ID + * @return Result + */ + public function cancelSslOrder(int $id): Result { + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); + + $payload = ['id' => $id]; + $uri = "/ssl/orders/{$id}/cancel"; + $curl = $this->setupCurl($uri, 'POST', $payload); + $res = $this->curlResult($curl); + if (isset($res)) { + $this->cache->murder("getsslorder-{$id}"); + $this->cache->murder('listsslorders'); + return Result::Success('SSL注文のキャンセルに成功。', $res->data); + } + + return Result::Error("SSL注文のキャンセルに失敗。"); + } + + /** + * SSL注文の再発行 + * @todo テスト + * + * @param int $id SSL注文ID + * @param array $payload フォームデータ + * @return Result + */ + public function reissueSslOrder(int $id, array $payload = []): Result { + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); + + $uri = "/ssl/orders/{$id}/reissue"; + $curl = $this->setupCurl($uri, 'POST', $payload); + $res = $this->curlResult($curl); + if (isset($res)) { + $this->cache->murder("getsslorder-{$id}"); + $this->cache->murder('listsslorders'); + return Result::Success('SSL注文の再発行に成功。', $res->data); + } + + return Result::Error("SSL注文の再発行に失敗。"); + } + + /** + * SSL注文の更新 + * @todo テスト + * + * @param int $id SSL注文ID + * @param array $payload フォームデータ + * @return Result + */ + public function renewSslOrder(int $id, array $payload = []): Result { + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); + + $uri = "/ssl/orders/{$id}/renew"; + $curl = $this->setupCurl($uri, 'POST', $payload); + $res = $this->curlResult($curl); + if (isset($res)) { + $this->cache->murder("getsslorder-{$id}"); + $this->cache->murder('listsslorders'); + return Result::Success('SSL注文の更新に成功。', $res->data); + } + + return Result::Error("SSL注文の更新に失敗。"); + } + //// 注文確認担当者メール /** @@ -1878,7 +2670,7 @@ class Openprovider { if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); $cacheName = 'listsslproducts'; $cache = $this->cache->get($cacheName); - if ($this->cache->validate($cache, $query)) return Result::Success('', $cache); + if ($this->cache->resurrect($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); @@ -1904,7 +2696,7 @@ class Openprovider { if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。'); $cacheName = "getsslproduct-{$id}"; $cache = $this->cache->get($cacheName); - if ($this->cache->validate($cache, $id, 'id')) return Result::Success('', $cache); + if ($this->cache->resurrect($cache, $id, 'id')) return Result::Success('', $cache); // kys($uri); $curl = $this->setupCurl($uri); $res = $this->curlResult($curl);