diff --git a/phpcbf.phar b/phpcbf.phar new file mode 100644 index 0000000..6771440 Binary files /dev/null and b/phpcbf.phar differ diff --git a/phpcs.phar b/phpcs.phar new file mode 100644 index 0000000..b8ed399 Binary files /dev/null and b/phpcs.phar differ diff --git a/src/Endpoints/TLS.php b/src/Endpoints/TLS.php index d92a8b7..46c960e 100644 --- a/src/Endpoints/TLS.php +++ b/src/Endpoints/TLS.php @@ -25,7 +25,7 @@ class TLS implements API 'zones/' . $zoneID . '/settings/tls_1_3', ['value' => 'on'] ); - $body = json_decode($return->getBody()); + $body = json_decode($return->getBody()); if ($body->success) { return true; @@ -40,7 +40,7 @@ class TLS implements API 'zones/' . $zoneID . '/settings/tls_1_3', ['value' => 'off'] ); - $body = json_decode($return->getBody()); + $body = json_decode($return->getBody()); if ($body->success) { return true; @@ -50,16 +50,77 @@ class TLS implements API } - public function changeMinimumTLSVersion($zoneID, $minimumVersion) { $return = $this->adapter->patch( 'zones/' . $zoneID . '/settings/min_tls_version', [ - 'value' => $minimumVersion + 'value' => $minimumVersion, ] ); - $body = json_decode($return->getBody()); + $body = json_decode($return->getBody()); + + if ($body->success) { + return true; + } + + return false; + } + + public function getHTTPSRedirectSetting($zoneID) + { + $return = $this->adapter->get( + 'zones/' . $zoneID . '/settings/always_use_https' + ); + $body = json_decode($return->getBody()); + + if ($body->success) { + return $body->result->value; + } + + return false; + } + + public function getHTTPSRewritesSetting($zoneID) + { + $return = $this->adapter->get( + 'zones/' . $zoneID . '/settings/automatic_https_rewrites' + ); + $body = json_decode($return->getBody()); + + if ($body->success) { + return $body->result->value; + } + + return false; + } + + public function updateHTTPSRedirectStatus($zoneID, $value) + { + $return = $this->adapter->patch( + 'zones/' . $zoneID . '/settings/always_use_https', + [ + 'value' => $value, + ] + ); + $body = json_decode($return->getBody()); + + if ($body->success) { + return true; + } + + return false; + } + + public function updateHTTPSRewritesStatus($zoneID, $value) + { + $return = $this->adapter->patch( + 'zones/' . $zoneID . '/settings/automatic_https_rewrites', + [ + 'value' => $value, + ] + ); + $body = json_decode($return->getBody()); if ($body->success) { return true; diff --git a/src/Endpoints/ZoneSettings.php b/src/Endpoints/ZoneSettings.php new file mode 100644 index 0000000..a32b84f --- /dev/null +++ b/src/Endpoints/ZoneSettings.php @@ -0,0 +1,180 @@ +adapter = $adapter; + } + + public function getMinifySetting($zoneID) + { + $return = $this->adapter->get( + 'zones/' . $zoneID . '/settings/minify' + ); + $body = json_decode($return->getBody()); + + if ($body->success) { + return $body->result->value; + } + + return false; + } + + public function getRocketLoaderSetting($zoneID) + { + $return = $this->adapter->get( + 'zones/' . $zoneID . '/settings/rocket_loader' + ); + $body = json_decode($return->getBody()); + + if ($body->success) { + return $body->result->value; + } + + return false; + } + + public function getAlwaysOnlineSetting($zoneID) + { + $return = $this->adapter->get( + 'zones/' . $zoneID . '/settings/always_online' + ); + $body = json_decode($return->getBody()); + + if ($body->success) { + return $body->result->value; + } + + return false; + } + + public function getEmailObfuscationSetting($zoneID) + { + $return = $this->adapter->get( + 'zones/' . $zoneID . '/settings/email_obfuscation' + ); + $body = json_decode($return->getBody()); + + if ($body->success) { + return $body->result->value; + } + + return false; + } + + public function getHotlinkProtectionSetting($zoneID) + { + $return = $this->adapter->get( + 'zones/' . $zoneID . '/settings/hotlink_protection' + ); + $body = json_decode($return->getBody()); + + if ($body->success) { + return $body->result->value; + } + + return false; + } + + public function updateMinifySetting($zoneID, $html, $css, $javascript) + { + $return = $this->adapter->patch( + 'zones/' . $zoneID . '/settings/minify', + [ + 'value' => [ + 'html' => $html, + 'css' => $css, + 'js' => $javascript, + ], + ] + ); + $body = json_decode($return->getBody()); + + if ($body->success) { + return true; + } + + return false; + } + + public function updateRocketLoaderSetting($zoneID, $value) + { + $return = $this->adapter->patch( + 'zones/' . $zoneID . '/settings/rocket_loader', + [ + 'value' => $value, + ] + ); + $body = json_decode($return->getBody()); + + if ($body->success) { + return true; + } + + return false; + } + + public function updateAlwaysOnlineSetting($zoneID, $value) + { + $return = $this->adapter->patch( + 'zones/' . $zoneID . '/settings/always_online', + [ + 'value' => $value, + ] + ); + $body = json_decode($return->getBody()); + + if ($body->success) { + return true; + } + + return false; + } + + public function updateEmailObfuscationSetting($zoneID, $value) + { + $return = $this->adapter->patch( + 'zones/' . $zoneID . '/settings/email_obfuscation', + [ + 'value' => $value, + ] + ); + $body = json_decode($return->getBody()); + + if ($body->success) { + return true; + } + + return false; + } + + public function updateHotlinkProtectionSetting($zoneID, $value) + { + $return = $this->adapter->patch( + 'zones/' . $zoneID . '/settings/hotlink_protection', + [ + 'value' => $value, + ] + ); + $body = json_decode($return->getBody()); + + if ($body->success) { + return true; + } + + return false; + } +}