1010
1111use Cloudflare \API \Configurations \Configurations ;
1212use Cloudflare \API \Adapter \Adapter ;
13+ use Cloudflare \API \Traits \BodyAccessorTrait ;
1314
1415class UARules implements API
1516{
17+ use BodyAccessorTrait;
18+
1619 private $ adapter ;
1720
1821 public function __construct (Adapter $ adapter )
@@ -31,9 +34,9 @@ public function listRules(
3134 ];
3235
3336 $ user = $ this ->adapter ->get ('zones/ ' . $ zoneID . '/firewall/ua_rules ' , $ query );
34- $ body = json_decode ($ user ->getBody ());
37+ $ this -> body = json_decode ($ user ->getBody ());
3538
36- return (object )['result ' => $ body ->result , 'result_info ' => $ body ->result_info ];
39+ return (object )['result ' => $ this -> body ->result , 'result_info ' => $ this -> body ->result_info ];
3740 }
3841
3942 public function createRule (
@@ -58,9 +61,9 @@ public function createRule(
5861
5962 $ user = $ this ->adapter ->post ('zones/ ' . $ zoneID . '/firewall/ua_rules ' , $ options );
6063
61- $ body = json_decode ($ user ->getBody ());
64+ $ this -> body = json_decode ($ user ->getBody ());
6265
63- if (isset ($ body ->result ->id )) {
66+ if (isset ($ this -> body ->result ->id )) {
6467 return true ;
6568 }
6669
@@ -70,8 +73,8 @@ public function createRule(
7073 public function getRuleDetails (string $ zoneID , string $ blockID ): \stdClass
7174 {
7275 $ user = $ this ->adapter ->get ('zones/ ' . $ zoneID . '/firewall/ua_rules/ ' . $ blockID );
73- $ body = json_decode ($ user ->getBody ());
74- return $ body ->result ;
76+ $ this -> body = json_decode ($ user ->getBody ());
77+ return $ this -> body ->result ;
7578 }
7679
7780 public function updateRule (
@@ -93,9 +96,9 @@ public function updateRule(
9396
9497 $ user = $ this ->adapter ->put ('zones/ ' . $ zoneID . '/firewall/ua_rules/ ' . $ ruleID , $ options );
9598
96- $ body = json_decode ($ user ->getBody ());
99+ $ this -> body = json_decode ($ user ->getBody ());
97100
98- if (isset ($ body ->result ->id )) {
101+ if (isset ($ this -> body ->result ->id )) {
99102 return true ;
100103 }
101104
@@ -106,9 +109,9 @@ public function deleteRule(string $zoneID, string $ruleID): bool
106109 {
107110 $ user = $ this ->adapter ->delete ('zones/ ' . $ zoneID . '/firewall/ua_rules/ ' . $ ruleID );
108111
109- $ body = json_decode ($ user ->getBody ());
112+ $ this -> body = json_decode ($ user ->getBody ());
110113
111- if (isset ($ body ->result ->id )) {
114+ if (isset ($ this -> body ->result ->id )) {
112115 return true ;
113116 }
114117
0 commit comments