diff --git a/src/Endpoints/CustomHostnames.php b/src/Endpoints/CustomHostnames.php index b16397b2..7a0d2de3 100644 --- a/src/Endpoints/CustomHostnames.php +++ b/src/Endpoints/CustomHostnames.php @@ -143,16 +143,33 @@ public function getHostname(string $zoneID, string $hostnameID) /** * @SuppressWarnings(PHPMD.BooleanArgumentFlag) + * @SuppressWarnings(PHPMD.CyclomaticComplexity) + * @SuppressWarnings(PHPMD.NPathComplexity) * - * @param string $zoneID - * @param string $hostnameID - * @param string $sslMethod - * @param string $sslType + * @param string $zoneID + * @param string $hostnameID + * @param string $sslMethod + * @param string $sslType + * @param array $sslSettings + * @param string $customOriginServer + * @param bool|null $wildcard + * @param string $bundleMethod + * @param array $customSsl * @return \stdClass */ - public function updateHostname(string $zoneID, string $hostnameID, string $sslMethod = '', string $sslType = '', array $sslSettings = [], string $customOriginServer = ''): \stdClass - { + public function updateHostname( + string $zoneID, + string $hostnameID, + string $sslMethod = '', + string $sslType = '', + array $sslSettings = [], + string $customOriginServer = '', + bool $wildcard = null, + string $bundleMethod = '', + array $customSsl = [] + ): \stdClass { $query = []; + $options = []; if (!empty($sslMethod)) { $query['method'] = $sslMethod; @@ -166,6 +183,22 @@ public function updateHostname(string $zoneID, string $hostnameID, string $sslMe $query['settings'] = $sslSettings; } + if (!is_null($wildcard)) { + $query['wildcard'] = $wildcard; + } + + if (!empty($bundleMethod)) { + $query['bundle_method'] = $bundleMethod; + } + + if (!empty($customSsl['key'])) { + $query['custom_key'] = $customSsl['key']; + } + + if (!empty($customSsl['certificate'])) { + $query['custom_certificate'] = $customSsl['certificate']; + } + if (!empty($query)) { $options = [ 'ssl' => $query diff --git a/tests/Endpoints/CustomHostnamesTest.php b/tests/Endpoints/CustomHostnamesTest.php index fb3a032a..f8cf990b 100644 --- a/tests/Endpoints/CustomHostnamesTest.php +++ b/tests/Endpoints/CustomHostnamesTest.php @@ -121,6 +121,8 @@ public function testUpdateHostname() { $response = $this->getPsr7JsonResponseForFixture('Endpoints/updateHostname.json'); + $customSsl = $this->getCustomSsl(); + $mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock(); $mock->method('patch')->willReturn($response); @@ -137,7 +139,12 @@ public function testUpdateHostname() 'http2' => 'on', 'http3' => 'on', 'min_tls_version' => '1.2' - ] + ], + 'bundle_method' => 'optimal', + 'custom_key' => $customSsl['key'], + 'custom_certificate' => $customSsl['certificate'], + 'wildcard' => true, + ] ]) ); @@ -148,7 +155,21 @@ public function testUpdateHostname() 'http3' => 'on', 'min_tls_version' => '1.2' ]; - $result = $zones->updateHostname('023e105f4ecef8ad9ca31a8372d0c353', '0d89c70d-ad9f-4843-b99f-6cc0252067e9', 'http', 'dv', $sslSettings, 'origin.example.com'); + + $result = $zones->updateHostname( + '023e105f4ecef8ad9ca31a8372d0c353', + '0d89c70d-ad9f-4843-b99f-6cc0252067e9', + 'http', + 'dv', + $sslSettings, + 'origin.example.com', + true, + 'optimal', + [ + 'key' => $customSsl['key'], + 'certificate' => $customSsl['certificate'], + ] + ); $this->assertObjectHasAttribute('id', $result); $this->assertObjectHasAttribute('hostname', $result); @@ -194,7 +215,7 @@ public function testGetHostnameFallbackOrigin() $this->assertObjectHasAttribute('origin', $result); $this->assertObjectHasAttribute('status', $result); } - + private function getCustomSsl(): array { $customKey = <<