mirror of
https://github.com/bitinflow/bunny-cli.git
synced 2026-03-13 13:45:54 +00:00
first commit
This commit is contained in:
40
app/Bunny/Client.php
Normal file
40
app/Bunny/Client.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Bunny;
|
||||
|
||||
use GuzzleHttp\RequestOptions;
|
||||
|
||||
class Client
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->client = new \GuzzleHttp\Client([
|
||||
'base_uri' => 'https://api.bunny.net/',
|
||||
]);
|
||||
}
|
||||
|
||||
public function getPullZone(int $pullZoneId): Result
|
||||
{
|
||||
return $this->request('GET', "pullzone/{$pullZoneId}", [
|
||||
RequestOptions::HEADERS => [
|
||||
'AccessKey' => config('bunny.api.access_key'),
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
public function purgeCache(int $pullZoneId): Result
|
||||
{
|
||||
return $this->request('POST', "pullzone/{$pullZoneId}/purgeCache", [
|
||||
RequestOptions::HEADERS => [
|
||||
'AccessKey' => config('bunny.api.access_key'),
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
private function request(string $method, string $uri, array $options): Result
|
||||
{
|
||||
$response = $this->client->request($method, $uri, $options);
|
||||
|
||||
return new Result($response);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user