| | @@ -38,9 +38,10 @@ |
| 38 | 38 | namespace Std\Lib;
|
| 39 | 39 |
|
| 40 | 40 | use Std\Lib\Curl;
|
| 41 | +use Result;
|
| 41 | 42 |
|
| 42 | 43 | class Openprovider {
|
| 43 | | - protected string $dataDir = ROOT."/data/cache/";
|
| 44 | + protected string $dataDir = ROOT."/data/cache/openprovider/";
|
| 44 | 45 | protected int $tokenDuration = 172800; // 48時間
|
| 45 | 46 | protected int $dataDuration = 1800; // 30分
|
| 46 | 47 |
|
| | @@ -60,19 +61,19 @@ |
| 60 | 61 | $this->ip = OPENPROVIDER['ip'];
|
| 61 | 62 | }
|
| 62 | 63 |
|
| 63 | | - /***
|
| 64 | + /**
|
| 64 | 65 | * トークンの受け取り。
|
| 65 | 66 | * このライブリリーを使ったら、一回「login()」を実行する事が必須となります。
|
| 66 | 67 | *
|
| 67 | 68 | * @return Result 結果
|
| 68 | 69 | */
|
| 69 | | - public function login(): \Result {
|
| 70 | | - if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
|
| 70 | + public function login(): Result {
|
| 71 | + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
|
| 71 | 72 | $cache = $this->getCache('login');
|
| 72 | 73 | if (time() < ($this->lastAuth + $this->tokenDuration)) {
|
| 73 | 74 | $this->token = $cache['data']['token'];
|
| 74 | 75 | $this->lastAuth = $cache['last_auth'];
|
| 75 | | - return \Result::Success('', $cache);
|
| 76 | + return Result::Success('', $cache);
|
| 76 | 77 | }
|
| 77 | 78 |
|
| 78 | 79 | $curl = new Curl("{$this->BASEURL}/auth/login");
|
| | @@ -91,7 +92,7 @@ |
| 91 | 92 | if (!$res->isSuccess) {
|
| 92 | 93 | $err = "CURLの実行に失敗: ".$curl->message;
|
| 93 | 94 | assert_unless_success($res, $err);
|
| 94 | | - return \Result::Error($err);
|
| 95 | + return Result::Error($err);
|
| 95 | 96 | }
|
| 96 | 97 |
|
| 97 | 98 | $body = $curl->getResponseBody();
|
| | @@ -99,7 +100,7 @@ |
| 99 | 100 | $err = json_decode($body, true);
|
| 100 | 101 | assert_not_null($err, "エラーの受け取りに失敗。");
|
| 101 | 102 | assert($curl->getResponseCode() == 200, $err['desc']);
|
| 102 | | - return \Result::Error();
|
| 103 | + return Result::Error();
|
| 103 | 104 | }
|
| 104 | 105 | assert_not_null($body, "返事ボディーは空です。");
|
| 105 | 106 |
|
| | @@ -110,10 +111,10 @@ |
| 110 | 111 | $res['last_auth'] = $this->lastAuth;
|
| 111 | 112 | $this->setCache('login', $res);
|
| 112 | 113 |
|
| 113 | | - return \Result::Success('', $res);
|
| 114 | + return Result::Success('', $res);
|
| 114 | 115 | }
|
| 115 | 116 |
|
| 116 | | - return \Result::Error('ログインに失敗。');
|
| 117 | + return Result::Error('ログインに失敗。');
|
| 117 | 118 | }
|
| 118 | 119 |
|
| 119 | 120 | /**
|
| | @@ -123,42 +124,42 @@ |
| 123 | 124 | * @param array $payload フォームデータ
|
| 124 | 125 | * @return Result
|
| 125 | 126 | */
|
| 126 | | - public function generateLoginUrlSpamExpert(array $payload = []): \Result {
|
| 127 | | - if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
|
| 127 | + public function generateLoginUrlSpamExpert(array $payload = []): Result {
|
| 128 | + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
|
| 128 | 129 |
|
| 129 | 130 | $uri = '/spam-expert-generate-login-url';
|
| 130 | 131 | $curl = $this->setupCurl($uri, 'POST', $payload);
|
| 131 | 132 | $res = $this->curlResult($curl);
|
| 132 | 133 | if (isset($res->data['data'])) {
|
| 133 | | - return \Result::Success('DNSテンプレートの追加に成功。', $res->data);
|
| 134 | + return Result::Success('DNSテンプレートの追加に成功。', $res->data);
|
| 134 | 135 | }
|
| 135 | 136 |
|
| 136 | | - return \Result::Error('DNSテンプレートの追加に失敗。');
|
| 137 | + return Result::Error('DNSテンプレートの追加に失敗。');
|
| 137 | 138 | }
|
| 138 | 139 |
|
| 139 | 140 | // ドメイン
|
| 140 | 141 |
|
| 141 | 142 | //// ドメイン
|
| 142 | 143 |
|
| 143 | | - /***
|
| 144 | + /**
|
| 144 | 145 | * ドメイン一覧。
|
| 145 | 146 | * @todo テスト
|
| 146 | 147 | *
|
| 147 | 148 | * @return Result 結果。
|
| 148 | 149 | */
|
| 149 | | - public function listDomains(array $query = []): \Result {
|
| 150 | | - if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
|
| 150 | + public function listDomains(array $query = []): Result {
|
| 151 | + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
|
| 151 | 152 | $cache = $this->getCache('listdomains');
|
| 152 | | - if ($this->isValidLifespan($cache, $query)) return \Result::Success('', $cache);
|
| 153 | + if ($this->isValidLifespan($cache, $query)) return Result::Success('', $cache);
|
| 153 | 154 |
|
| 154 | 155 | $curl = $this->setupCurl('/domains');
|
| 155 | 156 | $res = $this->curlResult($curl);
|
| 156 | 157 | if (isset($res['data']['results'])) {
|
| 157 | 158 | $this->setCache('listdomains', $res->data);
|
| 158 | | - return \Result::Success('', $res['data']['results']);
|
| 159 | + return Result::Success('', $res['data']['results']);
|
| 159 | 160 | }
|
| 160 | 161 |
|
| 161 | | - return \Result::Error('ドメインの確認に失敗。');
|
| 162 | + return Result::Error('ドメインの確認に失敗。');
|
| 162 | 163 | }
|
| 163 | 164 |
|
| 164 | 165 | /**
|
| | @@ -170,8 +171,8 @@ |
| 170 | 171 | * @param int $period 年間(デフォルト=1年)
|
| 171 | 172 | * @return Result 結果。配列の場合:'activation_date'(リアルタイムで成功したのみ), 'auth_code'(TLDが対応している場合のみ), 'expiration_date', 'id', 'renewal_date', 'status'(ACT又はREQ)
|
| 172 | 173 | */
|
| 173 | | - public function createDomain(string $name, array $info, int $period = 1): \Result {
|
| 174 | | - if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
|
| 174 | + public function createDomain(string $name, array $info, int $period = 1): Result {
|
| 175 | + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
|
| 175 | 176 | if (!isset($info['owner_handle']) || $info['owner_handle'] === '') $info['owner_handle'] = OPENPROVIDER['owner_handle'];
|
| 176 | 177 | if (!isset($info['admin_handle']) || $info['admin_handle'] === '') $info['admin_handle'] = OPENPROVIDER['owner_handle'];
|
| 177 | 178 | if (!isset($info['tech_handle']) || $info['tech_handle'] === '') $info['tech_handle'] = OPENPROVIDER['owner_handle'];
|
| | @@ -210,27 +211,27 @@ |
| 210 | 211 | $curl = $this->setupCurl('/domains/', 'POST', $payload);
|
| 211 | 212 | kys('TODO');
|
| 212 | 213 | $res = $this->curlResult($curl);
|
| 213 | | - if (isset($res['data'])) return \Result::Success('', $res);
|
| 214 | + if (isset($res['data'])) return Result::Success('', $res);
|
| 214 | 215 |
|
| 215 | | - return \Result::Error('ドメインの確認に失敗。');
|
| 216 | + return Result::Error('ドメインの確認に失敗。');
|
| 216 | 217 | }
|
| 217 | 218 |
|
| 218 | | - /***
|
| 219 | + /**
|
| 219 | 220 | * ドメインを登録可能かどうかの確認。
|
| 220 | 221 | *
|
| 221 | 222 | * @param array $domains ドメイン名リスト。例:['076.moe', '076.co.jp', '076.com']
|
| 222 | 223 | * @param bool $with_price 値段を表示するかどうか。デフォルトは「false」
|
| 223 | 224 | * @return Result 結果。配列の場合:'domain'と'status'はいつでもあり、'reason', 'premium', 'is_premium'が多分あり、そして'price'が「with_price」が「true」の場合のみ。
|
| 224 | 225 | */
|
| 225 | | - public function checkDomainAvailable(array $domains, bool $with_price = false): \Result {
|
| 226 | | - if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
|
| 226 | + public function checkDomainAvailable(array $domains, bool $with_price = false): Result {
|
| 227 | + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
|
| 227 | 228 | $domainList = [];
|
| 228 | 229 | foreach ($domains as $d) {
|
| 229 | 230 | $domain = explode('.', $d);
|
| 230 | 231 | assert_exists($domain[0]);
|
| 231 | 232 | assert_exists($domain[1]);
|
| 232 | 233 | if (count($domain) !== 2) {
|
| 233 | | - return \Result::Error("不正なドメイン形: {$d}");
|
| 234 | + return Result::Error("不正なドメイン形: {$d}");
|
| 234 | 235 | }
|
| 235 | 236 |
|
| 236 | 237 | $domainList[] = [
|
| | @@ -246,9 +247,9 @@ |
| 246 | 247 |
|
| 247 | 248 | $curl = $this->setupCurl('/domains/check', 'POST', $payload);
|
| 248 | 249 | $res = $this->curlResult($curl);
|
| 249 | | - if (isset($res->data['data']['results'])) return \Result::Success('', $res->data['data']['results']);
|
| 250 | + if (isset($res->data['data']['results'])) return Result::Success('', $res->data['data']['results']);
|
| 250 | 251 |
|
| 251 | | - return \Result::Error('ドメインの確認に失敗。');
|
| 252 | + return Result::Error('ドメインの確認に失敗。');
|
| 252 | 253 | }
|
| 253 | 254 |
|
| 254 | 255 | //// 追加データ
|
| | @@ -260,8 +261,8 @@ |
| 260 | 261 | * @param array $query 検索クエリー
|
| 261 | 262 | * @return Result
|
| 262 | 263 | */
|
| 263 | | - public function getDomainAdditionalData(array $query): \Result {
|
| 264 | | - if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
|
| 264 | + public function getDomainAdditionalData(array $query): Result {
|
| 265 | + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
|
| 265 | 266 | $name = '';
|
| 266 | 267 | $ext = '';
|
| 267 | 268 | if (isset($query['domain.name'])) $name = $query['domain.name'];
|
| | @@ -269,17 +270,17 @@ |
| 269 | 270 | $cacheName = $name && $ext ? "domainadditionaldata-{$name}.{$ext}" : 'domainadditionaldata';
|
| 270 | 271 |
|
| 271 | 272 | $cache = $this->getCache($cacheName);
|
| 272 | | - if ($this->isValidLifespan($cache)) return \Result::Success('', $cache);
|
| 273 | + if ($this->isValidLifespan($cache)) return Result::Success('', $cache);
|
| 273 | 274 |
|
| 274 | 275 | $uri = "/domains/additional-data?".http_build_query($query, '', '&', PHP_QUERY_RFC3986);
|
| 275 | 276 | $curl = $this->setupCurl($uri);
|
| 276 | 277 | $res = $this->curlResult($curl);
|
| 277 | 278 | if (isset($res->data['data'])) {
|
| 278 | 279 | $this->setCache($cacheName, $res->data);
|
| 279 | | - return \Result::Success('', $res->data);
|
| 280 | + return Result::Success('', $res->data);
|
| 280 | 281 | }
|
| 281 | 282 |
|
| 282 | | - return \Result::Error('ドメインの追加データの受け取りに失敗。');
|
| 283 | + return Result::Error('ドメインの追加データの受け取りに失敗。');
|
| 283 | 284 | }
|
| 284 | 285 |
|
| 285 | 286 | //// 顧客様の追加データ
|
| | @@ -291,8 +292,8 @@ |
| 291 | 292 | * @param array $query 検索クエリー
|
| 292 | 293 | * @return Result
|
| 293 | 294 | */
|
| 294 | | - public function getDomainCustomerAdditionalData(array $query): \Result {
|
| 295 | | - if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
|
| 295 | + public function getDomainCustomerAdditionalData(array $query): Result {
|
| 296 | + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
|
| 296 | 297 | $name = '';
|
| 297 | 298 | $ext = '';
|
| 298 | 299 | if (isset($query['domain.name'])) $name = $query['domain.name'];
|
| | @@ -300,17 +301,17 @@ |
| 300 | 301 | $cacheName = $name && $ext ? "domainadditionaldata-{$name}.{$ext}" : 'domainadditionaldata';
|
| 301 | 302 |
|
| 302 | 303 | $cache = $this->getCache($cacheName);
|
| 303 | | - if ($this->isValidLifespan($cache)) return \Result::Success('', $cache);
|
| 304 | + if ($this->isValidLifespan($cache)) return Result::Success('', $cache);
|
| 304 | 305 |
|
| 305 | 306 | $uri = "/domains/additional-data/customers?".http_build_query($query, '', '&', PHP_QUERY_RFC3986);
|
| 306 | 307 | $curl = $this->setupCurl($uri);
|
| 307 | 308 | $res = $this->curlResult($curl);
|
| 308 | 309 | if (isset($res->data['data'])) {
|
| 309 | 310 | $this->setCache($cacheName, $res->data);
|
| 310 | | - return \Result::Success('', $res->data);
|
| 311 | + return Result::Success('', $res->data);
|
| 311 | 312 | }
|
| 312 | 313 |
|
| 313 | | - return \Result::Error('ドメインの顧客様の追加データの受け取りに失敗。');
|
| 314 | + return Result::Error('ドメインの顧客様の追加データの受け取りに失敗。');
|
| 314 | 315 | }
|
| 315 | 316 |
|
| 316 | 317 |
|
| | @@ -322,8 +323,8 @@ |
| 322 | 323 | * @param array $query 検索クエリー
|
| 323 | 324 | * @return Result
|
| 324 | 325 | */
|
| 325 | | - public function getDomainPrices(array $query): \Result {
|
| 326 | | - if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
|
| 326 | + public function getDomainPrices(array $query): Result {
|
| 327 | + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
|
| 327 | 328 | $name = '';
|
| 328 | 329 | $ext = '';
|
| 329 | 330 | if (isset($query['domain.name'])) $name = $query['domain.name'];
|
| | @@ -331,60 +332,62 @@ |
| 331 | 332 | $cacheName = $name && $ext ? "domainprices-{$name}.{$ext}" : 'domainprices';
|
| 332 | 333 |
|
| 333 | 334 | $cache = $this->getCache($cacheName);
|
| 334 | | - if ($this->isValidLifespan($cache)) return \Result::Success('', $cache);
|
| 335 | + if ($this->isValidLifespan($cache)) return Result::Success('', $cache);
|
| 335 | 336 |
|
| 336 | 337 | $uri = "/domains/prices?".http_build_query($query, '', '&', PHP_QUERY_RFC3986);
|
| 337 | 338 | $curl = $this->setupCurl($uri);
|
| 338 | 339 | $res = $this->curlResult($curl);
|
| 339 | 340 | if (isset($res->data['data'])) {
|
| 340 | 341 | $this->setCache($cacheName, $res->data);
|
| 341 | | - return \Result::Success('', $res->data);
|
| 342 | + return Result::Success('', $res->data);
|
| 342 | 343 | }
|
| 343 | 344 |
|
| 344 | | - return \Result::Error('TLD一覧の受け取りに失敗。');
|
| 345 | + return Result::Error('TLD一覧の受け取りに失敗。');
|
| 345 | 346 | }
|
| 346 | 347 |
|
| 347 | 348 | //// 認証コード
|
| 348 | 349 |
|
| 349 | 350 | /**
|
| 350 | 351 | * 認証コードの受け取り
|
| 352 | + * @todo テスト
|
| 351 | 353 | *
|
| 352 | 354 | * @param int $id ドメイン名ID
|
| 353 | 355 | * @param array $query 検索クエリー
|
| 354 | 356 | * @return Result
|
| 355 | 357 | */
|
| 356 | | - public function getAuthCode(int $id, array $query = []): \Result {
|
| 357 | | - if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
|
| 358 | + public function getAuthCode(int $id, array $query = []): Result {
|
| 359 | + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
|
| 358 | 360 |
|
| 359 | 361 | $uri = "/domains/{$id}/authcode?".http_build_query($query, '', '&', PHP_QUERY_RFC3986);
|
| 360 | 362 | $curl = $this->setupCurl($uri);
|
| 361 | 363 | $res = $this->curlResult($curl);
|
| 362 | 364 | if (isset($res->data['data'])) {
|
| 363 | | - return \Result::Success('', $res->data);
|
| 365 | + return Result::Success('', $res->data);
|
| 364 | 366 | }
|
| 365 | 367 |
|
| 366 | | - return \Result::Error('認証コードの受け取りに失敗。');
|
| 368 | + return Result::Error('認証コードの受け取りに失敗。');
|
| 367 | 369 | }
|
| 368 | 370 |
|
| 369 | 371 | /**
|
| 370 | 372 | * 認証コードの再設定
|
| 373 | + * @todo テスト
|
| 371 | 374 | *
|
| 372 | 375 | * @param int $id ドメイン名ID
|
| 373 | 376 | * @param array $payload フォームデータ
|
| 374 | 377 | * @return Result
|
| 375 | 378 | */
|
| 376 | | - public function resetAuthCode(int $id, array $payload = []): \Result {
|
| 377 | | - if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
|
| 379 | + public function resetAuthCode(int $id, array $payload = []): Result {
|
| 380 | + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
|
| 378 | 381 |
|
| 379 | 382 | $uri = "/domains/{$id}/authcode/reset";
|
| 380 | 383 | $curl->setupCurl($uri, 'POST', $payload);
|
| 381 | 384 | $res = $this->curlResult($curl);
|
| 382 | 385 | kys($res);
|
| 383 | 386 | if (isset($res)) {
|
| 384 | | - return \Result::Success('', $res->data);
|
| 387 | + return Result::Success('', $res->data);
|
| 385 | 388 | }
|
| 386 | 389 |
|
| 387 | | - return \Result::Error("認証コードの再設定に失敗。");
|
| 390 | + return Result::Error("認証コードの再設定に失敗。");
|
| 388 | 391 | }
|
| 389 | 392 |
|
| 390 | 393 | //// TLD
|
| | @@ -395,10 +398,10 @@ |
| 395 | 398 | * @param array $query 検索クエリー
|
| 396 | 399 | * @return Result
|
| 397 | 400 | */
|
| 398 | | - public function listTlds(array $query = []): \Result {
|
| 399 | | - if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
|
| 401 | + public function listTlds(array $query = []): Result {
|
| 402 | + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
|
| 400 | 403 | $cache = $this->getCache('listtlds');
|
| 401 | | - if ($this->isValidLifespan($cache)) return \Result::Success('', $cache);
|
| 404 | + if ($this->isValidLifespan($cache)) return Result::Success('', $cache);
|
| 402 | 405 |
|
| 403 | 406 | if (empty($query)) $query = [ 'limit' => 10, 'offset' => 0, 'order' => 'ASC' ];
|
| 404 | 407 | foreach ($query as $k => $v) if (is_bool($v)) $query[$k] = $v ? 'true' : 'false';
|
| | @@ -408,10 +411,10 @@ |
| 408 | 411 | $res = $this->curlResult($curl);
|
| 409 | 412 | if (isset($res->data['data'])) {
|
| 410 | 413 | $this->setCache('listtlds', $res->data);
|
| 411 | | - return \Result::Success('', $res->data);
|
| 414 | + return Result::Success('', $res->data);
|
| 412 | 415 | }
|
| 413 | 416 |
|
| 414 | | - return \Result::Error('TLD一覧の受け取りに失敗。');
|
| 417 | + return Result::Error('TLD一覧の受け取りに失敗。');
|
| 415 | 418 | }
|
| 416 | 419 |
|
| 417 | 420 | /**
|
| | @@ -421,11 +424,11 @@ |
| 421 | 424 | * @param array $query 検索クエリー
|
| 422 | 425 | * @return Result
|
| 423 | 426 | */
|
| 424 | | - public function getTld(string $tld, array $query = []): \Result {
|
| 425 | | - if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
|
| 427 | + public function getTld(string $tld, array $query = []): Result {
|
| 428 | + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
|
| 426 | 429 | $cacheName = "gettld-{$tld}";
|
| 427 | 430 | $cache = $this->getCache($cacheName);
|
| 428 | | - if ($this->isValidLifespan($cache)) return \Result::Success('', $cache);
|
| 431 | + if ($this->isValidLifespan($cache)) return Result::Success('', $cache);
|
| 429 | 432 |
|
| 430 | 433 | if (empty($query)) $query = [ 'limit' => 10, 'offset' => 0 ];
|
| 431 | 434 | foreach ($query as $k => $v) if (is_bool($v)) $query[$k] = $v ? 'true' : 'false';
|
| | @@ -435,10 +438,10 @@ |
| 435 | 438 | $res = $this->curlResult($curl);
|
| 436 | 439 | if (isset($res->data['data'])) {
|
| 437 | 440 | $this->setCache($cacheName, $res->data);
|
| 438 | | - return \Result::Success('', $res->data);
|
| 441 | + return Result::Success('', $res->data);
|
| 439 | 442 | }
|
| 440 | 443 |
|
| 441 | | - return \Result::Error('TLD一覧の受け取りに失敗。');
|
| 444 | + return Result::Error('TLD一覧の受け取りに失敗。');
|
| 442 | 445 | }
|
| 443 | 446 |
|
| 444 | 447 | // 請求
|
| | @@ -451,11 +454,11 @@ |
| 451 | 454 | * @param array $query 検索クエリー
|
| 452 | 455 | * @return Result
|
| 453 | 456 | */
|
| 454 | | - public function listInvoices(array $query = []): \Result {
|
| 455 | | - if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
|
| 457 | + public function listInvoices(array $query = []): Result {
|
| 458 | + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
|
| 456 | 459 | $cacheName = 'listinvoices';
|
| 457 | 460 | $cache = $this->getCache($cacheName);
|
| 458 | | - if ($this->isValidLifespan($cache)) return \Result::Success('', $cache);
|
| 461 | + if ($this->isValidLifespan($cache)) return Result::Success('', $cache);
|
| 459 | 462 |
|
| 460 | 463 | if (empty($query)) $query = [ 'limit' => 10, 'offset' => 0 ];
|
| 461 | 464 | foreach ($query as $k => $v) if (is_bool($v)) $query[$k] = $v ? 'true' : 'false';
|
| | @@ -465,10 +468,10 @@ |
| 465 | 468 | $res = $this->curlResult($curl);
|
| 466 | 469 | if (isset($res->data['data'])) {
|
| 467 | 470 | $this->setCache($cacheName, $res->data);
|
| 468 | | - return \Result::Success('', $res->data);
|
| 471 | + return Result::Success('', $res->data);
|
| 469 | 472 | }
|
| 470 | 473 |
|
| 471 | | - return \Result::Error('請求書一覧の受け取りに請求書');
|
| 474 | + return Result::Error('請求書一覧の受け取りに請求書');
|
| 472 | 475 | }
|
| 473 | 476 |
|
| 474 | 477 | //// 支払
|
| | @@ -480,11 +483,11 @@ |
| 480 | 483 | * @param array $query 検索クエリー
|
| 481 | 484 | * @return Result
|
| 482 | 485 | */
|
| 483 | | - public function listPayments(array $query = []): \Result {
|
| 484 | | - if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
|
| 486 | + public function listPayments(array $query = []): Result {
|
| 487 | + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
|
| 485 | 488 | $cacheName = 'listpayments';
|
| 486 | 489 | $cache = $this->getCache($cacheName);
|
| 487 | | - if ($this->isValidLifespan($cache)) return \Result::Success('', $cache);
|
| 490 | + if ($this->isValidLifespan($cache)) return Result::Success('', $cache);
|
| 488 | 491 |
|
| 489 | 492 | if (empty($query)) $query = [ 'limit' => 10, 'offset' => 0 ];
|
| 490 | 493 | foreach ($query as $k => $v) if (is_bool($v)) $query[$k] = $v ? 'true' : 'false';
|
| | @@ -494,10 +497,10 @@ |
| 494 | 497 | $res = $this->curlResult($curl);
|
| 495 | 498 | if (isset($res->data['data'])) {
|
| 496 | 499 | $this->setCache($cacheName, $res->data);
|
| 497 | | - return \Result::Success('', $res->data);
|
| 500 | + return Result::Success('', $res->data);
|
| 498 | 501 | }
|
| 499 | 502 |
|
| 500 | | - return \Result::Error('支払一覧の受け取りに失敗。');
|
| 503 | + return Result::Error('支払一覧の受け取りに失敗。');
|
| 501 | 504 | }
|
| 502 | 505 |
|
| 503 | 506 | //// トランザクション
|
| | @@ -509,11 +512,11 @@ |
| 509 | 512 | * @param array $query 検索クエリー
|
| 510 | 513 | * @return Result
|
| 511 | 514 | */
|
| 512 | | - public function listTransactions(array $query = []): \Result {
|
| 513 | | - if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
|
| 515 | + public function listTransactions(array $query = []): Result {
|
| 516 | + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
|
| 514 | 517 | $cacheName = 'listtransactions';
|
| 515 | 518 | $cache = $this->getCache($cacheName);
|
| 516 | | - if ($this->isValidLifespan($cache)) return \Result::Success('', $cache);
|
| 519 | + if ($this->isValidLifespan($cache)) return Result::Success('', $cache);
|
| 517 | 520 |
|
| 518 | 521 | if (empty($query)) $query = [ 'limit' => 10, 'offset' => 0 ];
|
| 519 | 522 | foreach ($query as $k => $v) if (is_bool($v)) $query[$k] = $v ? 'true' : 'false';
|
| | @@ -523,10 +526,10 @@ |
| 523 | 526 | $res = $this->curlResult($curl);
|
| 524 | 527 | if (isset($res->data['data'])) {
|
| 525 | 528 | $this->setCache($cacheName, $res->data);
|
| 526 | | - return \Result::Success('', $res->data);
|
| 529 | + return Result::Success('', $res->data);
|
| 527 | 530 | }
|
| 528 | 531 |
|
| 529 | | - return \Result::Error('トランザクション一覧の受け取りに失敗。');
|
| 532 | + return Result::Error('トランザクション一覧の受け取りに失敗。');
|
| 530 | 533 | }
|
| 531 | 534 |
|
| 532 | 535 | // DNS
|
| | @@ -539,17 +542,17 @@ |
| 539 | 542 | * @param array $payload フォームデータ
|
| 540 | 543 | * @return Result
|
| 541 | 544 | */
|
| 542 | | - public function createDomainToken(array $payload = []): \Result {
|
| 543 | | - if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
|
| 545 | + public function createDomainToken(array $payload = []): Result {
|
| 546 | + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
|
| 544 | 547 |
|
| 545 | 548 | $uri = '/dns/domain-token';
|
| 546 | 549 | $curl = $this->setupCurl($uri, 'POST', $payload);
|
| 547 | 550 | $res = $this->curlResult($curl);
|
| 548 | 551 | if (isset($res->data['data'])) {
|
| 549 | | - return \Result::Success('DNSテンプレートの追加に成功。', $res->data);
|
| 552 | + return Result::Success('DNSテンプレートの追加に成功。', $res->data);
|
| 550 | 553 | }
|
| 551 | 554 |
|
| 552 | | - return \Result::Error('DNSテンプレートの追加に失敗。');
|
| 555 | + return Result::Error('DNSテンプレートの追加に失敗。');
|
| 553 | 556 | }
|
| 554 | 557 |
|
| 555 | 558 | //// ネームサーバー
|
| | @@ -563,11 +566,11 @@ |
| 563 | 566 | * @param array $query 検索クエリー
|
| 564 | 567 | * @return Result
|
| 565 | 568 | */
|
| 566 | | - public function listDnsTemplate(array $query = []): \Result {
|
| 567 | | - if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
|
| 569 | + public function listDnsTemplate(array $query = []): Result {
|
| 570 | + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
|
| 568 | 571 | $cacheName = 'listdnstemplates';
|
| 569 | 572 | $cache = $this->getCache($cacheName);
|
| 570 | | - if ($this->isValidLifespan($cache, $query)) return \Result::Success('', $cache);
|
| 573 | + if ($this->isValidLifespan($cache, $query)) return Result::Success('', $cache);
|
| 571 | 574 |
|
| 572 | 575 | foreach ($query as $k => $v) { if (is_bool($v)) $query[$k] = $v ? 'true' : 'false'; }
|
| 573 | 576 | $uri = '/dns/templates?'.http_build_query($query, '', '&', PHP_QUERY_RFC3986);
|
| | @@ -576,10 +579,10 @@ |
| 576 | 579 | if (isset($res->data['data'])) {
|
| 577 | 580 | $res->data['query'] = $query;
|
| 578 | 581 | $this->setCache($cacheName, $res->data);
|
| 579 | | - return \Result::Success('', $res->data);
|
| 582 | + return Result::Success('', $res->data);
|
| 580 | 583 | }
|
| 581 | 584 |
|
| 582 | | - return \Result::Error('DNSテンプレート一覧の受け取りに失敗。');
|
| 585 | + return Result::Error('DNSテンプレート一覧の受け取りに失敗。');
|
| 583 | 586 | }
|
| 584 | 587 |
|
| 585 | 588 | /**
|
| | @@ -589,18 +592,18 @@ |
| 589 | 592 | * @param array $payload フォームデータ
|
| 590 | 593 | * @return Result
|
| 591 | 594 | */
|
| 592 | | - public function createDnsTemplate(array $payload = []): \Result {
|
| 593 | | - if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
|
| 595 | + public function createDnsTemplate(array $payload = []): Result {
|
| 596 | + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
|
| 594 | 597 |
|
| 595 | 598 | $uri = '/dns/templates';
|
| 596 | 599 | $curl = $this->setupCurl($uri, 'POST', $payload);
|
| 597 | 600 | $res = $this->curlResult($curl);
|
| 598 | 601 | if (isset($res->data['data'])) {
|
| 599 | 602 | $this->murderCache('listdnstemplates');
|
| 600 | | - return \Result::Success('DNSテンプレートの追加に成功。', $res->data);
|
| 603 | + return Result::Success('DNSテンプレートの追加に成功。', $res->data);
|
| 601 | 604 | }
|
| 602 | 605 |
|
| 603 | | - return \Result::Error('DNSテンプレートの追加に失敗。');
|
| 606 | + return Result::Error('DNSテンプレートの追加に失敗。');
|
| 604 | 607 | }
|
| 605 | 608 |
|
| 606 | 609 | /**
|
| | @@ -610,21 +613,21 @@ |
| 610 | 613 | * @param int $id DNSテンプレートID
|
| 611 | 614 | * @return Result
|
| 612 | 615 | */
|
| 613 | | - public function getDnsTemplate(int $id): \Result {
|
| 614 | | - if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
|
| 616 | + public function getDnsTemplate(int $id): Result {
|
| 617 | + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
|
| 615 | 618 | $cacheName = "getdnstemplate-{$id}";
|
| 616 | 619 | $cache = $this->getCache($cacheName);
|
| 617 | | - if ($this->isValidLifespan($cache, $query)) return \Result::Success('', $cache);
|
| 620 | + if ($this->isValidLifespan($cache, $query)) return Result::Success('', $cache);
|
| 618 | 621 |
|
| 619 | 622 | $uri = "/dns/templates/{$id}";
|
| 620 | 623 | $curl = $this->setupCurl($uri);
|
| 621 | 624 | $res = $this->curlResult($curl);
|
| 622 | 625 | if (isset($res->data['data'])) {
|
| 623 | 626 | $this->setCache($cacheName, $res->data);
|
| 624 | | - return \Result::Success('', $res->data);
|
| 627 | + return Result::Success('', $res->data);
|
| 625 | 628 | }
|
| 626 | 629 |
|
| 627 | | - return \Result::Error('DNSテンプレートの更新に失敗。');
|
| 630 | + return Result::Error('DNSテンプレートの更新に失敗。');
|
| 628 | 631 | }
|
| 629 | 632 |
|
| 630 | 633 | /**
|
| | @@ -634,18 +637,18 @@ |
| 634 | 637 | * @param int $id DNSテンプレートID
|
| 635 | 638 | * @return Result
|
| 636 | 639 | */
|
| 637 | | - public function deleteDnsTemplate(int $id): \Result {
|
| 638 | | - if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
|
| 640 | + public function deleteDnsTemplate(int $id): Result {
|
| 641 | + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
|
| 639 | 642 |
|
| 640 | 643 | $uri = "/dns/templates/{$id}";
|
| 641 | 644 | $curl = $this->setupCurl($uri, 'DELETE');
|
| 642 | 645 | $res = $this->curlResult($curl);
|
| 643 | 646 | if (isset($res->data['data'])) {
|
| 644 | 647 | $this->murderCache('listdnstemplates');
|
| 645 | | - if ($res->data['data']['success']) return \Result::Success('DNSテンプレートの削除に成功。', $res->data);
|
| 648 | + if ($res->data['data']['success']) return Result::Success('DNSテンプレートの削除に成功。', $res->data);
|
| 646 | 649 | }
|
| 647 | 650 |
|
| 648 | | - return \Result::Error('DNSテンプレートの削除に失敗。');
|
| 651 | + return Result::Error('DNSテンプレートの削除に失敗。');
|
| 649 | 652 | }
|
| 650 | 653 |
|
| 651 | 654 | //// ゾーン
|
| | @@ -656,10 +659,10 @@ |
| 656 | 659 | * @param array $query
|
| 657 | 660 | * @return Result
|
| 658 | 661 | */
|
| 659 | | - public function listDnsZones(array $query = []): \Result {
|
| 660 | | - if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
|
| 662 | + public function listDnsZones(array $query = []): Result {
|
| 663 | + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
|
| 661 | 664 | $cache = $this->getCache('listdnszones');
|
| 662 | | - if ($this->isValidLifespan($cache, $query)) return \Result::Success('', $cache);
|
| 665 | + if ($this->isValidLifespan($cache, $query)) return Result::Success('', $cache);
|
| 663 | 666 |
|
| 664 | 667 | if (empty($query)) $query = [ 'limit' => 25, 'offset' => 0, 'order_by.name' => 'asc' ];
|
| 665 | 668 | foreach ($query as $k => $v) if (is_bool($v)) $query[$k] = $v ? 'true' : 'false';
|
| | @@ -669,10 +672,10 @@ |
| 669 | 672 | $res = $this->curlResult($curl);
|
| 670 | 673 | if (isset($res->data['data'])) {
|
| 671 | 674 | $this->setCache('listdnszones', $res->data);
|
| 672 | | - return \Result::Success('', $res->data);
|
| 675 | + return Result::Success('', $res->data);
|
| 673 | 676 | }
|
| 674 | 677 |
|
| 675 | | - return \Result::Error('TLD一覧の受け取りに失敗。');
|
| 678 | + return Result::Error('TLD一覧の受け取りに失敗。');
|
| 676 | 679 | }
|
| 677 | 680 |
|
| 678 | 681 | /**
|
| | @@ -682,10 +685,10 @@ |
| 682 | 685 | * @param array $query 検索クエリー
|
| 683 | 686 | * @return Result
|
| 684 | 687 | */
|
| 685 | | - public function getDnsZone(string $domain, array $query = []): \Result {
|
| 686 | | - if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
|
| 688 | + public function getDnsZone(string $domain, array $query = []): Result {
|
| 689 | + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
|
| 687 | 690 | $cache = $this->getCache("getdnszone-{$domain}");
|
| 688 | | - if ($this->isValidLifespan($cache)) return \Result::Success('', $cache);
|
| 691 | + if ($this->isValidLifespan($cache)) return Result::Success('', $cache);
|
| 689 | 692 |
|
| 690 | 693 | if (empty($query)) $query = [ 'limit' => 100, 'offset' => 0, 'order_by.name' => 'asc' ];
|
| 691 | 694 | foreach ($query as $k => $v) if (is_bool($v)) $query[$k] = $v ? 'true' : 'false';
|
| | @@ -695,10 +698,10 @@ |
| 695 | 698 | $res = $this->curlResult($curl);
|
| 696 | 699 | if (isset($res->data['data'])) {
|
| 697 | 700 | $this->setCache("getdnszone-{$domain}", $res->data);
|
| 698 | | - return \Result::Success('', $res->data);
|
| 701 | + return Result::Success('', $res->data);
|
| 699 | 702 | }
|
| 700 | 703 |
|
| 701 | | - return \Result::Error('TLD一覧の受け取りに失敗。');
|
| 704 | + return Result::Error('TLD一覧の受け取りに失敗。');
|
| 702 | 705 | }
|
| 703 | 706 |
|
| 704 | 707 | //// ゾーンレコード
|
| | @@ -709,19 +712,19 @@ |
| 709 | 712 | * @param string $domain
|
| 710 | 713 | * @return Result
|
| 711 | 714 | */
|
| 712 | | - public function listZoneRecords(string $domain): \Result {
|
| 713 | | - if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
|
| 715 | + public function listZoneRecords(string $domain): Result {
|
| 716 | + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
|
| 714 | 717 | $cache = $this->getCache("getzonerecords-{$domain}");
|
| 715 | | - if ($this->isValidLifespan($cache)) return \Result::Success('', $cache);
|
| 718 | + if ($this->isValidLifespan($cache)) return Result::Success('', $cache);
|
| 716 | 719 |
|
| 717 | 720 | $curl = $this->setupCurl("/dns/zones/{$domain}/records");
|
| 718 | 721 | $res = $this->curlResult($curl);
|
| 719 | 722 | if (isset($res->data['data'])) {
|
| 720 | 723 | $this->setCache("getzonerecords-{$domain}", $res->data);
|
| 721 | | - return \Result::Success('', $res->data);
|
| 724 | + return Result::Success('', $res->data);
|
| 722 | 725 | }
|
| 723 | 726 |
|
| 724 | | - return \Result::Error('TLD一覧の受け取りに失敗。');
|
| 727 | + return Result::Error('TLD一覧の受け取りに失敗。');
|
| 725 | 728 | }
|
| 726 | 729 |
|
| 727 | 730 | // Easydmarc
|
| | @@ -737,11 +740,11 @@ |
| 737 | 740 | * @param array $query 検索クエリー
|
| 738 | 741 | * @return Result
|
| 739 | 742 | */
|
| 740 | | - public function listEmails(array $query = []): \Result {
|
| 741 | | - if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
|
| 743 | + public function listEmails(array $query = []): Result {
|
| 744 | + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
|
| 742 | 745 | $cacheName = 'listemails';
|
| 743 | 746 | $cache = $this->getCache($cacheName);
|
| 744 | | - if ($this->isValidLifespan($cache, $query)) return \Result::Success('', $cache);
|
| 747 | + if ($this->isValidLifespan($cache, $query)) return Result::Success('', $cache);
|
| 745 | 748 |
|
| 746 | 749 | foreach ($query as $k => $v) { if (is_bool($v)) $query[$k] = $v ? 'true' : 'false'; }
|
| 747 | 750 | $uri = '/emails?'.http_build_query($query, '', '&', PHP_QUERY_RFC3986);
|
| | @@ -750,10 +753,10 @@ |
| 750 | 753 | if (isset($res->data['data'])) {
|
| 751 | 754 | $res->data['query'] = $query;
|
| 752 | 755 | $this->setCache($cacheName, $res->data);
|
| 753 | | - return \Result::Success('', $res->data);
|
| 756 | + return Result::Success('', $res->data);
|
| 754 | 757 | }
|
| 755 | 758 |
|
| 756 | | - return \Result::Error('メールテンプレート一覧の受け取りに失敗。');
|
| 759 | + return Result::Error('メールテンプレート一覧の受け取りに失敗。');
|
| 757 | 760 | }
|
| 758 | 761 |
|
| 759 | 762 | /**
|
| | @@ -763,18 +766,18 @@ |
| 763 | 766 | * @param array $payload フォームデータ
|
| 764 | 767 | * @return Result
|
| 765 | 768 | */
|
| 766 | | - public function createEmail(array $payload = []): \Result {
|
| 767 | | - if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
|
| 769 | + public function createEmail(array $payload = []): Result {
|
| 770 | + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
|
| 768 | 771 |
|
| 769 | 772 | $uri = '/emails';
|
| 770 | 773 | $curl = $this->setupCurl($uri, 'POST', $payload);
|
| 771 | 774 | $res = $this->curlResult($curl);
|
| 772 | 775 | if (isset($res->data['data'])) {
|
| 773 | 776 | $this->murderCache('listemails');
|
| 774 | | - return \Result::Success('メールテンプレートの追加に成功。', $res->data);
|
| 777 | + return Result::Success('メールテンプレートの追加に成功。', $res->data);
|
| 775 | 778 | }
|
| 776 | 779 |
|
| 777 | | - return \Result::Error('メールテンプレートの追加に失敗。');
|
| 780 | + return Result::Error('メールテンプレートの追加に失敗。');
|
| 778 | 781 | }
|
| 779 | 782 |
|
| 780 | 783 | /**
|
| | @@ -785,18 +788,18 @@ |
| 785 | 788 | * @param array $payload フォームデータ
|
| 786 | 789 | * @return Result
|
| 787 | 790 | */
|
| 788 | | - public function updateEmail(int $id, array $payload = []): \Result {
|
| 789 | | - if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
|
| 791 | + public function updateEmail(int $id, array $payload = []): Result {
|
| 792 | + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
|
| 790 | 793 |
|
| 791 | 794 | $uri = "/emails/{$id}";
|
| 792 | 795 | $curl = $this->setupCurl($uri, 'PUT', $payload);
|
| 793 | 796 | $res = $this->curlResult($curl);
|
| 794 | 797 | if (isset($res->data['data'])) {
|
| 795 | 798 | $this->murderCache('listemails');
|
| 796 | | - if ($res->data['data']['success']) return \Result::Success('メールテンプレートの更新に成功。', $res->data);
|
| 799 | + if ($res->data['data']['success']) return Result::Success('メールテンプレートの更新に成功。', $res->data);
|
| 797 | 800 | }
|
| 798 | 801 |
|
| 799 | | - return \Result::Error('メールテンプレートの更新に失敗。');
|
| 802 | + return Result::Error('メールテンプレートの更新に失敗。');
|
| 800 | 803 | }
|
| 801 | 804 |
|
| 802 | 805 | /**
|
| | @@ -806,18 +809,18 @@ |
| 806 | 809 | * @param int $id メールテンプレートID
|
| 807 | 810 | * @return Result
|
| 808 | 811 | */
|
| 809 | | - public function deleteEmail(int $id): \Result {
|
| 810 | | - if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
|
| 812 | + public function deleteEmail(int $id): Result {
|
| 813 | + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
|
| 811 | 814 |
|
| 812 | 815 | $uri = "/emails/{$id}";
|
| 813 | 816 | $curl = $this->setupCurl($uri, 'DELETE');
|
| 814 | 817 | $res = $this->curlResult($curl);
|
| 815 | 818 | if (isset($res->data['data'])) {
|
| 816 | 819 | $this->murderCache('listemails');
|
| 817 | | - if ($res->data['data']['success']) return \Result::Success('メールテンプレートの削除に成功。', $res->data);
|
| 820 | + if ($res->data['data']['success']) return Result::Success('メールテンプレートの削除に成功。', $res->data);
|
| 818 | 821 | }
|
| 819 | 822 |
|
| 820 | | - return \Result::Error('メールテンプレートの削除に失敗。');
|
| 823 | + return Result::Error('メールテンプレートの削除に失敗。');
|
| 821 | 824 | }
|
| 822 | 825 |
|
| 823 | 826 | // ライセンス
|
| | @@ -834,11 +837,11 @@ |
| 834 | 837 | * @param array $query 検索クエリー
|
| 835 | 838 | * @return Result
|
| 836 | 839 | */
|
| 837 | | - public function listCustomers(array $query = []): \Result {
|
| 838 | | - if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
|
| 840 | + public function listCustomers(array $query = []): Result {
|
| 841 | + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
|
| 839 | 842 | $cacheName = 'listcustomers';
|
| 840 | 843 | $cache = $this->getCache($cacheName);
|
| 841 | | - if ($this->isValidLifespan($cache, $query)) return \Result::Success('', $cache);
|
| 844 | + if ($this->isValidLifespan($cache, $query)) return Result::Success('', $cache);
|
| 842 | 845 |
|
| 843 | 846 | foreach ($query as $k => $v) { if (is_bool($v)) $query[$k] = $v ? 'true' : 'false'; }
|
| 844 | 847 | $uri = '/customers?'.http_build_query($query, '', '&', PHP_QUERY_RFC3986);
|
| | @@ -847,10 +850,10 @@ |
| 847 | 850 | if (isset($res->data['data'])) {
|
| 848 | 851 | $res->data['query'] = $query;
|
| 849 | 852 | $this->setCache($cacheName, $res->data);
|
| 850 | | - return \Result::Success('', $res->data);
|
| 853 | + return Result::Success('', $res->data);
|
| 851 | 854 | }
|
| 852 | 855 |
|
| 853 | | - return \Result::Error('顧客様一覧の受け取りに失敗。');
|
| 856 | + return Result::Error('顧客様一覧の受け取りに失敗。');
|
| 854 | 857 | }
|
| 855 | 858 |
|
| 856 | 859 | /**
|
| | @@ -859,19 +862,18 @@ |
| 859 | 862 | * @param array $payload
|
| 860 | 863 | * @return Result
|
| 861 | 864 | */
|
| 862 | | - public function createCustomer(array $payload): \Result {
|
| 863 | | - if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
|
| 865 | + public function createCustomer(array $payload): Result {
|
| 866 | + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
|
| 864 | 867 |
|
| 865 | 868 | $uri = '/customers';
|
| 866 | | - $curl->setupCurl($uri, 'POST', $payload);
|
| 869 | + $curl = $this->setupCurl($uri, 'POST', $payload);
|
| 867 | 870 | $res = $this->curlResult($curl);
|
| 868 | | - kys($res);
|
| 869 | 871 | if (isset($res)) {
|
| 870 | 872 | $this->murderCache('listcustomers');
|
| 871 | | - return \Result::Success('', $res->data);
|
| 873 | + return Result::Success('', $res->data);
|
| 872 | 874 | }
|
| 873 | 875 |
|
| 874 | | - return \Result::Error("顧客様の作成に失敗。");
|
| 876 | + return Result::Error("顧客様の作成に失敗。");
|
| 875 | 877 | }
|
| 876 | 878 |
|
| 877 | 879 | /**
|
| | @@ -881,11 +883,11 @@ |
| 881 | 883 | * @param bool $withAdditionalData 詳細データ含むか?
|
| 882 | 884 | * @return Result
|
| 883 | 885 | */
|
| 884 | | - public function getCustomer(string $handle, bool $withAdditionalData = false): \Result {
|
| 885 | | - if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
|
| 886 | + public function getCustomer(string $handle, bool $withAdditionalData = false): Result {
|
| 887 | + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
|
| 886 | 888 | $cacheName = "getcustomer-{$handle}";
|
| 887 | 889 | $cache = $this->getCache($cacheName);
|
| 888 | | - if ($this->isValidLifespan($cache, $handle, 'handle')) return \Result::Success('', $cache);
|
| 890 | + if ($this->isValidLifespan($cache, $handle, 'handle')) return Result::Success('', $cache);
|
| 889 | 891 |
|
| 890 | 892 | $query = [ 'with_additional_data' => $withAdditionalData ? 'true' : 'false' ];
|
| 891 | 893 | $uri = "/customers/{$handle}?".http_build_query($query, '', '&', PHP_QUERY_RFC3986);
|
| | @@ -895,10 +897,10 @@ |
| 895 | 897 | if (isset($res->data['data'])) {
|
| 896 | 898 | $res->data['handle'] = $handle;
|
| 897 | 899 | $this->setCache($cacheName, $res->data);
|
| 898 | | - return \Result::Success('', $res->data);
|
| 900 | + return Result::Success('', $res->data);
|
| 899 | 901 | }
|
| 900 | 902 |
|
| 901 | | - return \Result::Error('顧客様の受け取りに失敗。');
|
| 903 | + return Result::Error('顧客様の受け取りに失敗。');
|
| 902 | 904 | }
|
| 903 | 905 |
|
| 904 | 906 | /**
|
| | @@ -909,39 +911,38 @@ |
| 909 | 911 | * @param array $payload フォームデータ
|
| 910 | 912 | * @return Result
|
| 911 | 913 | */
|
| 912 | | - public function updateCustomer(string $handle, array $payload = []): \Result {
|
| 913 | | - if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
|
| 914 | + public function updateCustomer(string $handle, array $payload = []): Result {
|
| 915 | + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
|
| 914 | 916 |
|
| 915 | 917 | $uri = "/customers/{$handle}";
|
| 916 | 918 | $curl = $this->setupCurl($uri, 'PUT', $payload);
|
| 917 | 919 | $res = $this->curlResult($curl);
|
| 918 | 920 | if (isset($res->data['data'])) {
|
| 919 | 921 | $this->murderCache('listcustomers');
|
| 920 | | - if ($res->data['data']['success']) return \Result::Success('顧客様の更新に成功。', $res->data);
|
| 922 | + if ($res->data['data']['success']) return Result::Success('顧客様の更新に成功。', $res->data);
|
| 921 | 923 | }
|
| 922 | 924 |
|
| 923 | | - return \Result::Error('顧客様の更新に失敗。');
|
| 925 | + return Result::Error('顧客様の更新に失敗。');
|
| 924 | 926 | }
|
| 925 | 927 |
|
| 926 | 928 | /**
|
| 927 | 929 | * 顧客様の削除
|
| 928 | | - * @todo テスト
|
| 929 | 930 | *
|
| 930 | 931 | * @param string $handle 顧客様のハンドル
|
| 931 | 932 | * @return Result
|
| 932 | 933 | */
|
| 933 | | - public function deleteCustomer(int $id): \Result {
|
| 934 | | - if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
|
| 934 | + public function deleteCustomer(string $handle): Result {
|
| 935 | + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
|
| 935 | 936 |
|
| 936 | 937 | $uri = "/customers/{$handle}";
|
| 937 | 938 | $curl = $this->setupCurl($uri, 'DELETE');
|
| 938 | 939 | $res = $this->curlResult($curl);
|
| 939 | 940 | if (isset($res->data['data'])) {
|
| 940 | 941 | $this->murderCache('listcustomers');
|
| 941 | | - if ($res->data['data']['success']) return \Result::Success('顧客様の削除に成功。', $res->data);
|
| 942 | + if ($res->data['data']['success']) return Result::Success('顧客様の削除に成功。');
|
| 942 | 943 | }
|
| 943 | 944 |
|
| 944 | | - return \Result::Error('顧客様の削除に失敗。');
|
| 945 | + return Result::Error('顧客様の削除に失敗。');
|
| 945 | 946 | }
|
| 946 | 947 |
|
| 947 | 948 | //// メール認証
|
| | @@ -953,11 +954,11 @@ |
| 953 | 954 | * @param array $query 検索クエリー
|
| 954 | 955 | * @return Result
|
| 955 | 956 | */
|
| 956 | | - public function listEmailVerifications(array $query = []): \Result {
|
| 957 | | - if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
|
| 957 | + public function listEmailVerifications(array $query = []): Result {
|
| 958 | + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
|
| 958 | 959 | $cacheName = 'listemailverifications';
|
| 959 | 960 | $cache = $this->getCache($cacheName);
|
| 960 | | - if ($this->isValidLifespan($cache, $query)) return \Result::Success('', $cache);
|
| 961 | + if ($this->isValidLifespan($cache, $query)) return Result::Success('', $cache);
|
| 961 | 962 |
|
| 962 | 963 | foreach ($query as $k => $v) { if (is_bool($v)) $query[$k] = $v ? 'true' : 'false'; }
|
| 963 | 964 | $uri = '/customers/verifications/emails/domains?'.http_build_query($query, '', '&', PHP_QUERY_RFC3986);
|
| | @@ -966,10 +967,10 @@ |
| 966 | 967 | if (isset($res->data['data'])) {
|
| 967 | 968 | $res->data['query'] = $query;
|
| 968 | 969 | $this->setCache($cacheName, $res->data);
|
| 969 | | - return \Result::Success('', $res->data);
|
| 970 | + return Result::Success('', $res->data);
|
| 970 | 971 | }
|
| 971 | 972 |
|
| 972 | | - return \Result::Error('メール認証一覧の受け取りに失敗。');
|
| 973 | + return Result::Error('メール認証一覧の受け取りに失敗。');
|
| 973 | 974 | }
|
| 974 | 975 |
|
| 975 | 976 | /**
|
| | @@ -979,18 +980,18 @@ |
| 979 | 980 | * @param string $email メールアドレス
|
| 980 | 981 | * @return Result
|
| 981 | 982 | */
|
| 982 | | - public function restartEmailVerifications(string $email, string $language = '', string $tag = ''): \Result {
|
| 983 | | - if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
|
| 983 | + public function restartEmailVerifications(string $email, string $language = '', string $tag = ''): Result {
|
| 984 | + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
|
| 984 | 985 |
|
| 985 | 986 | $uri = '/customers/verifications/emails/restart';
|
| 986 | 987 | $curl = $this->setupCurl($uri, 'POST', ['email' => $email, 'language' => $language, 'tag' => $tag]);
|
| 987 | 988 | $res = $this->curlResult($curl);
|
| 988 | 989 | if (isset($res->data['data'])) {
|
| 989 | 990 | $this->murderCache('listemailverifications');
|
| 990 | | - return \Result::Success('メール認証の再起動に成功。', $res->data);
|
| 991 | + return Result::Success('メール認証の再起動に成功。', $res->data);
|
| 991 | 992 | }
|
| 992 | 993 |
|
| 993 | | - return \Result::Error('メール認証の再起動に失敗。');
|
| 994 | + return Result::Error('メール認証の再起動に失敗。');
|
| 994 | 995 | }
|
| 995 | 996 |
|
| 996 | 997 | /**
|
| | @@ -1003,18 +1004,18 @@ |
| 1003 | 1004 | * @param string $tag タグ
|
| 1004 | 1005 | * @return Result
|
| 1005 | 1006 | */
|
| 1006 | | - public function startEmailVerifications(string $email, string $handle = '', string $language = '', string $tag = ''): \Result {
|
| 1007 | | - if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
|
| 1007 | + public function startEmailVerifications(string $email, string $handle = '', string $language = '', string $tag = ''): Result {
|
| 1008 | + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
|
| 1008 | 1009 |
|
| 1009 | 1010 | $uri = '/customers/verifications/emails/start';
|
| 1010 | 1011 | $curl = $this->setupCurl($uri, 'POST', ['email' => $email, 'handle' => $handle, 'language' => $language, 'tag' => $tag]);
|
| 1011 | 1012 | $res = $this->curlResult($curl);
|
| 1012 | 1013 | if (isset($res->data['data'])) {
|
| 1013 | 1014 | $this->murderCache('listemailverifications');
|
| 1014 | | - return \Result::Success('メール認証の起動に成功。', $res->data);
|
| 1015 | + return Result::Success('メール認証の起動に成功。', $res->data);
|
| 1015 | 1016 | }
|
| 1016 | 1017 |
|
| 1017 | | - return \Result::Error('メール認証の起動に失敗。');
|
| 1018 | + return Result::Error('メール認証の起動に失敗。');
|
| 1018 | 1019 | }
|
| 1019 | 1020 |
|
| 1020 | 1021 | //// リセラー
|
| | @@ -1026,11 +1027,11 @@ |
| 1026 | 1027 | * @param array $query 検索クエリー
|
| 1027 | 1028 | * @return Result
|
| 1028 | 1029 | */
|
| 1029 | | - public function getReseller(array $query = []): \Result {
|
| 1030 | | - if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
|
| 1030 | + public function getReseller(array $query = []): Result {
|
| 1031 | + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
|
| 1031 | 1032 | $cacheName = 'getreseller';
|
| 1032 | 1033 | $cache = $this->getCache($cacheName);
|
| 1033 | | - if ($this->isValidLifespan($cache, $query)) return \Result::Success('', $cache);
|
| 1034 | + if ($this->isValidLifespan($cache, $query)) return Result::Success('', $cache);
|
| 1034 | 1035 |
|
| 1035 | 1036 | foreach ($query as $k => $v) { if (is_bool($v)) $query[$k] = $v ? 'true' : 'false'; }
|
| 1036 | 1037 | $uri = '/resellers?'.http_build_query($query, '', '&', PHP_QUERY_RFC3986);
|
| | @@ -1039,10 +1040,10 @@ |
| 1039 | 1040 | if (isset($res->data['data'])) {
|
| 1040 | 1041 | $res->data['query'] = $query;
|
| 1041 | 1042 | $this->setCache($cacheName, $res->data);
|
| 1042 | | - return \Result::Success('', $res->data);
|
| 1043 | + return Result::Success('', $res->data);
|
| 1043 | 1044 | }
|
| 1044 | 1045 |
|
| 1045 | | - return \Result::Error('リセラーの受け取りに失敗。');
|
| 1046 | + return Result::Error('リセラーの受け取りに失敗。');
|
| 1046 | 1047 | }
|
| 1047 | 1048 |
|
| 1048 | 1049 | /**
|
| | @@ -1053,18 +1054,18 @@ |
| 1053 | 1054 | * @param array $payload フォームデータ
|
| 1054 | 1055 | * @return Result
|
| 1055 | 1056 | */
|
| 1056 | | - public function updateReseller(int $id, array $payload = []): \Result {
|
| 1057 | | - if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
|
| 1057 | + public function updateReseller(int $id, array $payload = []): Result {
|
| 1058 | + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
|
| 1058 | 1059 |
|
| 1059 | 1060 | $uri = "/resellers/{$id}";
|
| 1060 | 1061 | $curl = $this->setupCurl($uri, 'PUT', $payload);
|
| 1061 | 1062 | $res = $this->curlResult($curl);
|
| 1062 | 1063 | if (isset($res->data['data'])) {
|
| 1063 | 1064 | $this->murderCache('getreseller');
|
| 1064 | | - if ($res->data['data']['success']) return \Result::Success('リセラーの更新に成功。', $res->data);
|
| 1065 | + if ($res->data['data']['success']) return Result::Success('リセラーの更新に成功。', $res->data);
|
| 1065 | 1066 | }
|
| 1066 | 1067 |
|
| 1067 | | - return \Result::Error('リセラーの更新に失敗。');
|
| 1068 | + return Result::Error('リセラーの更新に失敗。');
|
| 1068 | 1069 | }
|
| 1069 | 1070 |
|
| 1070 | 1071 | //// 設定
|
| | @@ -1075,11 +1076,11 @@ |
| 1075 | 1076 | *
|
| 1076 | 1077 | * @return Result
|
| 1077 | 1078 | */
|
| 1078 | | - public function listSettings(): \Result {
|
| 1079 | | - if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
|
| 1079 | + public function listSettings(): Result {
|
| 1080 | + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
|
| 1080 | 1081 | $cacheName = 'listsettings';
|
| 1081 | 1082 | $cache = $this->getCache($cacheName);
|
| 1082 | | - if ($this->isValidLifespan($cache, $query)) return \Result::Success('', $cache);
|
| 1083 | + if ($this->isValidLifespan($cache, $query)) return Result::Success('', $cache);
|
| 1083 | 1084 |
|
| 1084 | 1085 | $uri = '/resellers/settings';
|
| 1085 | 1086 | $curl = $this->setupCurl($uri);
|
| | @@ -1087,10 +1088,10 @@ |
| 1087 | 1088 | if (isset($res->data['data'])) {
|
| 1088 | 1089 | $res->data['query'] = $query;
|
| 1089 | 1090 | $this->setCache($cacheName, $res->data);
|
| 1090 | | - return \Result::Success('', $res->data);
|
| 1091 | + return Result::Success('', $res->data);
|
| 1091 | 1092 | }
|
| 1092 | 1093 |
|
| 1093 | | - return \Result::Error('設定の受け取りに失敗。');
|
| 1094 | + return Result::Error('設定の受け取りに失敗。');
|
| 1094 | 1095 | }
|
| 1095 | 1096 |
|
| 1096 | 1097 | //// 統計
|
| | @@ -1101,11 +1102,11 @@ |
| 1101 | 1102 | *
|
| 1102 | 1103 | * @return Result
|
| 1103 | 1104 | */
|
| 1104 | | - public function listStatistics(array $query = []): \Result {
|
| 1105 | | - if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
|
| 1105 | + public function listStatistics(array $query = []): Result {
|
| 1106 | + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
|
| 1106 | 1107 | $cacheName = 'liststatistics';
|
| 1107 | 1108 | $cache = $this->getCache($cacheName);
|
| 1108 | | - if ($this->isValidLifespan($cache, $query)) return \Result::Success('', $cache);
|
| 1109 | + if ($this->isValidLifespan($cache, $query)) return Result::Success('', $cache);
|
| 1109 | 1110 |
|
| 1110 | 1111 | $uri = '/resellers/statistics';
|
| 1111 | 1112 | $curl = $this->setupCurl($uri);
|
| | @@ -1113,10 +1114,10 @@ |
| 1113 | 1114 | if (isset($res->data['data'])) {
|
| 1114 | 1115 | $res->data['query'] = $query;
|
| 1115 | 1116 | $this->setCache($cacheName, $res->data);
|
| 1116 | | - return \Result::Success('', $res->data);
|
| 1117 | + return Result::Success('', $res->data);
|
| 1117 | 1118 | }
|
| 1118 | 1119 |
|
| 1119 | | - return \Result::Error('統計の受け取りに失敗。');
|
| 1120 | + return Result::Error('統計の受け取りに失敗。');
|
| 1120 | 1121 | }
|
| 1121 | 1122 |
|
| 1122 | 1123 | //// タグ
|
| | @@ -1128,11 +1129,11 @@ |
| 1128 | 1129 | * @param array $query 検索クエリー
|
| 1129 | 1130 | * @return Result
|
| 1130 | 1131 | */
|
| 1131 | | - public function listTags(array $query = []): \Result {
|
| 1132 | | - if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
|
| 1132 | + public function listTags(array $query = []): Result {
|
| 1133 | + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
|
| 1133 | 1134 | $cacheName = 'listtags';
|
| 1134 | 1135 | $cache = $this->getCache($cacheName);
|
| 1135 | | - if ($this->isValidLifespan($cache, $query)) return \Result::Success('', $cache);
|
| 1136 | + if ($this->isValidLifespan($cache, $query)) return Result::Success('', $cache);
|
| 1136 | 1137 |
|
| 1137 | 1138 | foreach ($query as $k => $v) { if (is_bool($v)) $query[$k] = $v ? 'true' : 'false'; }
|
| 1138 | 1139 | $uri = '/tags?'.http_build_query($query, '', '&', PHP_QUERY_RFC3986);
|
| | @@ -1141,10 +1142,10 @@ |
| 1141 | 1142 | if (isset($res->data['data'])) {
|
| 1142 | 1143 | $res->data['query'] = $query;
|
| 1143 | 1144 | $this->setCache($cacheName, $res->data);
|
| 1144 | | - return \Result::Success('', $res->data);
|
| 1145 | + return Result::Success('', $res->data);
|
| 1145 | 1146 | }
|
| 1146 | 1147 |
|
| 1147 | | - return \Result::Error('タグ一覧の受け取りに失敗。');
|
| 1148 | + return Result::Error('タグ一覧の受け取りに失敗。');
|
| 1148 | 1149 | }
|
| 1149 | 1150 |
|
| 1150 | 1151 | /**
|
| | @@ -1154,18 +1155,18 @@ |
| 1154 | 1155 | * @param array $payload フォームデータ
|
| 1155 | 1156 | * @return Result
|
| 1156 | 1157 | */
|
| 1157 | | - public function createTag(array $payload = []): \Result {
|
| 1158 | | - if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
|
| 1158 | + public function createTag(array $payload = []): Result {
|
| 1159 | + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
|
| 1159 | 1160 |
|
| 1160 | 1161 | $uri = '/tags';
|
| 1161 | 1162 | $curl = $this->setupCurl($uri, 'POST', $payload);
|
| 1162 | 1163 | $res = $this->curlResult($curl);
|
| 1163 | 1164 | if (isset($res->data['data'])) {
|
| 1164 | 1165 | $this->murderCache('listtags');
|
| 1165 | | - return \Result::Success('タグの追加に成功。', $res->data);
|
| 1166 | + return Result::Success('タグの追加に成功。', $res->data);
|
| 1166 | 1167 | }
|
| 1167 | 1168 |
|
| 1168 | | - return \Result::Error('タグの追加に失敗。');
|
| 1169 | + return Result::Error('タグの追加に失敗。');
|
| 1169 | 1170 | }
|
| 1170 | 1171 |
|
| 1171 | 1172 | /**
|
| | @@ -1175,18 +1176,18 @@ |
| 1175 | 1176 | * @param array $payload フォームデータ
|
| 1176 | 1177 | * @return Result
|
| 1177 | 1178 | */
|
| 1178 | | - public function deleteTag(array $payload = []): \Result {
|
| 1179 | | - if (!OPENPROVIDER_ENABLED) return \Result::error('エラー:OpenProviderは無効です。');
|
| 1179 | + public function deleteTag(array $payload = []): Result {
|
| 1180 | + if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
|
| 1180 | 1181 |
|
| 1181 | 1182 | $uri = "/tags/{$id}";
|
| 1182 | 1183 | $curl = $this->setupCurl($uri, 'DELETE', $payload);
|
| 1183 | 1184 | $res = $this->curlResult($curl);
|
| 1184 | 1185 | if (isset($res->data['data'])) {
|
| 1185 | 1186 | $this->murderCache('listtags');
|
| 1186 | | - if ($res->data['data']['success']) return \Result::Success('タグの削除に成功。', $res->data);
|
| 1187 | + if ($res->data['data']['success']) return Result::Success('タグの削除に成功。', $res->data);
|
| 1187 | 1188 | }
|
| 1188 | 1189 |
|
| 1189 | | - return \Result::Error('タグの削除に失敗。');
|
| 1190 | + return Result::Error('タグの削除に失敗。');
|
| 1190 | 1191 | }
|
| 1191 | 1192 |
|
| 1192 | 1193 | // SpamExpert
|
| | @@ -1229,12 +1230,12 @@ |
| 1229 | 1230 | return $curl;
|
| 1230 | 1231 | }
|
| 1231 | 1232 |
|
| 1232 | | - private function curlResult(Curl &$curl): \Result {
|
| 1233 | + private function curlResult(Curl &$curl): Result {
|
| 1233 | 1234 | $res = $curl->execute();
|
| 1234 | 1235 | if (!$res->isSuccess) {
|
| 1235 | 1236 | $err = "CURL実行に失敗: {$curl->message}";
|
| 1236 | 1237 | assert_unless_success($res, $err);
|
| 1237 | | - return \Result::Error($err);
|
| 1238 | + return Result::Error($err);
|
| 1238 | 1239 | }
|
| 1239 | 1240 |
|
| 1240 | 1241 | $body = $curl->getResponseBody();
|
| | @@ -1242,11 +1243,11 @@ |
| 1242 | 1243 | $err = json_decode($body, true);
|
| 1243 | 1244 | assert_not_null($err, "エラーの受け取りに失敗。");
|
| 1244 | 1245 | assert($curl->getResponseCode() == 200, $err['desc']);
|
| 1245 | | - return \Result::Error($err['desc']);
|
| 1246 | + return Result::Error($err['desc']);
|
| 1246 | 1247 | }
|
| 1247 | 1248 | assert_not_null($body, "返事ボディーは空です。");
|
| 1248 | 1249 |
|
| 1249 | | - return \Result::Success('', json_decode($body, true));
|
| 1250 | + return Result::Success('', json_decode($body, true));
|
| 1250 | 1251 | }
|
| 1251 | 1252 |
|
| 1252 | 1253 | /**
|
| | @@ -1256,17 +1257,17 @@ |
| 1256 | 1257 | * @param array $data 保存するデータ
|
| 1257 | 1258 | * @return Result
|
| 1258 | 1259 | */
|
| 1259 | | - private function setCache(string $type, array $data): \Result {
|
| 1260 | + private function setCache(string $type, array $data): Result {
|
| 1260 | 1261 | if (!file_exists($this->dataDir)) {
|
| 1261 | 1262 | if (!mkdir($this->dataDir, 0755))
|
| 1262 | | - return \Result::Error('エラー:ユーザーのアイコンディレクトリの作成に失敗。');
|
| 1263 | + return Result::Error('エラー:ユーザーのアイコンディレクトリの作成に失敗。');
|
| 1263 | 1264 | }
|
| 1264 | 1265 |
|
| 1265 | 1266 | $data['lifespan'] = time();
|
| 1266 | 1267 | $json = json_encode($data, JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
|
| 1267 | | - if (file_put_contents("{$this->dataDir}{$type}.json", $json) === false) return \Result::Error('エラー:ユーザーデータの保存に失敗。');
|
| 1268 | + if (file_put_contents("{$this->dataDir}{$type}.json", $json) === false) return Result::Error('エラー:ユーザーデータの保存に失敗。');
|
| 1268 | 1269 |
|
| 1269 | | - return \Result::Success();
|
| 1270 | + return Result::Success();
|
| 1270 | 1271 | }
|
| 1271 | 1272 |
|
| 1272 | 1273 | /**
|
| | @@ -1298,10 +1299,10 @@ |
| 1298 | 1299 | * @param string $name キャッシュのファイル名
|
| 1299 | 1300 | * @return Result
|
| 1300 | 1301 | */
|
| 1301 | | - private function murderCache(string $name): \Result {
|
| 1302 | | - if (!file_exists("{$this->dataDir}{$name}.json")) return \Result::Error('キャッシュファイルが存在しない。');
|
| 1303 | | - if (!unlink("{$this->dataDir}{$name}.json")) return \Result::Error('キャッシュファイルの削除に失敗。');
|
| 1304 | | - return \Result::Success();
|
| 1302 | + private function murderCache(string $name): Result {
|
| 1303 | + if (!file_exists("{$this->dataDir}{$name}.json")) return Result::Error('キャッシュファイルが存在しない。');
|
| 1304 | + if (!unlink("{$this->dataDir}{$name}.json")) return Result::Error('キャッシュファイルの削除に失敗。');
|
| 1305 | + return Result::Success();
|
| 1305 | 1306 | }
|
| 1306 | 1307 |
|
| 1307 | 1308 | /**
|