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.

This commit is contained in:
Abhay Saraf
2020-01-28 15:26:35 +05:30
parent 7276b61e20
commit f2e0d6cbe3

View File

@@ -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,