refactor(dashboard): move price clients to app namespace and simplify data
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user