first commit

This commit is contained in:
René Preuß
2021-07-19 20:55:01 +02:00
commit f42347aa99
33 changed files with 8074 additions and 0 deletions

40
app/Bunny/Client.php Normal file
View 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);
}
}