feat(history): add energy price history feature

This commit is contained in:
2026-08-02 11:29:58 +02:00
parent 1511de31a8
commit f70f3ab054
20 changed files with 262 additions and 52 deletions
+21 -2
View File
@@ -3,10 +3,12 @@
namespace App\Clients;
use App\Contracts\PriceClient;
use Carbon\Carbon;
use Exception;
use Illuminate\Http\Client\Factory;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Log;
use Override;
use Throwable;
class ZonneplanPriceClient implements PriceClient
@@ -25,14 +27,31 @@ class ZonneplanPriceClient implements PriceClient
return collect($this->get('/energy-prices/gas/upcoming'));
}
/** @return array<int, array<string, mixed>> */
private function get(string $path): array
#[Override]
public function getElectricityPricesForDate(Carbon $date): Collection
{
return collect($this->get('/energy-prices/electricity/upcoming', ['date' => $date->format('Y-m-d')]));
}
#[Override]
public function getGasPricesForDate(Carbon $date): Collection
{
return collect($this->get('/energy-prices/gas/upcoming', ['date' => $date->format('Y-m-d')]));
}
/**
* @property array<string, string> $params
*
* @return array<int, array<string, mixed>>
*/
private function get(string $path, array $params = []): array
{
try {
$response = $this->http
->baseUrl(config('api.baseurl'))
->withQueryParameters([
'secret' => config('api.key'),
...$params,
])
->timeout(10)
->retry(2, 100)