feat(dashboard): add price dashboard with Zonneplan integration

This commit is contained in:
2026-08-01 19:53:18 +02:00
parent 49919fef32
commit 1cd905ca4a
29 changed files with 1701 additions and 28 deletions
@@ -0,0 +1,60 @@
<?php
namespace App\Features\Dashboard\Clients;
use App\Features\Dashboard\Contracts\PriceClient;
use Exception;
use Illuminate\Http\Client\Factory;
use Illuminate\Support\Facades\Log;
use Throwable;
class ZonneplanPriceClient implements PriceClient
{
public function __construct(
private readonly Factory $http,
) {}
public function getElectricityPrices(): array
{
return $this->get('/energy-prices/electricity/upcoming');
}
public function getGasPrices(): array
{
return $this->get('/energy-prices/gas/upcoming');
}
/** @return array<int, array<string, mixed>> */
private function get(string $path): array
{
try {
$response = $this->http
->baseUrl(config('api.baseurl'))
->withQueryParameters([
'secret' => config('api.key'),
])
->timeout(10)
->retry(2, 100)
->get($path);
$response->throw();
Log::info('Zonneplan API opgehaald', [
'path' => $path,
'status' => $response->status(),
]);
return $response->json('data', []);
} catch (Throwable $e) {
Log::error('Zonneplan API aanroep mislukt', [
'path' => $path,
'message' => $e->getMessage(),
]);
throw new Exception(
"Kon energieprijzen niet ophalen voor {$path}",
previous: $e,
);
}
}
}