Add More Custom Hostname Creation Parameters

This now matches what is available as per the documentation
This commit is contained in:
Phil Young
2021-06-15 00:49:14 +01:00
parent 1e58a65888
commit c639f20cea
2 changed files with 78 additions and 5 deletions

View File

@@ -14,7 +14,7 @@ use Cloudflare\API\Traits\BodyAccessorTrait;
class CustomHostnames implements API
{
use BodyAccessorTrait;
private $adapter;
public function __construct(Adapter $adapter)
@@ -30,12 +30,15 @@ class CustomHostnames implements API
* @param string $hostname
* @param string $sslMethod
* @param string $sslType
* @param array $sslSettings
* @param array $sslSettings
* @param string $customOriginServer
* @param bool $wildcard
* @param bool $wildcard
* @param string $bundleMethod
* @param string $customKey
* @param string $customCertificate
* @return \stdClass
*/
public function addHostname(string $zoneID, string $hostname, string $sslMethod = 'http', string $sslType = 'dv', array $sslSettings = [], string $customOriginServer = '', bool $wildcard = false): \stdClass
public function addHostname(string $zoneID, string $hostname, string $sslMethod = 'http', string $sslType = 'dv', array $sslSettings = [], string $customOriginServer = '', bool $wildcard = false, string $bundleMethod = '', string $customKey = '', string $customCertificate = ''): \stdClass
{
$options = [
'hostname' => $hostname,
@@ -51,6 +54,18 @@ class CustomHostnames implements API
$options['custom_origin_server'] = $customOriginServer;
}
if (empty($bundleMethod) === false) {
$options['bundle_method'] = $bundleMethod;
}
if (empty($customKey) === false) {
$options['custom_key'] = $customKey;
}
if (empty($customCertificate) === false) {
$options['custom_certificate'] = $customCertificate;
}
$zone = $this->adapter->post('zones/'.$zoneID.'/custom_hostnames', $options);
$this->body = json_decode($zone->getBody());
return $this->body->result;