feat(history): add energy price history feature
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user