Skip to content

Commit

Permalink
Merge branch 'main' of github.com:Baspa/energyzero-php-api
Browse files Browse the repository at this point in the history
  • Loading branch information
Baspa committed Aug 26, 2024
2 parents 25caa8c + d8a4dfb commit ccd51e8
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/EnergyZero.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@
namespace Baspa\EnergyZero;

use DateTime;
use Exception;
use DateTimeZone;
use Illuminate\Support\Facades\Http;
use Exception;
use GuzzleHttp\Exception\RequestException;
use Illuminate\Support\Facades\Http;

class EnergyZero
{
private bool $vat = true;

private float $requestTimeout = 10.0;

private string $baseUri = 'https://api.energyzero.nl/v1/';

public function request(string $uri, array $params = [])
Expand All @@ -25,10 +27,10 @@ public function request(string $uri, array $params = [])
if ($response->successful()) {
return $response->json();
} else {
throw new Exception("Unexpected response status: " . $response->status());
throw new Exception('Unexpected response status: ' . $response->status());
}
} catch (RequestException $e) {
echo "Error: ", $e->getMessage(), "\n";
echo 'Error: ', $e->getMessage(), "\n";
}
}

Expand Down Expand Up @@ -60,7 +62,7 @@ public function energyPrices(string $startDate, string $endDate, int $interval =
$data = $this->request('energyprices', $params);

if (empty($data['Prices'])) {
throw new Exception("No energy prices found for this period.");
throw new Exception('No energy prices found for this period.');
}

return $data;
Expand Down

0 comments on commit ccd51e8

Please sign in to comment.