Skip to content

Commit

Permalink
Merge pull request #8 from cloudflare/COM-45
Browse files Browse the repository at this point in the history
COM-45 :: Change API submission type to JSON and adjust function names
  • Loading branch information
IcyApril authored Sep 20, 2017
2 parents a4ddb61 + 121209e commit 2a39298
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions src/Adapter/Guzzle.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function put(String $uri, array $headers = array(), array $body = array()

$response = $this->client->put($uri, [
'headers' => $headers,
'body' => $jsonBody
'json' => $jsonBody
]
);

Expand All @@ -88,7 +88,7 @@ public function patch(String $uri, array $headers = array(), array $body = array

$response = $this->client->patch($uri, [
'headers' => $headers,
'body' => $jsonBody
'json' => $jsonBody
]
);

Expand All @@ -103,7 +103,7 @@ public function delete(String $uri, array $headers = array(), array $body = arra
{
$response = $this->client->delete($uri, [
'headers' => $headers,
'form_params' => $body
'json' => $body
]
);

Expand Down
4 changes: 2 additions & 2 deletions src/Endpoints/Zones.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public function getZoneID(string $name = ""): string
* @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]);

Expand All @@ -121,7 +121,7 @@ public function purgeAll(string $zoneID): bool
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.");
Expand Down
6 changes: 3 additions & 3 deletions tests/Adapter/GuzzleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function testPut()
$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()
Expand All @@ -70,7 +70,7 @@ public function testPatch()
$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()
Expand All @@ -82,7 +82,7 @@ public function testDelete()
$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()
Expand Down
4 changes: 2 additions & 2 deletions tests/Endpoints/ZonesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ public function testGetZoneID()
$this->assertEquals("023e105f4ecef8ad9ca31a8372d0c353", $result);
}

public function testPurgeAll()
public function testCachePurgeEverything()
{
$stream = GuzzleHttp\Psr7\stream_for('{
"success": true,
Expand All @@ -312,7 +312,7 @@ public function testPurgeAll()
);

$zones = new \Cloudflare\API\Endpoints\Zones($mock);
$result = $zones->purgeAll("c2547eb745079dac9320b638f5e225cf483cc5cfdda41");
$result = $zones->cachePurgeEverything("c2547eb745079dac9320b638f5e225cf483cc5cfdda41");

$this->assertTrue($result);
}
Expand Down

0 comments on commit 2a39298

Please sign in to comment.