@@ -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は無効です。' );
$cach e = $this -> getCache ( 'listcustomers ') ;
if ( $this -> isValidLifespan ( $cache , $query )) return \Result :: Success ( '' , $cache ) ;
$nam e = ' ';
$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証明書