Skip to content

Commit 78eadb9

Browse files
authored
Merge pull request #80 from smalot/smalot-feature-cache-level
Feature: Add cache level methods
2 parents e1c2539 + 6acf09b commit 78eadb9

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/Endpoints/Zones.php

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,38 @@ public function changeDevelopmentMode(string $zoneID, bool $enable = false): boo
153153
return false;
154154
}
155155

156+
/**
157+
* Return caching level settings
158+
* @param string $zoneID
159+
* @return string
160+
*/
161+
public function getCachingLevel(string $zoneID): string
162+
{
163+
$response = $this->adapter->get('zones/' . $zoneID . '/settings/cache_level');
164+
165+
$this->body = json_decode($response->getBody());
166+
167+
return $this->body->result->value;
168+
}
169+
170+
/**
171+
* Change caching level settings
172+
* @param string $zoneID
173+
* @param string $level (aggressive | basic | simplified)
174+
* @return bool
175+
*/
176+
public function setCachingLevel(string $zoneID, string $level = 'aggressive'): bool
177+
{
178+
$response = $this->adapter->patch('zones/' . $zoneID . '/settings/cache_level', ['value' => $level]);
179+
180+
$this->body = json_decode($response->getBody());
181+
182+
if ($this->body->success) {
183+
return true;
184+
}
185+
186+
return false;
187+
}
156188

157189
/**
158190
* Purge Everything

0 commit comments

Comments
 (0)