From b0106fa93def83492d85a93f6cc5a00e3b539fff Mon Sep 17 00:00:00 2001 From: Daniel Roth Date: Thu, 21 May 2026 15:48:45 +0000 Subject: [PATCH] =?UTF-8?q?GoogleSolarApiClient=20fetches=20building=20ins?= =?UTF-8?q?ights=20from=20the=20Solar=20API=20=F0=9F=9F=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- infrastructure/solar/google_solar_api_client.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/infrastructure/solar/google_solar_api_client.py b/infrastructure/solar/google_solar_api_client.py index 5e4698e9..4edea335 100644 --- a/infrastructure/solar/google_solar_api_client.py +++ b/infrastructure/solar/google_solar_api_client.py @@ -1,5 +1,7 @@ from typing import Any, Literal +import requests + class BuildingInsightsNotFoundError(Exception): pass @@ -11,7 +13,7 @@ class GoogleSolarApiClient: ENTITY_NOT_FOUND_ERROR: str = "Requested entity was not found." def __init__(self, api_key: str) -> None: - raise NotImplementedError + self._api_key = api_key def get_building_insights( self, @@ -19,4 +21,14 @@ class GoogleSolarApiClient: latitude: float, required_quality: Literal["HIGH", "MEDIUM", "LOW"] = "MEDIUM", ) -> dict[str, Any]: - raise NotImplementedError + insights_url = f"{self.base_url}/buildingInsights:findClosest" + params: dict[str, str] = { + "location.latitude": f"{latitude:.5f}", + "location.longitude": f"{longitude:.5f}", + "requiredQuality": required_quality, + "key": self._api_key, + } + response = requests.get(insights_url, params=params) + response.raise_for_status() + result: dict[str, Any] = response.json() + return result