99namespace Cloudflare \API \Endpoints ;
1010
1111use Cloudflare \API \Adapter \Adapter ;
12+ use Cloudflare \API \Traits \BodyAccessorTrait ;
1213
1314class CustomHostnames implements API
1415{
16+ use BodyAccessorTrait;
17+
1518 private $ adapter ;
1619
1720 public function __construct (Adapter $ adapter )
@@ -40,8 +43,8 @@ public function addHostname(string $zoneID, string $hostname, string $sslMethod
4043 ];
4144
4245 $ zone = $ this ->adapter ->post ('zones/ ' .$ zoneID .'/custom_hostnames ' , $ options );
43- $ body = json_decode ($ zone ->getBody ());
44- return $ body ->result ;
46+ $ this -> body = json_decode ($ zone ->getBody ());
47+ return $ this -> body ->result ;
4548 }
4649
4750 /**
@@ -88,9 +91,9 @@ public function listHostnames(
8891 }
8992
9093 $ zone = $ this ->adapter ->get ('zones/ ' .$ zoneID .'/custom_hostnames ' , $ query );
91- $ body = json_decode ($ zone ->getBody ());
94+ $ this -> body = json_decode ($ zone ->getBody ());
9295
93- return (object )['result ' => $ body ->result , 'result_info ' => $ body ->result_info ];
96+ return (object )['result ' => $ this -> body ->result , 'result_info ' => $ this -> body ->result_info ];
9497 }
9598
9699 /**
@@ -101,9 +104,9 @@ public function listHostnames(
101104 public function getHostname (string $ zoneID , string $ hostnameID )
102105 {
103106 $ zone = $ this ->adapter ->get ('zones/ ' .$ zoneID .'/custom_hostnames/ ' .$ hostnameID );
104- $ body = json_decode ($ zone ->getBody ());
107+ $ this -> body = json_decode ($ zone ->getBody ());
105108
106- return $ body ->result ;
109+ return $ this -> body ->result ;
107110 }
108111
109112 /**
@@ -132,8 +135,8 @@ public function updateHostname(string $zoneID, string $hostnameID, string $sslMe
132135 ];
133136
134137 $ zone = $ this ->adapter ->patch ('zones/ ' .$ zoneID .'/custom_hostnames/ ' .$ hostnameID , $ options );
135- $ body = json_decode ($ zone ->getBody ());
136- return $ body ->result ;
138+ $ this -> body = json_decode ($ zone ->getBody ());
139+ return $ this -> body ->result ;
137140 }
138141
139142 /**
@@ -144,7 +147,7 @@ public function updateHostname(string $zoneID, string $hostnameID, string $sslMe
144147 public function deleteHostname (string $ zoneID , string $ hostnameID ): \stdClass
145148 {
146149 $ zone = $ this ->adapter ->delete ('zones/ ' .$ zoneID .'/custom_hostnames/ ' .$ hostnameID );
147- $ body = json_decode ($ zone ->getBody ());
148- return $ body ;
150+ $ this -> body = json_decode ($ zone ->getBody ());
151+ return $ this -> body ;
149152 }
150153}
0 commit comments