diff --git a/src/Endpoints/CustomHostnames.php b/src/Endpoints/CustomHostnames.php index 7540365..b16397b 100644 --- a/src/Endpoints/CustomHostnames.php +++ b/src/Endpoints/CustomHostnames.php @@ -192,4 +192,16 @@ class CustomHostnames implements API $this->body = json_decode($zone->getBody()); return $this->body; } + + /** + * @param string $zoneID + * @return \stdClass + */ + public function getFallbackOrigin(string $zoneID): \stdClass + { + $zone = $this->adapter->get('zones/'.$zoneID.'/custom_hostnames/fallback_origin'); + $this->body = json_decode($zone->getBody()); + + return $this->body->result; + } } diff --git a/tests/Endpoints/CustomHostnamesTest.php b/tests/Endpoints/CustomHostnamesTest.php index f3fae3d..484c206 100644 --- a/tests/Endpoints/CustomHostnamesTest.php +++ b/tests/Endpoints/CustomHostnamesTest.php @@ -175,6 +175,26 @@ class CustomHostnamesTest extends TestCase $this->assertEquals('0d89c70d-ad9f-4843-b99f-6cc0252067e9', $zones->getBody()->id); } + public function testGetHostnameFallbackOrigin() + { + $response = $this->getPsr7JsonResponseForFixture('Endpoints/getCustomHostnameFallbackOrigin.json'); + + $mock = $this->getMockBuilder(\Cloudflare\API\Adapter\Adapter::class)->getMock(); + $mock->method('get')->willReturn($response); + + $mock->expects($this->once()) + ->method('get') + ->with( + $this->equalTo('zones/023e105f4ecef8ad9ca31a8372d0c353/custom_hostnames/fallback_origin') + ); + + $zones = new \Cloudflare\API\Endpoints\CustomHostnames($mock); + $result = $zones->getFallbackOrigin('023e105f4ecef8ad9ca31a8372d0c353'); + + $this->assertObjectHasAttribute('origin', $result); + $this->assertObjectHasAttribute('status', $result); + } + private function getCustomSsl(): array { $customKey = <<