もっと追加した

諏訪子 <suwako@076.moe>、2026-04-30 19:28
コミット d3e04ace968add3d5db253f203f66cf71d2fef2a ・親 1588201 ・ファイルを見る

1個のファイル、+734 -15

@@ -69,7 +69,8 @@
6969 */
7070 public function login(): Result {
7171 if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
72- $cache = $this->getCache('login');
72+ $cacheName = 'login';
73+ $cache = $this->getCache($cacheName);
7374 if (time() < ($this->lastAuth + $this->tokenDuration)) {
7475 $this->token = $cache['data']['token'];
7576 $this->lastAuth = $cache['last_auth'];
@@ -109,7 +110,7 @@
109110 $this->token = $res['data']['token'];
110111 $this->lastAuth = time();
111112 $res['last_auth'] = $this->lastAuth;
112- $this->setCache('login', $res);
113+ $this->setCache($cacheName, $res);
113114
114115 return Result::Success('', $res);
115116 }
@@ -149,13 +150,14 @@
149150 */
150151 public function listDomains(array $query = []): Result {
151152 if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
152- $cache = $this->getCache('listdomains');
153+ $cacheName = 'listdomains'
154+ $cache = $this->getCache($cacheName);
153155 if ($this->isValidLifespan($cache, $query)) return Result::Success('', $cache);
154156
155157 $curl = $this->setupCurl('/domains');
156158 $res = $this->curlResult($curl);
157159 if (isset($res['data']['results'])) {
158- $this->setCache('listdomains', $res->data);
160+ $this->setCache($cacheName, $res->data);
159161 return Result::Success('', $res['data']['results']);
160162 }
161163
@@ -400,7 +402,8 @@
400402 */
401403 public function listTlds(array $query = []): Result {
402404 if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
403- $cache = $this->getCache('listtlds');
405+ $cacheName = 'listtlds';
406+ $cache = $this->getCache($cacheName);
404407 if ($this->isValidLifespan($cache)) return Result::Success('', $cache);
405408
406409 if (empty($query)) $query = [ 'limit' => 10, 'offset' => 0, 'order' => 'ASC' ];
@@ -410,7 +413,7 @@
410413 $curl = $this->setupCurl($uri);
411414 $res = $this->curlResult($curl);
412415 if (isset($res->data['data'])) {
413- $this->setCache('listtlds', $res->data);
416+ $this->setCache($cacheName, $res->data);
414417 return Result::Success('', $res->data);
415418 }
416419
@@ -556,7 +559,251 @@
556559 }
557560
558561 //// ネームサーバー
562+
563+ /**
564+ * ネームサーバー一覧
565+ * @todo テスト
566+ *
567+ * @param array $query
568+ * @return Result
569+ */
570+ public function listNameservers(array $query = []): Result {
571+ if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
572+ $cacheName = 'listnameservers';
573+ $cache = $this->getCache($cacheName);
574+ if ($this->isValidLifespan($cache, $query)) return Result::Success('', $cache);
575+
576+ if (empty($query)) $query = [ 'limit' => 25, 'offset' => 0, 'order_by.name' => 'asc' ];
577+ foreach ($query as $k => $v) if (is_bool($v)) $query[$k] = $v ? 'true' : 'false';
578+
579+ $uri = "/dns/nameservers?".http_build_query($query, '', '&', PHP_QUERY_RFC3986);
580+ $curl = $this->setupCurl($uri);
581+ $res = $this->curlResult($curl);
582+ if (isset($res->data['data'])) {
583+ $this->setCache($cacheName, $res->data);
584+ return Result::Success('', $res->data);
585+ }
586+
587+ return Result::Error('ネームサーバー一覧の受け取りに失敗。');
588+ }
589+
590+ /**
591+ * ネームサーバーの作成
592+ * @todo テスト
593+ *
594+ * @param array $payload フォームデータ
595+ * @return Result
596+ */
597+ public function createNameserver(array $payload = []): Result {
598+ if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
599+
600+ $uri = '/dns/nameservers';
601+ $curl = $this->setupCurl($uri, 'POST', $payload);
602+ $res = $this->curlResult($curl);
603+ if (isset($res->data['data'])) {
604+ $this->murderCache('listnameservers');
605+ return Result::Success('ネームサーバーの追加に成功。', $res->data);
606+ }
607+
608+ return Result::Error('ネームサーバーの追加に失敗。');
609+ }
610+
611+ /**
612+ * ネームサーバー一覧
613+ * @todo テスト
614+ *
615+ * @param string $domain ドメイン名
616+ * @param array $query 検索クエリー
617+ * @return Result
618+ */
619+ public function getNameserver(string $domain, array $query = []): Result {
620+ if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
621+ $cacheName = "listnameserver-{$domain}";
622+ $cache = $this->getCache($cacheName);
623+ if ($this->isValidLifespan($cache)) return Result::Success('', $cache);
624+
625+ if (empty($query)) $query = [ 'limit' => 100, 'offset' => 0, 'order_by.name' => 'asc' ];
626+ foreach ($query as $k => $v) if (is_bool($v)) $query[$k] = $v ? 'true' : 'false';
627+
628+ $uri = "/dns/nameservers/{$domain}?".http_build_query($query, '', '&', PHP_QUERY_RFC3986);
629+ $curl = $this->setupCurl($uri);
630+ $res = $this->curlResult($curl);
631+ if (isset($res->data['data'])) {
632+ $this->setCache($cacheName, $res->data);
633+ return Result::Success('', $res->data);
634+ }
635+
636+ return Result::Error('ネームサーバー一覧の受け取りに失敗。');
637+ }
638+
639+ /**
640+ * ネームサーバーの更新
641+ * @todo テスト
642+ *
643+ * @param string $domain ドメイン名
644+ * @param array $payload フォームデータ
645+ * @return Result
646+ */
647+ public function updateNameserver(string $domain, array $payload = []): Result {
648+ if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
649+
650+ $uri = "/dns/nameservers/{$domain}";
651+ $curl = $this->setupCurl($uri, 'PUT', $payload);
652+ $res = $this->curlResult($curl);
653+ if (isset($res->data['data'])) {
654+ $this->murderCache('listnameservers');
655+ $this->murderCache("listnameserver-{$domain}");
656+ if ($res->data['data']['success']) return Result::Success('ネームサーバーの更新に成功。', $res->data);
657+ }
658+
659+ return Result::Error('ネームサーバーの更新に失敗。');
660+ }
661+
662+ /**
663+ * ネームサーバーの削除
664+ * @todo テスト
665+ *
666+ * @param string $domain ドメイン名
667+ * @return Result
668+ */
669+ public function deleteNameserver(string $domain): Result {
670+ if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
671+
672+ $uri = "/dns/nameservers/{$domain}";
673+ $curl = $this->setupCurl($uri, 'DELETE');
674+ $res = $this->curlResult($curl);
675+ if (isset($res->data['data'])) {
676+ $this->murderCache('listnameservers');
677+ $this->murderCache("listnameserver-{$domain}");
678+ if ($res->data['data']['success']) return Result::Success('ネームサーバーの削除に成功。', $res->data);
679+ }
680+
681+ return Result::Error('ネームサーバーの削除に失敗。');
682+ }
683+
559684 //// NSグループ
685+
686+ /**
687+ * NSグループ一覧
688+ * @todo テスト
689+ *
690+ * @param array $query
691+ * @return Result
692+ */
693+ public function listNsGroups(array $query = []): Result {
694+ if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
695+ $cacheName = 'listnsgroups';
696+ $cache = $this->getCache($cacheName);
697+ if ($this->isValidLifespan($cache, $query)) return Result::Success('', $cache);
698+
699+ if (empty($query)) $query = [ 'limit' => 25, 'offset' => 0, 'order_by.name' => 'asc' ];
700+ foreach ($query as $k => $v) if (is_bool($v)) $query[$k] = $v ? 'true' : 'false';
701+
702+ $uri = "/dns/nameservers/groups?".http_build_query($query, '', '&', PHP_QUERY_RFC3986);
703+ $curl = $this->setupCurl($uri);
704+ $res = $this->curlResult($curl);
705+ if (isset($res->data['data'])) {
706+ $this->setCache($cacheName, $res->data);
707+ return Result::Success('', $res->data);
708+ }
709+
710+ return Result::Error('NSグループ一覧の受け取りに失敗。');
711+ }
712+
713+ /**
714+ * NSグループの作成
715+ * @todo テスト
716+ *
717+ * @param array $payload フォームデータ
718+ * @return Result
719+ */
720+ public function createNsGroup(array $payload = []): Result {
721+ if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
722+
723+ $uri = '/dns/nameservers/groups';
724+ $curl = $this->setupCurl($uri, 'POST', $payload);
725+ $res = $this->curlResult($curl);
726+ if (isset($res->data['data'])) {
727+ $this->murderCache('listnsgroups');
728+ return Result::Success('NSグループの追加に成功。', $res->data);
729+ }
730+
731+ return Result::Error('NSグループの追加に失敗。');
732+ }
733+
734+ /**
735+ * NSグループ一覧
736+ * @todo テスト
737+ *
738+ * @param string $nsGroup ネームサーバー名
739+ * @param array $query 検索クエリー
740+ * @return Result
741+ */
742+ public function getNsGroup(string $nsGroup, array $query = []): Result {
743+ if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
744+ $cacheName = "listnsgroup-{$nsGroup}";
745+ $cache = $this->getCache($cacheName);
746+ if ($this->isValidLifespan($cache)) return Result::Success('', $cache);
747+
748+ if (empty($query)) $query = [ 'limit' => 100, 'offset' => 0, 'order_by.name' => 'asc' ];
749+ foreach ($query as $k => $v) if (is_bool($v)) $query[$k] = $v ? 'true' : 'false';
750+
751+ $uri = "/dns/nameservers/groups/{$nsGroup}?".http_build_query($query, '', '&', PHP_QUERY_RFC3986);
752+ $curl = $this->setupCurl($uri);
753+ $res = $this->curlResult($curl);
754+ if (isset($res->data['data'])) {
755+ $this->setCache($cacheName, $res->data);
756+ return Result::Success('', $res->data);
757+ }
758+
759+ return Result::Error('NSグループ一覧の受け取りに失敗。');
760+ }
761+
762+ /**
763+ * NSグループの更新
764+ * @todo テスト
765+ *
766+ * @param string $nsGroup ネームサーバー名
767+ * @param array $payload フォームデータ
768+ * @return Result
769+ */
770+ public function updateNsGroup(string $nsGroup, array $payload = []): Result {
771+ if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
772+
773+ $uri = "/dns/nameservers/groups/{$nsGroup}";
774+ $curl = $this->setupCurl($uri, 'PUT', $payload);
775+ $res = $this->curlResult($curl);
776+ if (isset($res->data['data'])) {
777+ $this->murderCache('listnsgroups');
778+ $this->murderCache("listnsgroup-{$nsGroup}");
779+ if ($res->data['data']['success']) return Result::Success('NSグループの更新に成功。', $res->data);
780+ }
781+
782+ return Result::Error('NSグループの更新に失敗。');
783+ }
784+
785+ /**
786+ * NSグループの削除
787+ * @todo テスト
788+ *
789+ * @param string $nsGroup ネームサーバー名
790+ * @return Result
791+ */
792+ public function deleteNsGroup(string $nsGroup): Result {
793+ if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
794+
795+ $uri = "/dns/nameservers/groups/{$nsGroup}";
796+ $curl = $this->setupCurl($uri, 'DELETE');
797+ $res = $this->curlResult($curl);
798+ if (isset($res->data['data'])) {
799+ $this->murderCache('listnsgroups');
800+ $this->murderCache("listnsgroup-{$nsGroup}");
801+ if ($res->data['data']['success']) return Result::Success('NSグループの削除に成功。', $res->data);
802+ }
803+
804+ return Result::Error('NSグループの削除に失敗。');
805+ }
806+
560807 //// テンプレート
561808
562809 /**
@@ -645,13 +892,14 @@
645892 $res = $this->curlResult($curl);
646893 if (isset($res->data['data'])) {
647894 $this->murderCache('listdnstemplates');
895+ $this->murderCache("getdnstemplate-{$id}");
648896 if ($res->data['data']['success']) return Result::Success('DNSテンプレートの削除に成功。', $res->data);
649897 }
650898
651899 return Result::Error('DNSテンプレートの削除に失敗。');
652900 }
653901
654- //// ゾーン
902+ //// DNSゾーン
655903
656904 /**
657905 * DNSゾーン一覧
@@ -661,7 +909,8 @@
661909 */
662910 public function listDnsZones(array $query = []): Result {
663911 if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
664- $cache = $this->getCache('listdnszones');
912+ $cacheName = 'listdnszones';
913+ $cache = $this->getCache($cacheName);
665914 if ($this->isValidLifespan($cache, $query)) return Result::Success('', $cache);
666915
667916 if (empty($query)) $query = [ 'limit' => 25, 'offset' => 0, 'order_by.name' => 'asc' ];
@@ -671,14 +920,35 @@
671920 $curl = $this->setupCurl($uri);
672921 $res = $this->curlResult($curl);
673922 if (isset($res->data['data'])) {
674- $this->setCache('listdnszones', $res->data);
923+ $this->setCache($cacheName, $res->data);
675924 return Result::Success('', $res->data);
676925 }
677926
678- return Result::Error('TLD一覧の受け取りに失敗。');
927+ return Result::Error('DNSゾーン一覧の受け取りに失敗。');
679928 }
680929
681930 /**
931+ * DNSゾーンの作成
932+ * @todo テスト
933+ *
934+ * @param array $payload フォームデータ
935+ * @return Result
936+ */
937+ public function createDnsZone(array $payload = []): Result {
938+ if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
939+
940+ $uri = '/dns/zones';
941+ $curl = $this->setupCurl($uri, 'POST', $payload);
942+ $res = $this->curlResult($curl);
943+ if (isset($res->data['data'])) {
944+ $this->murderCache('listdnszones');
945+ return Result::Success('DNSゾーンの追加に成功。', $res->data);
946+ }
947+
948+ return Result::Error('DNSゾーンの追加に失敗。');
949+ }
950+
951+ /**
682952 * DNSゾーン一覧
683953 *
684954 * @param string $domain ドメイン名
@@ -687,7 +957,8 @@
687957 */
688958 public function getDnsZone(string $domain, array $query = []): Result {
689959 if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
690- $cache = $this->getCache("getdnszone-{$domain}");
960+ $cacheName = "getdnszone-{$domain}";
961+ $cache = $this->getCache($cacheName);
691962 if ($this->isValidLifespan($cache)) return Result::Success('', $cache);
692963
693964 if (empty($query)) $query = [ 'limit' => 100, 'offset' => 0, 'order_by.name' => 'asc' ];
@@ -697,13 +968,58 @@
697968 $curl = $this->setupCurl($uri);
698969 $res = $this->curlResult($curl);
699970 if (isset($res->data['data'])) {
700- $this->setCache("getdnszone-{$domain}", $res->data);
971+ $this->setCache($cacheName, $res->data);
701972 return Result::Success('', $res->data);
702973 }
703974
704- return Result::Error('TLD一覧の受け取りに失敗。');
975+ return Result::Error('DNSゾーン一覧の受け取りに失敗。');
705976 }
706977
978+ /**
979+ * DNSゾーンの更新
980+ * @todo テスト
981+ *
982+ * @param string $domain ドメイン名
983+ * @param array $payload フォームデータ
984+ * @return Result
985+ */
986+ public function updateDnsZone(string $domain, array $payload = []): Result {
987+ if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
988+
989+ $uri = "/dns/zones/{$domain}";
990+ $curl = $this->setupCurl($uri, 'PUT', $payload);
991+ $res = $this->curlResult($curl);
992+ if (isset($res->data['data'])) {
993+ $this->murderCache('listdnszones');
994+ $this->murderCache("getdnszone-{$domain}");
995+ if ($res->data['data']['success']) return Result::Success('DNSゾーンの更新に成功。', $res->data);
996+ }
997+
998+ return Result::Error('DNSゾーンの更新に失敗。');
999+ }
1000+
1001+ /**
1002+ * DNSゾーンの削除
1003+ * @todo テスト
1004+ *
1005+ * @param string $domain ドメイン名
1006+ * @return Result
1007+ */
1008+ public function deleteDnsZone(string $domain): Result {
1009+ if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
1010+
1011+ $uri = "/dns/zones/{$domain}";
1012+ $curl = $this->setupCurl($uri, 'DELETE');
1013+ $res = $this->curlResult($curl);
1014+ if (isset($res->data['data'])) {
1015+ $this->murderCache('listdnszones');
1016+ $this->murderCache("getdnszone-{$domain}");
1017+ if ($res->data['data']['success']) return Result::Success('DNSゾーンの削除に成功。', $res->data);
1018+ }
1019+
1020+ return Result::Error('DNSゾーンの削除に失敗。');
1021+ }
1022+
7071023 //// ゾーンレコード
7081024
7091025 /**
@@ -714,13 +1030,14 @@
7141030 */
7151031 public function listZoneRecords(string $domain): Result {
7161032 if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
717- $cache = $this->getCache("getzonerecords-{$domain}");
1033+ $cacheName = "getzonerecords-{$domain}";
1034+ $cache = $this->getCache($cacheName);
7181035 if ($this->isValidLifespan($cache)) return Result::Success('', $cache);
7191036
7201037 $curl = $this->setupCurl("/dns/zones/{$domain}/records");
7211038 $res = $this->curlResult($curl);
7221039 if (isset($res->data['data'])) {
723- $this->setCache("getzonerecords-{$domain}", $res->data);
1040+ $this->setCache($cacheName, $res->data);
7241041 return Result::Success('', $res->data);
7251042 }
7261043
@@ -829,6 +1146,122 @@
8291146
8301147 //// 連絡先
8311148
1149+ /**
1150+ * 連絡先の一覧
1151+ *
1152+ * @param array $query 検索クエリー
1153+ * @return Result
1154+ */
1155+ public function listContacts(array $query = []): Result {
1156+ if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
1157+ $cacheName = 'listcontacts';
1158+ $cache = $this->getCache($cacheName);
1159+ if ($this->isValidLifespan($cache, $query)) return Result::Success('', $cache);
1160+
1161+ foreach ($query as $k => $v) { if (is_bool($v)) $query[$k] = $v ? 'true' : 'false'; }
1162+ $uri = '/contacts?'.http_build_query($query, '', '&', PHP_QUERY_RFC3986);
1163+ $curl = $this->setupCurl($uri);
1164+ $res = $this->curlResult($curl);
1165+ if (isset($res->data['data'])) {
1166+ $res->data['query'] = $query;
1167+ $this->setCache($cacheName, $res->data);
1168+ return Result::Success('', $res->data);
1169+ }
1170+
1171+ return Result::Error('連絡先一覧の受け取りに失敗。');
1172+ }
1173+
1174+ /**
1175+ * 連絡先の作成
1176+ *
1177+ * @param array $payload
1178+ * @return Result
1179+ */
1180+ public function createContact(array $payload): Result {
1181+ if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
1182+
1183+ $uri = '/contacts';
1184+ $curl = $this->setupCurl($uri, 'POST', $payload);
1185+ $res = $this->curlResult($curl);
1186+ if (isset($res)) {
1187+ $this->murderCache('listcontacts');
1188+ return Result::Success('', $res->data);
1189+ }
1190+
1191+ return Result::Error("連絡先の作成に失敗。");
1192+ }
1193+
1194+ /**
1195+ * 連絡先の表示
1196+ *
1197+ * @param int $id 連絡先ID
1198+ * @param bool $withAdditionalData 詳細データ含むか?
1199+ * @return Result
1200+ */
1201+ public function getContact(int $id, bool $withAdditionalData = false): Result {
1202+ if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
1203+ $cacheName = "getcontact-{$id}";
1204+ $cache = $this->getCache($cacheName);
1205+ if ($this->isValidLifespan($cache, $id, 'id')) return Result::Success('', $cache);
1206+
1207+ $query = [ 'with_additional_data' => $withAdditionalData ? 'true' : 'false' ];
1208+ $uri = "/contacts/{$id}?".http_build_query($query, '', '&', PHP_QUERY_RFC3986);
1209+ // kys($uri);
1210+ $curl = $this->setupCurl($uri);
1211+ $res = $this->curlResult($curl);
1212+ if (isset($res->data['data'])) {
1213+ $res->data['id'] = $id;
1214+ $this->setCache($cacheName, $res->data);
1215+ return Result::Success('', $res->data);
1216+ }
1217+
1218+ return Result::Error('連絡先の受け取りに失敗。');
1219+ }
1220+
1221+ /**
1222+ * 連絡先の更新
1223+ * @todo テスト
1224+ *
1225+ * @param int $id 連絡先ID
1226+ * @param array $payload フォームデータ
1227+ * @return Result
1228+ */
1229+ public function updateContact(int $id, array $payload = []): Result {
1230+ if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
1231+
1232+ $uri = "/contacts/{$id}";
1233+ $curl = $this->setupCurl($uri, 'PUT', $payload);
1234+ $res = $this->curlResult($curl);
1235+ if (isset($res->data['data'])) {
1236+ $this->murderCache("getcontact-{$id}");
1237+ $this->murderCache('listcontacts');
1238+ if ($res->data['data']['success']) return Result::Success('連絡先の更新に成功。', $res->data);
1239+ }
1240+
1241+ return Result::Error('連絡先の更新に失敗。');
1242+ }
1243+
1244+ /**
1245+ * 連絡先の削除
1246+ *
1247+ * @param int $id 連絡先ID
1248+ * @return Result
1249+ */
1250+ public function deleteContact(int $id): Result {
1251+ if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
1252+
1253+ $uri = "/contacts/{$id}";
1254+ $curl = $this->setupCurl($uri, 'DELETE');
1255+ $res = $this->curlResult($curl);
1256+ if (isset($res->data['data'])) {
1257+ $this->murderCache("getcontact-{$id}");
1258+ $this->murderCache('listcontacts');
1259+ if ($res->data['data']['success']) return Result::Success('連絡先の削除に成功。');
1260+ }
1261+
1262+ return Result::Error('連絡先の削除に失敗。');
1263+ }
1264+
8321265 //// 顧客様
8331266
8341267 /**
@@ -1192,7 +1625,293 @@
11921625
11931626 // SpamExpert
11941627
1628+ //// SEDomain
1629+
1630+ /**
1631+ * SEDomainの作成
1632+ * @todo テスト
1633+ *
1634+ * @param array $payload
1635+ * @return Result
1636+ */
1637+ public function createSeDomain(array $payload): Result {
1638+ if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
1639+
1640+ $uri = '/spam-expert/domains';
1641+ $curl = $this->setupCurl($uri, 'POST', $payload);
1642+ $res = $this->curlResult($curl);
1643+ if (isset($res)) {
1644+ $this->murderCache('listdomains');
1645+ return Result::Success('', $res->data);
1646+ }
1647+
1648+ return Result::Error("SEDomainの作成に失敗。");
1649+ }
1650+
1651+ /**
1652+ * SEDomainの表示
1653+ * @todo テスト
1654+ *
1655+ * @param string $domain ドメイン名
1656+ * @param array $query 検索クエリー
1657+ * @return Result
1658+ */
1659+ public function getSeDomain(string $domain, array $query = []): Result {
1660+ if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
1661+ $cacheName = "getsedomain-{$domain}";
1662+ $cache = $this->getCache($cacheName);
1663+ if ($this->isValidLifespan($cache, $domain, 'domain')) return Result::Success('', $cache);
1664+
1665+ $uri = "/spam-expert/domains/{$domain}?".http_build_query($query, '', '&', PHP_QUERY_RFC3986);
1666+ // kys($uri);
1667+ $curl = $this->setupCurl($uri);
1668+ $res = $this->curlResult($curl);
1669+ if (isset($res->data['data'])) {
1670+ $res->data['domain'] = $domain;
1671+ $this->setCache($cacheName, $res->data);
1672+ return Result::Success('', $res->data);
1673+ }
1674+
1675+ return Result::Error('SEDomainの受け取りに失敗。');
1676+ }
1677+
1678+ /**
1679+ * SEDomainの更新
1680+ * @todo テスト
1681+ *
1682+ * @param string $domain ドメイン名
1683+ * @param array $payload フォームデータ
1684+ * @return Result
1685+ */
1686+ public function updateSeDomain(string $domain, array $payload = []): Result {
1687+ if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
1688+
1689+ $uri = "/spam-expert/domains/{$domain}";
1690+ $curl = $this->setupCurl($uri, 'PUT', $payload);
1691+ $res = $this->curlResult($curl);
1692+ if (isset($res->data['data'])) {
1693+ $this->murderCache('listdomains');
1694+ $this->murderCache("getsedomain-{$domain}");
1695+ if ($res->data['data']['success']) return Result::Success('SEDomainの更新に成功。', $res->data);
1696+ }
1697+
1698+ return Result::Error('SEDomainの更新に失敗。');
1699+ }
1700+
1701+ /**
1702+ * SEDomainの削除
1703+ * @todo テスト
1704+ *
1705+ * @param string $domain ドメイン名
1706+ * @return Result
1707+ */
1708+ public function deleteSeDomain(string $domain): Result {
1709+ if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
1710+
1711+ $uri = "/spam-expert/domains/{$domain}";
1712+ $curl = $this->setupCurl($uri, 'DELETE');
1713+ $res = $this->curlResult($curl);
1714+ if (isset($res->data['data'])) {
1715+ $this->murderCache('listdomains');
1716+ $this->murderCache("getsedomain-{$domain}");
1717+ if ($res->data['data']['success']) return Result::Success('SEDomainの削除に成功。');
1718+ }
1719+
1720+ return Result::Error('SEDomainの削除に失敗。');
1721+ }
1722+
11951723 // SSL証明書
1724+
1725+ //// 確認担当者メール
1726+
1727+ /**
1728+ * 確認担当者メール一覧
1729+ * @todo テスト
1730+ *
1731+ * @param array $query 検索クエリー
1732+ * @return Result
1733+ */
1734+ public function listApproverEmails(array $query = []): Result {
1735+ if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
1736+ $cacheName = 'listapproveremails';
1737+ $cache = $this->getCache($cacheName);
1738+ if ($this->isValidLifespan($cache, $query)) return Result::Success('', $cache);
1739+
1740+ foreach ($query as $k => $v) { if (is_bool($v)) $query[$k] = $v ? 'true' : 'false'; }
1741+ $uri = '/ssl/approver-emails?'.http_build_query($query, '', '&', PHP_QUERY_RFC3986);
1742+ $curl = $this->setupCurl($uri);
1743+ $res = $this->curlResult($curl);
1744+ if (isset($res->data['data'])) {
1745+ $res->data['query'] = $query;
1746+ $this->setCache($cacheName, $res->data);
1747+ return Result::Success('', $res->data);
1748+ }
1749+
1750+ return Result::Error('確認担当者メール一覧の受け取りに失敗。');
1751+ }
1752+
1753+ //// CSR
1754+
1755+ /**
1756+ * 注文確認担当者メールの再送信
1757+ * @todo テスト
1758+ *
1759+ * @param array $payload
1760+ * @return Result
1761+ */
1762+ public function createCsr(array $payload): Result {
1763+ if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
1764+
1765+ $uri = '/ssl/csr';
1766+ $curl = $this->setupCurl($uri, 'POST', $payload);
1767+ $res = $this->curlResult($curl);
1768+ if (isset($res)) {
1769+ return Result::Success('', $res->data);
1770+ }
1771+
1772+ return Result::Error("注文確認担当者メールの再送信に失敗。");
1773+ }
1774+
1775+ /**
1776+ * 注文確認担当者メールの再送信
1777+ * @todo テスト
1778+ *
1779+ * @param string $csr
1780+ * @return Result
1781+ */
1782+ public function decodeCsr(string $csr): Result {
1783+ if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
1784+
1785+ $uri = '/ssl/csr/decode';
1786+ $curl = $this->setupCurl($uri, 'POST', ['csr' => $csr]);
1787+ $res = $this->curlResult($curl);
1788+ if (isset($res)) {
1789+ return Result::Success('', $res->data);
1790+ }
1791+
1792+ return Result::Error("注文確認担当者メールの再送信に失敗。");
1793+ }
1794+
1795+ //// 注文
1796+
1797+ //// 注文確認担当者メール
1798+
1799+ /**
1800+ * 注文確認担当者メールの更新
1801+ * @todo テスト
1802+ *
1803+ * @param int $id
1804+ * @param string $approverEmail
1805+ * @return Result
1806+ */
1807+ public function updateSslApproverEmail(int $id, string $approverEmail): Result {
1808+ if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
1809+
1810+ $uri = "/ssl/orders/{$id}/approver-email";
1811+ $curl = $this->setupCurl($uri, 'PUT', ['id' => $id, 'approver_email' => $approverEmail]);
1812+ $res = $this->curlResult($curl);
1813+ if (isset($res)) {
1814+ $this->murderCache('listapproveremails');
1815+ return Result::Success('', $res->data);
1816+ }
1817+
1818+ return Result::Error("注文確認担当者メールの更新に失敗。");
1819+ }
1820+
1821+ /**
1822+ * 注文確認担当者メールの再送信
1823+ * @todo テスト
1824+ *
1825+ * @param int $id
1826+ * @return Result
1827+ */
1828+ public function resendSslApproverEmail(int $id): Result {
1829+ if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
1830+
1831+ $uri = "/ssl/orders/{$id}/approver-email/resend";
1832+ $curl = $this->setupCurl($uri, 'POST', ['id' => $id]);
1833+ $res = $this->curlResult($curl);
1834+ if (isset($res)) {
1835+ $this->murderCache('listapproveremails');
1836+ return Result::Success('', $res->data);
1837+ }
1838+
1839+ return Result::Error("注文確認担当者メールの再送信に失敗。");
1840+ }
1841+
1842+ //// OTPトークン
1843+
1844+ /**
1845+ * OTPトークンの作成
1846+ * @todo テスト
1847+ *
1848+ * @param int $id
1849+ * @return Result
1850+ */
1851+ public function createSslOtpToken(int $id): Result {
1852+ if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
1853+
1854+ $uri = "/ssl/orders/{$id}/otp-tokens";
1855+ $curl = $this->setupCurl($uri, 'POST');
1856+ $res = $this->curlResult($curl);
1857+ if (isset($res)) {
1858+ return Result::Success('', $res->data);
1859+ }
1860+
1861+ return Result::Error("OTPトークンの作成に失敗。");
1862+ }
1863+
1864+ //// 商品
1865+
1866+ /**
1867+ * 商品一覧
1868+ * @todo テスト
1869+ *
1870+ * @param array $query 検索クエリー
1871+ * @return Result
1872+ */
1873+ public function listSslProducts(array $query = []): Result {
1874+ if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
1875+ $cacheName = 'listsslproducts';
1876+ $cache = $this->getCache($cacheName);
1877+ if ($this->isValidLifespan($cache, $query)) return Result::Success('', $cache);
1878+
1879+ foreach ($query as $k => $v) { if (is_bool($v)) $query[$k] = $v ? 'true' : 'false'; }
1880+ $uri = '/ssl/products?'.http_build_query($query, '', '&', PHP_QUERY_RFC3986);
1881+ $curl = $this->setupCurl($uri);
1882+ $res = $this->curlResult($curl);
1883+ if (isset($res->data['data'])) {
1884+ $res->data['query'] = $query;
1885+ $this->setCache($cacheName, $res->data);
1886+ return Result::Success('', $res->data);
1887+ }
1888+
1889+ return Result::Error('商品一覧の受け取りに失敗。');
1890+ }
1891+
1892+ /**
1893+ * 商品の表示
1894+ * @todo テスト
1895+ *
1896+ * @param int $id 商品ID
1897+ * @return Result
1898+ */
1899+ public function getSslProduct(int $id): Result {
1900+ if (!OPENPROVIDER_ENABLED) return Result::error('エラー:OpenProviderは無効です。');
1901+ $cacheName = "getsslproduct-{$id}";
1902+ $cache = $this->getCache($cacheName);
1903+ if ($this->isValidLifespan($cache, $id, 'id')) return Result::Success('', $cache);
1904+ // kys($uri);
1905+ $curl = $this->setupCurl($uri);
1906+ $res = $this->curlResult($curl);
1907+ if (isset($res->data['data'])) {
1908+ $res->data['id'] = $id;
1909+ $this->setCache($cacheName, $res->data);
1910+ return Result::Success('', $res->data);
1911+ }
1912+
1913+ return Result::Error('商品の受け取りに失敗。');
1914+ }
11961915
11971916 ////////
11981917