Add Browser Cache TTL endpoint (#127)
Co-authored-by: bnalonezi <b.alenezi@zid.sa>
This commit is contained in:
@@ -106,6 +106,37 @@ class ZoneSettings implements API
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getBrowserCacheTtlSetting($zoneID)
|
||||||
|
{
|
||||||
|
$return = $this->adapter->get(
|
||||||
|
'zones/' . $zoneID . '/settings/browser_cache_ttl'
|
||||||
|
);
|
||||||
|
$body = json_decode($return->getBody());
|
||||||
|
|
||||||
|
if ($body->success) {
|
||||||
|
return $body->result->value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function updateBrowserCacheTtlSetting($zoneID, $value)
|
||||||
|
{
|
||||||
|
$return = $this->adapter->patch(
|
||||||
|
'zones/' . $zoneID . '/settings/browser_cache_ttl',
|
||||||
|
[
|
||||||
|
'value' => $value
|
||||||
|
]
|
||||||
|
);
|
||||||
|
$body = json_decode($return->getBody());
|
||||||
|
|
||||||
|
if ($body->success) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public function updateMinifySetting($zoneID, $html, $css, $javascript)
|
public function updateMinifySetting($zoneID, $html, $css, $javascript)
|
||||||
{
|
{
|
||||||
$return = $this->adapter->patch(
|
$return = $this->adapter->patch(
|
||||||
|
|||||||
@@ -36,4 +36,34 @@ class ZoneSettingsTest extends TestCase
|
|||||||
|
|
||||||
$this->assertSame('on', $result);
|
$this->assertSame('on', $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testGetBrowserCacheTtlSetting()
|
||||||
|
{
|
||||||
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/getBrowserCacheTtlSetting.json');
|
||||||
|
|
||||||
|
$mock = $this->getMockBuilder(Adapter::class)->getMock();
|
||||||
|
$mock->method('get')->willReturn($response);
|
||||||
|
|
||||||
|
$mock->expects($this->once())->method('get');
|
||||||
|
|
||||||
|
$zones = new ZoneSettings($mock);
|
||||||
|
$result = $zones->getBrowserCacheTtlSetting('023e105f4ecef8ad9ca31a8372d0c353');
|
||||||
|
|
||||||
|
$this->assertSame(14400, $result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testUpdateBrowserCacheTtlSetting()
|
||||||
|
{
|
||||||
|
$response = $this->getPsr7JsonResponseForFixture('Endpoints/updateBrowserCacheTtlSetting.json');
|
||||||
|
|
||||||
|
$mock = $this->getMockBuilder(Adapter::class)->getMock();
|
||||||
|
$mock->method('patch')->willReturn($response);
|
||||||
|
|
||||||
|
$mock->expects($this->once())->method('patch');
|
||||||
|
|
||||||
|
$zones = new ZoneSettings($mock);
|
||||||
|
$result = $zones->updateBrowserCacheTtlSetting('023e105f4ecef8ad9ca31a8372d0c353', 16070400);
|
||||||
|
|
||||||
|
$this->assertTrue($result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
11
tests/Fixtures/Endpoints/getBrowserCacheTtlSetting.json
Normal file
11
tests/Fixtures/Endpoints/getBrowserCacheTtlSetting.json
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"errors": [],
|
||||||
|
"messages": [],
|
||||||
|
"result": {
|
||||||
|
"id": "browser_cache_ttl",
|
||||||
|
"value": 14400,
|
||||||
|
"editable": true,
|
||||||
|
"modified_on": "2014-01-01T05:20:00.12345Z"
|
||||||
|
}
|
||||||
|
}
|
||||||
11
tests/Fixtures/Endpoints/updateBrowserCacheTtlSetting.json
Normal file
11
tests/Fixtures/Endpoints/updateBrowserCacheTtlSetting.json
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"errors": [],
|
||||||
|
"messages": [],
|
||||||
|
"result": {
|
||||||
|
"id": "browser_cache_ttl",
|
||||||
|
"value": 14400,
|
||||||
|
"editable": true,
|
||||||
|
"modified_on": "2014-01-01T05:20:00.12345Z"
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user