get('/energy-prices/electricity/upcoming')); } public function getGasPrices(): Collection { return collect($this->get('/energy-prices/gas/upcoming')); } #[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 $params * * @return array> */ 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) ->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, ); } } }