沢山APIの追加

This commit is contained in:
2026-04-28 14:39:26 +09:00
parent 430249ebf5
commit d4176e6553
5 changed files with 954 additions and 47 deletions

View File

@@ -61,6 +61,7 @@ if (ATOM_ENABLED) {
if (OPENPROVIDER_ENABLED) { if (OPENPROVIDER_ENABLED) {
$routes[] = Route::add('GET', 'openprovider', Op::class.'@index'); $routes[] = Route::add('GET', 'openprovider', Op::class.'@index');
$routes[] = Route::add('GET', 'openprovider/listcustomers', Op::class.'@opListCustomers'); $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/getcustomer/{handle}', Op::class.'@opGetCustomer');
$routes[] = Route::add('GET', 'openprovider/listtlds', Op::class.'@opListTlds'); $routes[] = Route::add('GET', 'openprovider/listtlds', Op::class.'@opListTlds');
$routes[] = Route::add('GET', 'openprovider/gettld/{tld}', Op::class.'@opGetTld'); $routes[] = Route::add('GET', 'openprovider/gettld/{tld}', Op::class.'@opGetTld');

View File

@@ -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 { public function opGetCustomer(array $params): void {
try { try {
$handle = ''; $handle = '';

View File

@@ -80,7 +80,25 @@ class Openprovider {
return \Result::Error('ログインに失敗。'); 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 結果。 * @return Result 結果。
*/ */
@@ -108,6 +127,7 @@ class Openprovider {
/** /**
* ドメイン名の登録。 * ドメイン名の登録。
* @todo テスト
* *
* @param string $name 登録したいドメイン名(例:"076studio.jp" * @param string $name 登録したいドメイン名(例:"076studio.jp"
* @param array $info カスタマー情報等 * @param array $info カスタマー情報等
@@ -197,59 +217,67 @@ class Openprovider {
//// 追加データ //// 追加データ
//// 顧客様の追加データ
/** /**
* 顧客様の一覧 * 追加データの受け取り
* @todo テスト
* *
* @param array $query 検索クエリー * @param array $query 検索クエリー
* @return Result * @return Result
*/ */
public function listCustomers(array $query = []): \Result { public function getDomainAdditionalData(array $query): \Result {
if (!OPENPROVIDER_ENABLED) return \Result::error('エラーOpenProviderは無効です。'); if (!OPENPROVIDER_ENABLED) return \Result::error('エラーOpenProviderは無効です。');
$cache = $this->getCache('listcustomers'); $name = '';
if ($this->isValidLifespan($cache, $query)) return \Result::Success('', $cache); $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); $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 = "/domains/additional-data?".http_build_query($query, '', '&', PHP_QUERY_RFC3986);
$uri = "/customers/{$handle}?".http_build_query($query, '', '&', PHP_QUERY_RFC3986);
// kys($uri);
$curl = $this->setupCurl($uri); $curl = $this->setupCurl($uri);
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res->data['data'])) { if (isset($res->data['data'])) {
$res->data['handle'] = $handle;
$this->setCache($cacheName, $res->data); $this->setCache($cacheName, $res->data);
return \Result::Success('', $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 //// TLD
/** /**
@@ -296,7 +365,7 @@ class Openprovider {
if ($this->isValidLifespan($cache)) return \Result::Success('', $cache); if ($this->isValidLifespan($cache)) return \Result::Success('', $cache);
if (empty($query)) $query = [ 'limit' => 10, 'offset' => 0, 'order' => 'ASC' ]; 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); $uri = '/tlds?'.http_build_query($query, '', '&', PHP_QUERY_RFC3986);
$curl = $this->setupCurl($uri); $curl = $this->setupCurl($uri);
@@ -318,37 +387,231 @@ class Openprovider {
*/ */
public function getTld(string $tld, array $query = []): \Result { public function getTld(string $tld, array $query = []): \Result {
if (!OPENPROVIDER_ENABLED) return \Result::error('エラーOpenProviderは無効です。'); 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 ($this->isValidLifespan($cache)) return \Result::Success('', $cache);
if (empty($query)) $query = [ 'limit' => 10, 'offset' => 0 ]; 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); $uri = "/tlds/{$tld}?".http_build_query($query, '', '&', PHP_QUERY_RFC3986);
$curl = $this->setupCurl($uri); $curl = $this->setupCurl($uri);
$res = $this->curlResult($curl); $res = $this->curlResult($curl);
if (isset($res->data['data'])) { if (isset($res->data['data'])) {
$this->setCache("gettld-{$tld}", $res->data); $this->setCache($cacheName, $res->data);
return \Result::Success('', $res->data); return \Result::Success('', $res->data);
} }
return \Result::Error('TLD一覧の受け取りに失敗。'); 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 // DNS
//// DomainToken //// 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グループ //// 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 ($this->isValidLifespan($cache, $query)) return \Result::Success('', $cache);
if (empty($query)) $query = [ 'limit' => 25, 'offset' => 0, 'order_by.name' => 'asc' ]; 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); $uri = "/dns/zones?".http_build_query($query, '', '&', PHP_QUERY_RFC3986);
$curl = $this->setupCurl($uri); $curl = $this->setupCurl($uri);
@@ -389,7 +652,7 @@ class Openprovider {
if ($this->isValidLifespan($cache)) return \Result::Success('', $cache); if ($this->isValidLifespan($cache)) return \Result::Success('', $cache);
if (empty($query)) $query = [ 'limit' => 100, 'offset' => 0, 'order_by.name' => 'asc' ]; 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); $uri = "/dns/zones/{$domain}?".http_build_query($query, '', '&', PHP_QUERY_RFC3986);
$curl = $this->setupCurl($uri); $curl = $this->setupCurl($uri);
@@ -427,10 +690,469 @@ class Openprovider {
// Easydmarc // 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 // SpamExpert
// SSL証明書 // SSL証明書

View File

@@ -0,0 +1,109 @@
{@ include(common/header) @}
<h2>新規顧客様作成</h2>
<p>
<form method="POST" action="/openprovider/createcustomer">
<h3>会社情報</h3>
<p>個人の場合、入力が不要です。</p>
<table>
<tbody>
<tr>
<td><label for="company_name">会社名</label></td>
<td><input type="text" name="company_name" value="{{ $data['company_name'] }}" /></td>
</tr>
<tr>
<td><label for="company_registration_number">法人番号</label></td>
<td><input type="text" name="company_registration_number" value="{{ $data['company_registration_number'] }}" /></td>
</tr>
<tr>
<td><label for="company_url">ウェブサイト</label></td>
<td><input type="text" name="company_url" value="{{ $data['company_url'] }}" /></td>
</tr>
</tbody>
</table>
<h3>個人情報</h3>
telephone number (req)
fax number
email address (req)
birth date
<table>
<tbody>
<tr>
<td><label for="last_name">姓名(ローマ字)*</label></td>
<td>
<input type="text" name="last_name" placeholder="Taro" value="{{ $data['last_name'] }}" />
<input type="text" name="first_name" placeholder="Yamada" value="{{ $data['first_name'] }}" />
</td>
</tr>
<tr>
<td><label for="phone.country_code">電話番号*</label></td>
<td>
<input type="text" name="phone.country_code" placeholder="+81" value="{{ $data['phone.country_code'] }}" />
<input type="text" name="phone.area_code" placeholder="43" value="{{ $data['phone.area_code'] }}" />
<input type="text" name="phone.subscriber_number" placeholder="0000000" value="{{ $data['phone.subscriber_number'] }}" />
</td>
</tr>
<tr>
<td><label for="fax.country_code">FAX</label></td>
<td>
<input type="text" name="fax.country_code" placeholder="+81" value="{{ $data['fax.country_code'] }}" />
<input type="text" name="fax.area_code" placeholder="43" value="{{ $data['fax.area_code'] }}" />
<input type="text" name="fax.subscriber_number" placeholder="0000000" value="{{ $data['fax.subscriber_number'] }}" />
</td>
</tr>
<tr>
<td><label for="email">メールアドレス*</label></td>
<td><input type="text" name="email" placeholder="taro@076.co.jp" value="{{ $data['email'] }}" /></td>
</tr>
<tr>
<td><label for="year">生年月日</label></td>
<td>
<input type="text" name="year" placeholder="1970" value="{{ $data['year'] }}" />年
<input type="text" name="month" placeholder="12" value="{{ $data['month'] }}" />月
<input type="text" name="day" placeholder="31" value="{{ $data['day'] }}" />日
</td>
</tr>
</tbody>
</table>
<h3>住所情報</h3>
<table>
<tbody>
<tr>
<td><label for="zipcode">郵便番号*(ハイフン付き)</label></td>
<td>〒<input type="text" name="zipcode" value="{{ $data['zipcode'] }}" /></td>
</tr>
<tr>
<td><label for="state">都道府県*</label></td>
<td><input type="text" name="state" value="{{ $data['state'] }}" /></td>
</tr>
<tr>
<td><label for="city">市区町村*</label></td>
<td><input type="text" name="city" value="{{ $data['city'] }}" /></td>
</tr>
<tr>
<td><label for="street">町名*</label></td>
<td><input type="text" name="street" value="{{ $data['street'] }}" /></td>
</tr>
<tr>
<td><label for="number">番地*</label></td>
<td><input type="text" name="number" value="{{ $data['number'] }}" /></td>
</tr>
<tr>
<td><label for="country">国</label></td>
<td>
<select name="country">
<option value="JP" selected="selected">日本</option>
<option value="NL">オランダ</option>
</select>
</td>
</tr>
<tr>
<td><label for="comments">メモ</label></td>
<td><input type="text" name="comments" value="{{ $data['comments'] }}" /></td>
</tr>
</tbody>
</table>
<button>送信</button>
</form>
</p>
{@ kys($data) @}
{@ include(common/footer) @}

View File

@@ -1,5 +1,5 @@
{@ include(common/header) @} {@ include(common/header) @}
顧客様の追加<br /> <a href="/openprovider/createcustomer">顧客様の追加</a><br />
検索<br /> 検索<br />
{@ if (isset($data['data']['results'])) @} {@ if (isset($data['data']['results'])) @}
<table> <table>