-
Notifications
You must be signed in to change notification settings - Fork 231
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #92 from exportsmedia/feature-crypto-endpoints
Add Crypto endpoints to crypto.php, update TLS.php
- Loading branch information
Showing
19 changed files
with
684 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
<?php | ||
|
||
namespace Cloudflare\API\Endpoints; | ||
|
||
use Cloudflare\API\Adapter\Adapter; | ||
|
||
class Crypto implements API | ||
{ | ||
private $adapter; | ||
|
||
public function __construct(Adapter $adapter) | ||
{ | ||
$this->adapter = $adapter; | ||
} | ||
|
||
/** | ||
* Get the Opportunistic Encryption feature for a zone. | ||
* | ||
* @param string $zoneID The ID of the zone | ||
* @return string|false | ||
*/ | ||
public function getOpportunisticEncryptionSetting(string $zoneID) | ||
{ | ||
$return = $this->adapter->get( | ||
'zones/' . $zoneID . '/settings/opportunistic_encryption' | ||
); | ||
$body = json_decode($return->getBody()); | ||
if (isset($body->result)) { | ||
return $body->result->value; | ||
} | ||
return false; | ||
} | ||
|
||
/** | ||
* Get the Onion Routing feature for a zone. | ||
* | ||
* @param string $zoneID The ID of the zone | ||
* @return string|false | ||
*/ | ||
public function getOnionRoutingSetting(string $zoneID) | ||
{ | ||
$return = $this->adapter->get( | ||
'zones/' . $zoneID . '/settings/opportunistic_onion' | ||
); | ||
$body = json_decode($return->getBody()); | ||
if (isset($body->result)) { | ||
return $body->result; | ||
} | ||
return false; | ||
} | ||
|
||
/** | ||
* Update the Oppurtunistic Encryption setting for the zone | ||
* | ||
* @param string $zoneID The ID of the zone | ||
* @param string $value The value of the zone setting | ||
* @return bool | ||
*/ | ||
public function updateOpportunisticEncryptionSetting(string $zoneID, string $value) | ||
{ | ||
$return = $this->adapter->patch( | ||
'zones/' . $zoneID . '/settings/opportunistic_encryption', | ||
[ | ||
'value' => $value, | ||
] | ||
); | ||
$body = json_decode($return->getBody()); | ||
if (isset($body->success) && $body->success == true) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
/** | ||
* Update the Onion Routing setting for the zone | ||
* | ||
* @param string $zoneID The ID of the zone | ||
* @param string $value The value of the zone setting | ||
* @return bool | ||
*/ | ||
public function updateOnionRoutingSetting(string $zoneID, string $value) | ||
{ | ||
$return = $this->adapter->patch( | ||
'zones/' . $zoneID . '/settings/opportunistic_onion', | ||
[ | ||
'value' => $value, | ||
] | ||
); | ||
$body = json_decode($return->getBody()); | ||
if (isset($body->success) && $body->success == true) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
<?php | ||
|
||
namespace Cloudflare\API\Endpoints; | ||
|
||
use Cloudflare\API\Adapter\Adapter; | ||
|
||
class SSL implements API | ||
{ | ||
private $adapter; | ||
|
||
public function __construct(Adapter $adapter) | ||
{ | ||
$this->adapter = $adapter; | ||
} | ||
|
||
/** | ||
* Get the SSL setting for the zone | ||
* | ||
* @param string $zoneID The ID of the zone | ||
* @return string|false | ||
*/ | ||
public function getSSLSetting(string $zoneID) | ||
{ | ||
$return = $this->adapter->get( | ||
'zones/' . $zoneID . '/settings/ssl' | ||
); | ||
$body = json_decode($return->getBody()); | ||
if (isset($body->result)) { | ||
return $body->result->value; | ||
} | ||
return false; | ||
} | ||
|
||
/** | ||
* Get SSL Verification Info for a Zone | ||
* | ||
* @param string $zoneID The ID of the zone | ||
* @return array|false | ||
*/ | ||
public function getSSLVerificationStatus(string $zoneID) | ||
{ | ||
$return = $this->adapter->get( | ||
'zones/' . $zoneID . '/ssl/verification' | ||
); | ||
$body = json_decode($return->getBody()); | ||
if (isset($body->result)) { | ||
return $body; | ||
} | ||
return false; | ||
} | ||
|
||
/** | ||
* Get the HTTPS Redirect setting for the zone | ||
* | ||
* @param string $zoneID The ID of the zone | ||
* @return string|false | ||
*/ | ||
public function getHTTPSRedirectSetting(string $zoneID) | ||
{ | ||
$return = $this->adapter->get( | ||
'zones/' . $zoneID . '/settings/always_use_https' | ||
); | ||
$body = json_decode($return->getBody()); | ||
if (isset($body->result)) { | ||
return $body->result; | ||
} | ||
return false; | ||
} | ||
|
||
/** | ||
* Get the HTTPS Rewrite setting for the zone | ||
* | ||
* @param string $zoneID The ID of the zone | ||
* @return string|false | ||
*/ | ||
public function getHTTPSRewritesSetting(string $zoneID) | ||
{ | ||
$return = $this->adapter->get( | ||
'zones/' . $zoneID . '/settings/automatic_https_rewrites' | ||
); | ||
$body = json_decode($return->getBody()); | ||
if (isset($body->result)) { | ||
return $body->result; | ||
} | ||
return false; | ||
} | ||
|
||
/** | ||
* Update the SSL setting for the zone | ||
* | ||
* @param string $zoneID The ID of the zone | ||
* @param string $value The value of the zone setting | ||
* @return bool | ||
*/ | ||
public function updateSSLSetting(string $zoneID, string $value) | ||
{ | ||
$return = $this->adapter->patch( | ||
'zones/' . $zoneID . '/settings/ssl', | ||
[ | ||
'value' => $value, | ||
] | ||
); | ||
$body = json_decode($return->getBody()); | ||
if (isset($body->success) && $body->success == true) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
/** | ||
* Update the HTTPS Redirect setting for the zone | ||
* | ||
* @param string $zoneID The ID of the zone | ||
* @param string $value The value of the zone setting | ||
* @return bool | ||
*/ | ||
public function updateHTTPSRedirectSetting(string $zoneID, string $value) | ||
{ | ||
$return = $this->adapter->patch( | ||
'zones/' . $zoneID . '/settings/always_use_https', | ||
[ | ||
'value' => $value, | ||
] | ||
); | ||
$body = json_decode($return->getBody()); | ||
if (isset($body->success) && $body->success == true) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
/** | ||
* Update the HTTPS Rewrite setting for the zone | ||
* | ||
* @param string $zoneID The ID of the zone | ||
* @param string $value The value of the zone setting | ||
* @return bool | ||
*/ | ||
public function updateHTTPSRewritesSetting(string $zoneID, string $value) | ||
{ | ||
$return = $this->adapter->patch( | ||
'zones/' . $zoneID . '/settings/automatic_https_rewrites', | ||
[ | ||
'value' => $value, | ||
] | ||
); | ||
$body = json_decode($return->getBody()); | ||
if (isset($body->success) && $body->success == true) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
} |
Oops, something went wrong.