refactor(dashboard): move price clients to app namespace and simplify data

This commit is contained in:
2026-08-01 21:55:23 +02:00
parent 69f214ade3
commit 0fa648f833
8 changed files with 31 additions and 32 deletions
@@ -0,0 +1,34 @@
<?php
namespace App\Repositories;
use App\Contracts\PriceClient;
use App\Contracts\PriceRepository as ContractsPriceRepository;
use App\Features\Dashboard\Data\ElectricityData;
use App\Features\Dashboard\Data\GasData;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Cache;
use Override;
class ZonneplanPriceRepository implements ContractsPriceRepository
{
public function __construct(
public PriceClient $client
) {}
#[Override]
public function retrieveElectricity(): Collection
{
$data = Cache::remember('electricity', 3600, fn () => $this->client->getElectricityPrices()->toArray());
return collect(ElectricityData::collect($data));
}
#[Override]
public function retrieveGas(): Collection
{
$data = Cache::remember('gas', 3600, fn () => $this->client->getGasPrices()->toArray());
return collect(GasData::collect($data));
}
}