From 6acf09ba822df411e788b2e493044982dc9a3eb2 Mon Sep 17 00:00:00 2001 From: Sebastien MALOT Date: Sun, 27 Jan 2019 14:53:16 +0100 Subject: [PATCH] Feature: Add cache level methods Add `getCachingLevel` and `setCachingLevel` methods --- src/Endpoints/Zones.php | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/Endpoints/Zones.php b/src/Endpoints/Zones.php index 8595cb6..68ec257 100644 --- a/src/Endpoints/Zones.php +++ b/src/Endpoints/Zones.php @@ -144,6 +144,38 @@ class Zones implements API return false; } + /** + * Return caching level settings + * @param string $zoneID + * @return string + */ + public function getCachingLevel(string $zoneID): string + { + $response = $this->adapter->get('zones/' . $zoneID . '/settings/cache_level'); + + $this->body = json_decode($response->getBody()); + + return $this->body->result->value; + } + + /** + * Change caching level settings + * @param string $zoneID + * @param string $level (aggressive | basic | simplified) + * @return bool + */ + public function setCachingLevel(string $zoneID, string $level = 'aggressive'): bool + { + $response = $this->adapter->patch('zones/' . $zoneID . '/settings/cache_level', ['value' => $level]); + + $this->body = json_decode($response->getBody()); + + if ($this->body->success) { + return true; + } + + return false; + } /** * Purge Everything