mirror of
https://github.com/bitinflow/bunny-cli.git
synced 2026-03-13 13:45:54 +00:00
41 lines
983 B
PHP
41 lines
983 B
PHP
<?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);
|
|
}
|
|
}
|