Skip to content

Commit 2a39298

Browse files
authored
Merge pull request #8 from cloudflare/COM-45
COM-45 :: Change API submission type to JSON and adjust function names
2 parents a4ddb61 + 121209e commit 2a39298

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

src/Adapter/Guzzle.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function put(String $uri, array $headers = array(), array $body = array()
7171

7272
$response = $this->client->put($uri, [
7373
'headers' => $headers,
74-
'body' => $jsonBody
74+
'json' => $jsonBody
7575
]
7676
);
7777

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

8989
$response = $this->client->patch($uri, [
9090
'headers' => $headers,
91-
'body' => $jsonBody
91+
'json' => $jsonBody
9292
]
9393
);
9494

@@ -103,7 +103,7 @@ public function delete(String $uri, array $headers = array(), array $body = arra
103103
{
104104
$response = $this->client->delete($uri, [
105105
'headers' => $headers,
106-
'form_params' => $body
106+
'json' => $body
107107
]
108108
);
109109

src/Endpoints/Zones.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public function getZoneID(string $name = ""): string
108108
* @param string $zoneID
109109
* @return bool
110110
*/
111-
public function purgeAll(string $zoneID): bool
111+
public function cachePurgeEverything(string $zoneID): bool
112112
{
113113
$user = $this->adapter->delete('zones/' . $zoneID . '/purge_cache', [], ["purge_everything" => true]);
114114

@@ -121,7 +121,7 @@ public function purgeAll(string $zoneID): bool
121121
return false;
122122
}
123123

124-
public function purge(string $zoneID, array $files = [], array $tags = []): bool
124+
public function cachePurge(string $zoneID, array $files = [], array $tags = []): bool
125125
{
126126
if (empty($files) && empty($tags)) {
127127
throw new EndpointException("No files or tags to purge.");

tests/Adapter/GuzzleTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public function testPut()
5858
$this->assertEquals("application/json", $headers["Content-Type"][0]);
5959

6060
$body = json_decode($response->getBody());
61-
$this->assertEquals("Testing a PUT request.", $body->json->{"X-Put-Test"});
61+
$this->assertEquals("Testing a PUT request.", json_decode($body->json)->{"X-Put-Test"});
6262
}
6363

6464
public function testPatch()
@@ -70,7 +70,7 @@ public function testPatch()
7070
$this->assertEquals("application/json", $headers["Content-Type"][0]);
7171

7272
$body = json_decode($response->getBody());
73-
$this->assertEquals("Testing a PATCH request.", $body->json->{"X-Patch-Test"});
73+
$this->assertEquals("Testing a PATCH request.", json_decode($body->json)->{"X-Patch-Test"});
7474
}
7575

7676
public function testDelete()
@@ -82,7 +82,7 @@ public function testDelete()
8282
$this->assertEquals("application/json", $headers["Content-Type"][0]);
8383

8484
$body = json_decode($response->getBody());
85-
$this->assertEquals("Testing a DELETE request.", $body->form->{"X-Delete-Test"});
85+
$this->assertEquals("Testing a DELETE request.", $body->json->{"X-Delete-Test"});
8686
}
8787

8888
public function testErrors()

tests/Endpoints/ZonesTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ public function testGetZoneID()
290290
$this->assertEquals("023e105f4ecef8ad9ca31a8372d0c353", $result);
291291
}
292292

293-
public function testPurgeAll()
293+
public function testCachePurgeEverything()
294294
{
295295
$stream = GuzzleHttp\Psr7\stream_for('{
296296
"success": true,
@@ -312,7 +312,7 @@ public function testPurgeAll()
312312
);
313313

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

317317
$this->assertTrue($result);
318318
}

0 commit comments

Comments
 (0)