From f2e0d6cbe3e3fd57fb7d33aabc61f86fda7e427e Mon Sep 17 00:00:00 2001 From: Abhay Saraf Date: Tue, 28 Jan 2020 15:26:35 +0530 Subject: [PATCH] Adding new function editPageRule to allow put method to support removal of rule settings or rule action items from the page rule which is not supported by updatePageRule. --- src/Endpoints/PageRules.php | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/Endpoints/PageRules.php b/src/Endpoints/PageRules.php index c8480f4..c7e5964 100644 --- a/src/Endpoints/PageRules.php +++ b/src/Endpoints/PageRules.php @@ -109,6 +109,37 @@ class PageRules implements API return $this->body->result; } + public function editPageRule( + string $zoneID, + string $ruleID, + PageRulesTargets $target, + PageRulesActions $actions, + bool $active = null, + int $priority = null + ): bool { + $options = []; + $options['targets'] = $target->getArray(); + $options['actions'] = $actions->getArray(); + + if ($active !== null) { + $options['status'] = $active == true ? 'active' : 'disabled'; + } + + if ($priority !== null) { + $options['priority'] = $priority; + } + + $query = $this->adapter->put('zones/' . $zoneID . '/pagerules/' . $ruleID, $options); + + $this->body = json_decode($query->getBody()); + + if (isset($this->body->result->id)) { + return true; + } + + return false; + } + public function updatePageRule( string $zoneID, string $ruleID,