From d4176e6553e5d3436270c0616031552f1c511ee1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E8=AB=8F=E8=A8=AA=E5=AD=90?=
Date: Tue, 28 Apr 2026 14:39:26 +0900
Subject: [PATCH] =?UTF-8?q?=E6=B2=A2=E5=B1=B1API=E3=81=AE=E8=BF=BD?=
=?UTF-8?q?=E5=8A=A0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
route.php | 1 +
src/Site/Controller/Op.php | 75 +++
src/Std/Lib/Openprovider.php | 814 +++++++++++++++++++++++--
view/openprovider/createcustomer.maron | 109 ++++
view/openprovider/listcustomers.maron | 2 +-
5 files changed, 954 insertions(+), 47 deletions(-)
create mode 100644 view/openprovider/createcustomer.maron
diff --git a/route.php b/route.php
index f51cf21..10b3805 100644
--- a/route.php
+++ b/route.php
@@ -61,6 +61,7 @@ if (ATOM_ENABLED) {
if (OPENPROVIDER_ENABLED) {
$routes[] = Route::add('GET', 'openprovider', Op::class.'@index');
$routes[] = Route::add('GET', 'openprovider/listcustomers', Op::class.'@opListCustomers');
+ $routes[] = Route::add('GET', 'openprovider/createcustomer', Op::class.'@opCreateCustomers');
$routes[] = Route::add('GET', 'openprovider/getcustomer/{handle}', Op::class.'@opGetCustomer');
$routes[] = Route::add('GET', 'openprovider/listtlds', Op::class.'@opListTlds');
$routes[] = Route::add('GET', 'openprovider/gettld/{tld}', Op::class.'@opGetTld');
diff --git a/src/Site/Controller/Op.php b/src/Site/Controller/Op.php
index 5f7bee2..d23e245 100644
--- a/src/Site/Controller/Op.php
+++ b/src/Site/Controller/Op.php
@@ -73,6 +73,81 @@ class Op {
}
}
+ public function opCreateCustomer(array $params): void {
+ try {
+ kys('sasa');
+ if (isset($_POST)) kys($_POST);
+ $payload = [
+ 'additional_data' => [
+ 'company_registration_number' => '',
+ 'company_url' => '',
+ ],
+ 'address' => [
+ 'city' => '',
+ 'country' => '',
+ 'number' => '',
+ 'state' => '',
+ 'street' => '',
+ 'zipcode' => '',
+ ],
+ 'comments' => '',
+ 'company_name' => '',
+ 'email' => '',
+ 'fax' => [
+ 'area_code' => '',
+ 'country_code' => '',
+ 'subscriber_number' => '',
+ ],
+ 'locale' => 'ja_JP',
+ 'name' => [
+ 'first_name' => '',
+ 'full_name' => '',
+ 'last_name' => '',
+ ],
+ 'phone' => [
+ 'area_code' => '',
+ 'country_code' => '',
+ 'subscriber_number' => '',
+ ],
+ ];
+ $tmpl = new Template('/openprovider/');
+ $pagetit = "OpenProvider管理 - 顧客様の新規作成";
+ $description = '';
+
+ // ユーザー
+ $auth = new Auth();
+ $user = $auth->getLoggedInUser();
+ $tmpl->assign('user', $user);
+
+ $tmpl->assign('pagetit', $pagetit);
+ $tmpl->assign('curPage', 'openprovider');
+ $tmpl->assign('custCss', true);
+ $tmpl->assign('menu', $this->getMenu());
+ $tmpl->assign('description', $description);
+
+ if (!$user || $user->role !== \Roles::ADMIN) goto noaccess;
+ if (isset($_POST)) {
+ $op = new Openprovider();
+ $op->login();
+ $data = $op->createCustomer($_POST, true);
+ kys($data->data);
+ header("Location: /openprovider/getcustomer/{$data->data['handle']}");
+ exit();
+ }
+
+ $tmpl->assign('data', $payload);
+ $tmpl->render('createcustomer');
+ kys('sasa');
+
+ exit();
+
+ noaccess:
+ $tmpl->render('nopermission');
+ } catch (\Exception $e) {
+ throw new \Exception($e->getMessage());
+ }
+ }
+
public function opGetCustomer(array $params): void {
try {
$handle = '';
diff --git a/src/Std/Lib/Openprovider.php b/src/Std/Lib/Openprovider.php
index 87acbc7..84d3e36 100644
--- a/src/Std/Lib/Openprovider.php
+++ b/src/Std/Lib/Openprovider.php
@@ -80,7 +80,25 @@ class Openprovider {
return \Result::Error('ログインに失敗。');
}
- // カスタマー
+ /**
+ * SpanExpert向けログインURLの生成
+ * @todo テスト
+ *
+ * @param array $payload フォームデータ
+ * @return Result
+ */
+ public function generateLoginUrlSpamExpert(array $payload = []): \Result {
+ if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
+
+ $uri = '/spam-expert-generate-login-url';
+ $curl = $this->setupCurl($uri, 'POST', $payload);
+ $res = $this->curlResult($curl);
+ if (isset($res->data['data'])) {
+ return \Result::Success('DNSテンプレートの追加に成功。', $res->data);
+ }
+
+ return \Result::Error('DNSテンプレートの追加に失敗。');
+ }
// ドメイン
@@ -88,6 +106,7 @@ class Openprovider {
/***
* ドメイン一覧。
+ * @todo テスト
*
* @return Result 結果。
*/
@@ -108,6 +127,7 @@ class Openprovider {
/**
* ドメイン名の登録。
+ * @todo テスト
*
* @param string $name 登録したいドメイン名(例:"076studio.jp")
* @param array $info カスタマー情報等
@@ -197,59 +217,67 @@ class Openprovider {
//// 追加データ
- //// 顧客様の追加データ
-
/**
- * 顧客様の一覧
+ * 追加データの受け取り
+ * @todo テスト
*
* @param array $query 検索クエリー
* @return Result
*/
- public function listCustomers(array $query = []): \Result {
+ public function getDomainAdditionalData(array $query): \Result {
if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
- $cache = $this->getCache('listcustomers');
- if ($this->isValidLifespan($cache, $query)) return \Result::Success('', $cache);
+ $name = '';
+ $ext = '';
+ if (isset($query['domain.name'])) $name = $query['domain.name'];
+ if (isset($query['domain.extension'])) $ext = $query['domain.extension'];
+ $cacheName = $name && $ext ? "domainadditionaldata-{$name}.{$ext}" : 'domainadditionaldata';
- foreach ($query as $k => $v) { if (is_bool($v)) $query[$k] = $v ? '1' : '0'; }
- $uri = '/customers?'.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('listcustomers', $res->data);
- return \Result::Success('', $res->data);
- }
-
- return \Result::Error('顧客様一覧の受け取りに失敗。');
- }
-
- /**
- * 顧客様の表示
- *
- * @param string $handle ハンドル
- * @param bool $withAdditionalData 詳細データ含むか?
- * @return Result
- */
- public function getCustomer(string $handle, bool $withAdditionalData = false): \Result {
- if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
- $cacheName = "getcustomer-{$handle}";
$cache = $this->getCache($cacheName);
- if ($this->isValidLifespan($cache, $handle, 'handle')) return \Result::Success('', $cache);
+ if ($this->isValidLifespan($cache)) return \Result::Success('', $cache);
- $query = [ 'with_additional_data' => $withAdditionalData ? 'true' : 'false' ];
- $uri = "/customers/{$handle}?".http_build_query($query, '', '&', PHP_QUERY_RFC3986);
- // kys($uri);
+ $uri = "/domains/additional-data?".http_build_query($query, '', '&', PHP_QUERY_RFC3986);
$curl = $this->setupCurl($uri);
$res = $this->curlResult($curl);
if (isset($res->data['data'])) {
- $res->data['handle'] = $handle;
$this->setCache($cacheName, $res->data);
return \Result::Success('', $res->data);
}
- return \Result::Error('顧客様の受け取りに失敗。');
+ return \Result::Error('ドメインの追加データの受け取りに失敗。');
}
+ //// 顧客様の追加データ
+
+ /**
+ * 顧客様の追加データの受け取り
+ * @todo テスト
+ *
+ * @param array $query 検索クエリー
+ * @return Result
+ */
+ public function getDomainCustomerAdditionalData(array $query): \Result {
+ if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
+ $name = '';
+ $ext = '';
+ if (isset($query['domain.name'])) $name = $query['domain.name'];
+ if (isset($query['domain.extension'])) $ext = $query['domain.extension'];
+ $cacheName = $name && $ext ? "domainadditionaldata-{$name}.{$ext}" : 'domainadditionaldata';
+
+ $cache = $this->getCache($cacheName);
+ if ($this->isValidLifespan($cache)) return \Result::Success('', $cache);
+
+ $uri = "/domains/additional-data/customers?".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('ドメインの顧客様の追加データの受け取りに失敗。');
+ }
+
+
//// ドメイン値段
/**
@@ -282,6 +310,47 @@ class Openprovider {
//// 認証コード
+ /**
+ * 認証コードの受け取り
+ *
+ * @param int $id ドメイン名ID
+ * @param array $query 検索クエリー
+ * @return Result
+ */
+ public function getAuthCode(int $id, array $query = []): \Result {
+ if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
+
+ $uri = "/domains/{$id}/authcode?".http_build_query($query, '', '&', PHP_QUERY_RFC3986);
+ $curl = $this->setupCurl($uri);
+ $res = $this->curlResult($curl);
+ if (isset($res->data['data'])) {
+ return \Result::Success('', $res->data);
+ }
+
+ return \Result::Error('認証コードの受け取りに失敗。');
+ }
+
+ /**
+ * 認証コードの再設定
+ *
+ * @param int $id ドメイン名ID
+ * @param array $payload フォームデータ
+ * @return Result
+ */
+ public function resetAuthCode(int $id, array $payload = []): \Result {
+ if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
+
+ $uri = "/domains/{$id}/authcode/reset";
+ $curl->setupCurl($uri, 'POST', $payload);
+ $res = $this->curlResult($curl);
+ kys($res);
+ if (isset($res)) {
+ return \Result::Success('', $res->data);
+ }
+
+ return \Result::Error("認証コードの再設定に失敗。");
+ }
+
//// TLD
/**
@@ -296,7 +365,7 @@ class Openprovider {
if ($this->isValidLifespan($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 ? '1' : '0';
+ foreach ($query as $k => $v) if (is_bool($v)) $query[$k] = $v ? 'true' : 'false';
$uri = '/tlds?'.http_build_query($query, '', '&', PHP_QUERY_RFC3986);
$curl = $this->setupCurl($uri);
@@ -318,37 +387,231 @@ class Openprovider {
*/
public function getTld(string $tld, array $query = []): \Result {
if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
- $cache = $this->getCache("gettld-{$tld}");
+ $cacheName = "gettld-{$tld}";
+ $cache = $this->getCache($cacheName);
if ($this->isValidLifespan($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 ? '1' : '0';
+ foreach ($query as $k => $v) if (is_bool($v)) $query[$k] = $v ? 'true' : 'false';
$uri = "/tlds/{$tld}?".http_build_query($query, '', '&', PHP_QUERY_RFC3986);
$curl = $this->setupCurl($uri);
$res = $this->curlResult($curl);
if (isset($res->data['data'])) {
- $this->setCache("gettld-{$tld}", $res->data);
+ $this->setCache($cacheName, $res->data);
return \Result::Success('', $res->data);
}
return \Result::Error('TLD一覧の受け取りに失敗。');
}
- /**
- * TLDの受け取り
- */
-
// 請求
//// 請求書
+
+ /**
+ * 請求書一覧
+ * @todo テスト
+ *
+ * @param array $query 検索クエリー
+ * @return Result
+ */
+ public function listInvoices(array $query = []): \Result {
+ if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
+ $cacheName = 'listinvoices';
+ $cache = $this->getCache($cacheName);
+ if ($this->isValidLifespan($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';
+
+ $uri = "/invoices?".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 $query 検索クエリー
+ * @return Result
+ */
+ public function listPayments(array $query = []): \Result {
+ if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
+ $cacheName = 'listpayments';
+ $cache = $this->getCache($cacheName);
+ if ($this->isValidLifespan($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';
+
+ $uri = "/payments?".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 $query 検索クエリー
+ * @return Result
+ */
+ public function listTransactions(array $query = []): \Result {
+ if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
+ $cacheName = 'listtransactions';
+ $cache = $this->getCache($cacheName);
+ if ($this->isValidLifespan($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';
+
+ $uri = "/transactions?".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('トランザクション一覧の受け取りに失敗。');
+ }
+
// DNS
//// DomainToken
+
+ /**
+ * ドメイントークンの作成
+ * @todo テスト
+ *
+ * @param array $payload フォームデータ
+ * @return Result
+ */
+ public function createDomainToken(array $payload = []): \Result {
+ if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
+
+ $uri = '/dns/domain-token';
+ $curl = $this->setupCurl($uri, 'POST', $payload);
+ $res = $this->curlResult($curl);
+ if (isset($res->data['data'])) {
+ return \Result::Success('DNSテンプレートの追加に成功。', $res->data);
+ }
+
+ return \Result::Error('DNSテンプレートの追加に失敗。');
+ }
+
//// ネームサーバー
//// NSグループ
//// テンプレート
+
+ /**
+ * DNSテンプレート一覧
+ * @todo テスト
+ *
+ * @param array $query 検索クエリー
+ * @return Result
+ */
+ public function listDnsTemplate(array $query = []): \Result {
+ if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
+ $cacheName = 'listdnstemplates';
+ $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 = '/dns/templates?'.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('DNSテンプレート一覧の受け取りに失敗。');
+ }
+
+ /**
+ * DNSテンプレートの作成
+ * @todo テスト
+ *
+ * @param array $payload フォームデータ
+ * @return Result
+ */
+ public function createDnsTemplate(array $payload = []): \Result {
+ if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
+
+ $uri = '/dns/templates';
+ $curl = $this->setupCurl($uri, 'POST', $payload);
+ $res = $this->curlResult($curl);
+ if (isset($res->data['data'])) {
+ $this->murderCache('listdnstemplates');
+ return \Result::Success('DNSテンプレートの追加に成功。', $res->data);
+ }
+
+ return \Result::Error('DNSテンプレートの追加に失敗。');
+ }
+
+ /**
+ * DNSテンプレートの表示
+ * @todo テスト
+ *
+ * @param int $id DNSテンプレートID
+ * @return Result
+ */
+ public function getDnsTemplate(int $id): \Result {
+ if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
+ $cacheName = "getdnstemplate-{$id}";
+ $cache = $this->getCache($cacheName);
+ if ($this->isValidLifespan($cache, $query)) return \Result::Success('', $cache);
+
+ $uri = "/dns/templates/{$id}";
+ $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('DNSテンプレートの更新に失敗。');
+ }
+
+ /**
+ * DNSテンプレートの削除
+ * @todo テスト
+ *
+ * @param int $id DNSテンプレートID
+ * @return Result
+ */
+ public function deleteDnsTemplate(int $id): \Result {
+ if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
+
+ $uri = "/dns/templates/{$id}";
+ $curl = $this->setupCurl($uri, 'DELETE');
+ $res = $this->curlResult($curl);
+ if (isset($res->data['data'])) {
+ $this->murderCache('listdnstemplates');
+ if ($res->data['data']['success']) return \Result::Success('DNSテンプレートの削除に成功。', $res->data);
+ }
+
+ return \Result::Error('DNSテンプレートの削除に失敗。');
+ }
+
//// ゾーン
/**
@@ -363,7 +626,7 @@ class Openprovider {
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 ? '1' : '0';
+ foreach ($query as $k => $v) if (is_bool($v)) $query[$k] = $v ? 'true' : 'false';
$uri = "/dns/zones?".http_build_query($query, '', '&', PHP_QUERY_RFC3986);
$curl = $this->setupCurl($uri);
@@ -389,7 +652,7 @@ class Openprovider {
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 ? '1' : '0';
+ foreach ($query as $k => $v) if (is_bool($v)) $query[$k] = $v ? 'true' : 'false';
$uri = "/dns/zones/{$domain}?".http_build_query($query, '', '&', PHP_QUERY_RFC3986);
$curl = $this->setupCurl($uri);
@@ -427,10 +690,469 @@ class Openprovider {
// Easydmarc
+ // メールテンプレート
+
+ //// メール
+
+ /**
+ * メールテンプレート一覧
+ * @todo テスト
+ *
+ * @param array $query 検索クエリー
+ * @return Result
+ */
+ public function listEmails(array $query = []): \Result {
+ if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
+ $cacheName = 'listemails';
+ $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 = '/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('メールテンプレート一覧の受け取りに失敗。');
+ }
+
+ /**
+ * メールテンプレートの作成
+ * @todo テスト
+ *
+ * @param array $payload フォームデータ
+ * @return Result
+ */
+ public function createEmail(array $payload = []): \Result {
+ if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
+
+ $uri = '/emails';
+ $curl = $this->setupCurl($uri, 'POST', $payload);
+ $res = $this->curlResult($curl);
+ if (isset($res->data['data'])) {
+ $this->murderCache('listemails');
+ return \Result::Success('メールテンプレートの追加に成功。', $res->data);
+ }
+
+ return \Result::Error('メールテンプレートの追加に失敗。');
+ }
+
+ /**
+ * メールテンプレートの更新
+ * @todo テスト
+ *
+ * @param int $id メールテンプレートID
+ * @param array $payload フォームデータ
+ * @return Result
+ */
+ public function updateEmail(int $id, array $payload = []): \Result {
+ if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
+
+ $uri = "/emails/{$id}";
+ $curl = $this->setupCurl($uri, 'PUT', $payload);
+ $res = $this->curlResult($curl);
+ if (isset($res->data['data'])) {
+ $this->murderCache('listemails');
+ if ($res->data['data']['success']) return \Result::Success('メールテンプレートの更新に成功。', $res->data);
+ }
+
+ return \Result::Error('メールテンプレートの更新に失敗。');
+ }
+
+ /**
+ * メールテンプレートの削除
+ * @todo テスト
+ *
+ * @param int $id メールテンプレートID
+ * @return Result
+ */
+ public function deleteEmail(int $id): \Result {
+ if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
+
+ $uri = "/emails/{$id}";
+ $curl = $this->setupCurl($uri, 'DELETE');
+ $res = $this->curlResult($curl);
+ if (isset($res->data['data'])) {
+ $this->murderCache('listemails');
+ if ($res->data['data']['success']) return \Result::Success('メールテンプレートの削除に成功。', $res->data);
+ }
+
+ return \Result::Error('メールテンプレートの削除に失敗。');
+ }
+
// ライセンス
// リセラー・顧客様
+ //// 連絡先
+
+ //// 顧客様
+
+ /**
+ * 顧客様の一覧
+ *
+ * @param array $query 検索クエリー
+ * @return Result
+ */
+ public function listCustomers(array $query = []): \Result {
+ if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
+ $cacheName = 'listcustomers';
+ $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 = '/customers?'.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 createCustomer(array $payload): \Result {
+ if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
+
+ $uri = '/customers';
+ $curl->setupCurl($uri, 'POST', $payload);
+ $res = $this->curlResult($curl);
+ kys($res);
+ if (isset($res)) {
+ $this->murderCache('listcustomers');
+ return \Result::Success('', $res->data);
+ }
+
+ return \Result::Error("顧客様の作成に失敗。");
+ }
+
+ /**
+ * 顧客様の表示
+ *
+ * @param string $handle ハンドル
+ * @param bool $withAdditionalData 詳細データ含むか?
+ * @return Result
+ */
+ public function getCustomer(string $handle, bool $withAdditionalData = false): \Result {
+ if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
+ $cacheName = "getcustomer-{$handle}";
+ $cache = $this->getCache($cacheName);
+ if ($this->isValidLifespan($cache, $handle, 'handle')) return \Result::Success('', $cache);
+
+ $query = [ 'with_additional_data' => $withAdditionalData ? 'true' : 'false' ];
+ $uri = "/customers/{$handle}?".http_build_query($query, '', '&', PHP_QUERY_RFC3986);
+ // kys($uri);
+ $curl = $this->setupCurl($uri);
+ $res = $this->curlResult($curl);
+ if (isset($res->data['data'])) {
+ $res->data['handle'] = $handle;
+ $this->setCache($cacheName, $res->data);
+ return \Result::Success('', $res->data);
+ }
+
+ return \Result::Error('顧客様の受け取りに失敗。');
+ }
+
+ /**
+ * 顧客様の更新
+ * @todo テスト
+ *
+ * @param string $handle 顧客様のハンドル
+ * @param array $payload フォームデータ
+ * @return Result
+ */
+ public function updateCustomer(string $handle, array $payload = []): \Result {
+ if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
+
+ $uri = "/customers/{$handle}";
+ $curl = $this->setupCurl($uri, 'PUT', $payload);
+ $res = $this->curlResult($curl);
+ if (isset($res->data['data'])) {
+ $this->murderCache('listcustomers');
+ if ($res->data['data']['success']) return \Result::Success('顧客様の更新に成功。', $res->data);
+ }
+
+ return \Result::Error('顧客様の更新に失敗。');
+ }
+
+ /**
+ * 顧客様の削除
+ * @todo テスト
+ *
+ * @param string $handle 顧客様のハンドル
+ * @return Result
+ */
+ public function deleteCustomer(int $id): \Result {
+ if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
+
+ $uri = "/customers/{$handle}";
+ $curl = $this->setupCurl($uri, 'DELETE');
+ $res = $this->curlResult($curl);
+ if (isset($res->data['data'])) {
+ $this->murderCache('listcustomers');
+ if ($res->data['data']['success']) return \Result::Success('顧客様の削除に成功。', $res->data);
+ }
+
+ return \Result::Error('顧客様の削除に失敗。');
+ }
+
+ //// メール認証
+
+ /**
+ * メール認証一覧
+ * @todo テスト
+ *
+ * @param array $query 検索クエリー
+ * @return Result
+ */
+ public function listEmailVerifications(array $query = []): \Result {
+ if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
+ $cacheName = 'listemailverifications';
+ $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 = '/customers/verifications/emails/domains?'.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 string $email メールアドレス
+ * @return Result
+ */
+ public function restartEmailVerifications(string $email, string $language = '', string $tag = ''): \Result {
+ if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
+
+ $uri = '/customers/verifications/emails/restart';
+ $curl = $this->setupCurl($uri, 'POST', ['email' => $email, 'language' => $language, 'tag' => $tag]);
+ $res = $this->curlResult($curl);
+ if (isset($res->data['data'])) {
+ $this->murderCache('listemailverifications');
+ return \Result::Success('メール認証の再起動に成功。', $res->data);
+ }
+
+ return \Result::Error('メール認証の再起動に失敗。');
+ }
+
+ /**
+ * メール認証の起動
+ * @todo テスト
+ *
+ * @param string $email メールアドレス
+ * @param string $handle 顧客様のハンドル
+ * @param string $language 言語
+ * @param string $tag タグ
+ * @return Result
+ */
+ public function startEmailVerifications(string $email, string $handle = '', string $language = '', string $tag = ''): \Result {
+ if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
+
+ $uri = '/customers/verifications/emails/start';
+ $curl = $this->setupCurl($uri, 'POST', ['email' => $email, 'handle' => $handle, 'language' => $language, 'tag' => $tag]);
+ $res = $this->curlResult($curl);
+ if (isset($res->data['data'])) {
+ $this->murderCache('listemailverifications');
+ return \Result::Success('メール認証の起動に成功。', $res->data);
+ }
+
+ return \Result::Error('メール認証の起動に失敗。');
+ }
+
+ //// リセラー
+
+ /**
+ * リセラーの受け取り
+ * @todo テスト
+ *
+ * @param array $query 検索クエリー
+ * @return Result
+ */
+ public function getReseller(array $query = []): \Result {
+ if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
+ $cacheName = 'getreseller';
+ $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 = '/resellers?'.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
+ * @param array $payload フォームデータ
+ * @return Result
+ */
+ public function updateReseller(int $id, array $payload = []): \Result {
+ if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
+
+ $uri = "/resellers/{$id}";
+ $curl = $this->setupCurl($uri, 'PUT', $payload);
+ $res = $this->curlResult($curl);
+ if (isset($res->data['data'])) {
+ $this->murderCache('getreseller');
+ if ($res->data['data']['success']) return \Result::Success('リセラーの更新に成功。', $res->data);
+ }
+
+ return \Result::Error('リセラーの更新に失敗。');
+ }
+
+ //// 設定
+
+ /**
+ * 設定の受け取り
+ * @todo テスト
+ *
+ * @return Result
+ */
+ public function listSettings(): \Result {
+ if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
+ $cacheName = 'listsettings';
+ $cache = $this->getCache($cacheName);
+ if ($this->isValidLifespan($cache, $query)) return \Result::Success('', $cache);
+
+ $uri = '/resellers/settings';
+ $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 テスト
+ *
+ * @return Result
+ */
+ public function listStatistics(array $query = []): \Result {
+ if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
+ $cacheName = 'liststatistics';
+ $cache = $this->getCache($cacheName);
+ if ($this->isValidLifespan($cache, $query)) return \Result::Success('', $cache);
+
+ $uri = '/resellers/statistics';
+ $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 array $query 検索クエリー
+ * @return Result
+ */
+ public function listTags(array $query = []): \Result {
+ if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
+ $cacheName = 'listtags';
+ $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 = '/tags?'.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 array $payload フォームデータ
+ * @return Result
+ */
+ public function createTag(array $payload = []): \Result {
+ if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
+
+ $uri = '/tags';
+ $curl = $this->setupCurl($uri, 'POST', $payload);
+ $res = $this->curlResult($curl);
+ if (isset($res->data['data'])) {
+ $this->murderCache('listtags');
+ return \Result::Success('タグの追加に成功。', $res->data);
+ }
+
+ return \Result::Error('タグの追加に失敗。');
+ }
+
+ /**
+ * タグの削除
+ * @todo テスト
+ *
+ * @param array $payload フォームデータ
+ * @return Result
+ */
+ public function deleteTag(array $payload = []): \Result {
+ if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
+
+ $uri = "/tags/{$id}";
+ $curl = $this->setupCurl($uri, 'DELETE', $payload);
+ $res = $this->curlResult($curl);
+ if (isset($res->data['data'])) {
+ $this->murderCache('listtags');
+ if ($res->data['data']['success']) return \Result::Success('タグの削除に成功。', $res->data);
+ }
+
+ return \Result::Error('タグの削除に失敗。');
+ }
+
// SpamExpert
// SSL証明書
diff --git a/view/openprovider/createcustomer.maron b/view/openprovider/createcustomer.maron
new file mode 100644
index 0000000..e84f5d4
--- /dev/null
+++ b/view/openprovider/createcustomer.maron
@@ -0,0 +1,109 @@
+{@ include(common/header) @}
+ 新規顧客様作成
+
+
+
+ {@ kys($data) @}
+{@ include(common/footer) @}
\ No newline at end of file
diff --git a/view/openprovider/listcustomers.maron b/view/openprovider/listcustomers.maron
index 3b1bc70..ebea5b4 100644
--- a/view/openprovider/listcustomers.maron
+++ b/view/openprovider/listcustomers.maron
@@ -1,5 +1,5 @@
{@ include(common/header) @}
- 顧客様の追加
+ 顧客様の追加
検索
{@ if (isset($data['data']['results'])) @}