44
55use Cloudflare \API \Adapter \Adapter ;
66use Cloudflare \API \Configurations \Configurations ;
7+ use Cloudflare \API \Traits \BodyAccessorTrait ;
78
89class AccessRules implements API
910{
11+ use BodyAccessorTrait;
12+
1013 private $ adapter ;
1114
1215 public function __construct (Adapter $ adapter )
@@ -78,9 +81,9 @@ public function listRules(
7881 }
7982
8083 $ data = $ this ->adapter ->get ('zones/ ' . $ zoneID . '/firewall/access_rules/rules ' , $ query );
81- $ body = json_decode ($ data ->getBody ());
84+ $ this -> body = json_decode ($ data ->getBody ());
8285
83- return (object )['result ' => $ body ->result , 'result_info ' => $ body ->result_info ];
86+ return (object )['result ' => $ this -> body ->result , 'result_info ' => $ this -> body ->result_info ];
8487 }
8588
8689 public function createRule (
@@ -100,9 +103,9 @@ public function createRule(
100103
101104 $ query = $ this ->adapter ->post ('zones/ ' . $ zoneID . '/firewall/access_rules/rules ' , $ options );
102105
103- $ body = json_decode ($ query ->getBody ());
106+ $ this -> body = json_decode ($ query ->getBody ());
104107
105- if (isset ($ body ->result ->id )) {
108+ if (isset ($ this -> body ->result ->id )) {
106109 return true ;
107110 }
108111
@@ -125,9 +128,9 @@ public function updateRule(
125128
126129 $ query = $ this ->adapter ->patch ('zones/ ' . $ zoneID . '/firewall/access_rules/rules/ ' . $ ruleID , $ options );
127130
128- $ body = json_decode ($ query ->getBody ());
131+ $ this -> body = json_decode ($ query ->getBody ());
129132
130- if (isset ($ body ->result ->id )) {
133+ if (isset ($ this -> body ->result ->id )) {
131134 return true ;
132135 }
133136
@@ -142,9 +145,9 @@ public function deleteRule(string $zoneID, string $ruleID, string $cascade = 'no
142145
143146 $ data = $ this ->adapter ->delete ('zones/ ' . $ zoneID . '/firewall/access_rules/rules/ ' . $ ruleID , $ options );
144147
145- $ body = json_decode ($ data ->getBody ());
148+ $ this -> body = json_decode ($ data ->getBody ());
146149
147- if (isset ($ body ->result ->id )) {
150+ if (isset ($ this -> body ->result ->id )) {
148151 return true ;
149152 }
150153
0 commit comments