8 Commits
1.0.0 ... 1.0.2

Author SHA1 Message Date
Junade
f38b1c61f7 Merge pull request #10 from cloudflare/COM-45
COM-45 :: Bugfix active status in Page Rules
2017-09-20 15:00:53 +01:00
Junade Ali
635a299b43 COM-45 :: Update PageRule tests. 2017-09-20 14:55:44 +01:00
Junade Ali
85d64f8afc COM-45 :: Bugfix active status in Page Rules 2017-09-20 14:50:55 +01:00
Junade
48db6337c5 Merge pull request #9 from cloudflare/COM-45
COM-45 :: Bugfix Page Rules class
2017-09-20 14:35:25 +01:00
Junade Ali
4699270f51 COM-45 :: Bugfix Page Rules class 2017-09-20 14:32:46 +01:00
Junade
2a3929824e Merge pull request #8 from cloudflare/COM-45
COM-45 :: Change API submission type to JSON and adjust function names
2017-09-20 13:36:44 +01:00
Junade Ali
121209e4ca COM-45 :: Adjust Guzzle Tests 2017-09-20 13:25:00 +01:00
Junade Ali
1baeeee882 COM-40 :: Change API submission type to JSON and adjust function names 2017-09-20 13:15:34 +01:00
6 changed files with 18 additions and 22 deletions

View File

@@ -71,7 +71,7 @@ class Guzzle implements Adapter
$response = $this->client->put($uri, [
'headers' => $headers,
'body' => $jsonBody
'json' => $jsonBody
]
);
@@ -88,7 +88,7 @@ class Guzzle implements Adapter
$response = $this->client->patch($uri, [
'headers' => $headers,
'body' => $jsonBody
'json' => $jsonBody
]
);
@@ -103,7 +103,7 @@ class Guzzle implements Adapter
{
$response = $this->client->delete($uri, [
'headers' => $headers,
'form_params' => $body
'json' => $body
]
);

View File

@@ -35,7 +35,7 @@ class PageRules implements API
];
if ($active !== null) {
$options['active'] = $active == true ? 'active' : 'disabled';
$options['status'] = $active == true ? 'active' : 'disabled';
}
if ($priority !== null) {
@@ -60,7 +60,7 @@ class PageRules implements API
string $order = null,
string $direction = null,
string $match = null
): \stdClass {
): array {
if (is_null($status) && !in_array($status, ['active', 'disabled'])) {
throw new EndpointException('Page Rules can only be listed by status of active or disabled.');
}
@@ -89,11 +89,7 @@ class PageRules implements API
$user = $this->adapter->get('zones/' . $zoneID . '/pagerules?' . $query, []);
$body = json_decode($user->getBody());
$result = new \stdClass();
$result->result = $body->result;
$result->result_info = $body->result_info;
return $result;
return $body->result;
}
public function getPageRuleDetails(string $zoneID, string $ruleID): \stdClass
@@ -121,7 +117,7 @@ class PageRules implements API
}
if ($active !== null) {
$options['active'] = $active == true ? 'active' : 'disabled';
$options['status'] = $active == true ? 'active' : 'disabled';
}
if ($priority !== null) {

View File

@@ -108,7 +108,7 @@ class Zones implements API
* @param string $zoneID
* @return bool
*/
public function purgeAll(string $zoneID): bool
public function cachePurgeEverything(string $zoneID): bool
{
$user = $this->adapter->delete('zones/' . $zoneID . '/purge_cache', [], ["purge_everything" => true]);
@@ -121,7 +121,7 @@ class Zones implements API
return false;
}
public function purge(string $zoneID, array $files = [], array $tags = []): bool
public function cachePurge(string $zoneID, array $files = [], array $tags = []): bool
{
if (empty($files) && empty($tags)) {
throw new EndpointException("No files or tags to purge.");

View File

@@ -58,7 +58,7 @@ class GuzzleTest extends PHPUnit_Framework_TestCase
$this->assertEquals("application/json", $headers["Content-Type"][0]);
$body = json_decode($response->getBody());
$this->assertEquals("Testing a PUT request.", $body->json->{"X-Put-Test"});
$this->assertEquals("Testing a PUT request.", json_decode($body->json)->{"X-Put-Test"});
}
public function testPatch()
@@ -70,7 +70,7 @@ class GuzzleTest extends PHPUnit_Framework_TestCase
$this->assertEquals("application/json", $headers["Content-Type"][0]);
$body = json_decode($response->getBody());
$this->assertEquals("Testing a PATCH request.", $body->json->{"X-Patch-Test"});
$this->assertEquals("Testing a PATCH request.", json_decode($body->json)->{"X-Patch-Test"});
}
public function testDelete()
@@ -82,7 +82,7 @@ class GuzzleTest extends PHPUnit_Framework_TestCase
$this->assertEquals("application/json", $headers["Content-Type"][0]);
$body = json_decode($response->getBody());
$this->assertEquals("Testing a DELETE request.", $body->form->{"X-Delete-Test"});
$this->assertEquals("Testing a DELETE request.", $body->json->{"X-Delete-Test"});
}
public function testErrors()

View File

@@ -57,8 +57,8 @@ class PageRulesTest extends PHPUnit_Framework_TestCase
$this->equalTo([
'targets' => $target->getArray(),
'actions' => $action->getArray(),
'active' => 'active',
'priority' => '1'
'status' => 'active',
'priority' => 1
])
);
@@ -217,8 +217,8 @@ class PageRulesTest extends PHPUnit_Framework_TestCase
$this->equalTo([
'targets' => $target->getArray(),
'actions' => $action->getArray(),
'active' => 'active',
'priority' => '1'
'status' => 'active',
'priority' => 1
])
);

View File

@@ -290,7 +290,7 @@ class ZonesTest extends PHPUnit_Framework_TestCase
$this->assertEquals("023e105f4ecef8ad9ca31a8372d0c353", $result);
}
public function testPurgeAll()
public function testCachePurgeEverything()
{
$stream = GuzzleHttp\Psr7\stream_for('{
"success": true,
@@ -312,7 +312,7 @@ class ZonesTest extends PHPUnit_Framework_TestCase
);
$zones = new \Cloudflare\API\Endpoints\Zones($mock);
$result = $zones->purgeAll("c2547eb745079dac9320b638f5e225cf483cc5cfdda41");
$result = $zones->cachePurgeEverything("c2547eb745079dac9320b638f5e225cf483cc5cfdda41");
$this->assertTrue($result);
}