python-google-weather-api 0.0.1__tar.gz → 0.0.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (14) hide show
  1. {python_google_weather_api-0.0.1/src/python_google_weather_api.egg-info → python_google_weather_api-0.0.2}/PKG-INFO +1 -1
  2. {python_google_weather_api-0.0.1 → python_google_weather_api-0.0.2}/pyproject.toml +1 -1
  3. {python_google_weather_api-0.0.1 → python_google_weather_api-0.0.2}/src/google_weather_api/api.py +22 -15
  4. {python_google_weather_api-0.0.1 → python_google_weather_api-0.0.2/src/python_google_weather_api.egg-info}/PKG-INFO +1 -1
  5. {python_google_weather_api-0.0.1 → python_google_weather_api-0.0.2}/LICENSE +0 -0
  6. {python_google_weather_api-0.0.1 → python_google_weather_api-0.0.2}/README.md +0 -0
  7. {python_google_weather_api-0.0.1 → python_google_weather_api-0.0.2}/setup.cfg +0 -0
  8. {python_google_weather_api-0.0.1 → python_google_weather_api-0.0.2}/src/google_weather_api/__init__.py +0 -0
  9. {python_google_weather_api-0.0.1 → python_google_weather_api-0.0.2}/src/google_weather_api/py.typed +0 -0
  10. {python_google_weather_api-0.0.1 → python_google_weather_api-0.0.2}/src/python_google_weather_api.egg-info/SOURCES.txt +0 -0
  11. {python_google_weather_api-0.0.1 → python_google_weather_api-0.0.2}/src/python_google_weather_api.egg-info/dependency_links.txt +0 -0
  12. {python_google_weather_api-0.0.1 → python_google_weather_api-0.0.2}/src/python_google_weather_api.egg-info/requires.txt +0 -0
  13. {python_google_weather_api-0.0.1 → python_google_weather_api-0.0.2}/src/python_google_weather_api.egg-info/top_level.txt +0 -0
  14. {python_google_weather_api-0.0.1 → python_google_weather_api-0.0.2}/tests/test_api.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-google-weather-api
3
- Version: 0.0.1
3
+ Version: 0.0.2
4
4
  Summary: A python client library for Google Weather API
5
5
  Author-email: tronikos <tronikos@gmail.com>
6
6
  License-Expression: Apache-2.0
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "python-google-weather-api"
3
- version = "0.0.1"
3
+ version = "0.0.2"
4
4
  license = "Apache-2.0"
5
5
  authors = [
6
6
  { name="tronikos", email="tronikos@gmail.com" },
@@ -34,8 +34,6 @@ class GoogleWeatherApi:
34
34
  self,
35
35
  session: aiohttp.ClientSession,
36
36
  api_key: str,
37
- latitude: float,
38
- longitude: float,
39
37
  language_code: str = "en",
40
38
  units_system: str = "METRIC",
41
39
  referrer: str | None = None,
@@ -44,8 +42,6 @@ class GoogleWeatherApi:
44
42
  """Initialize the Google Weather API client."""
45
43
  self.session = session
46
44
  self.api_key = api_key
47
- self.latitude = latitude
48
- self.longitude = longitude
49
45
  self.language_code = language_code
50
46
  self.units_system = units_system
51
47
  self.referrer = referrer
@@ -62,8 +58,6 @@ class GoogleWeatherApi:
62
58
  "key": self.api_key,
63
59
  "language_code": self.language_code,
64
60
  "units_system": self.units_system,
65
- "location.latitude": self.latitude,
66
- "location.longitude": self.longitude,
67
61
  }
68
62
  _LOGGER.debug("GET %s with params: %s", url, params)
69
63
  try:
@@ -78,33 +72,46 @@ class GoogleWeatherApi:
78
72
  if resp.status != HTTPStatus.OK:
79
73
  raise GoogleWeatherApiResponseError(res["error"]["message"])
80
74
  return res
81
- except (aiohttp.ClientError, TimeoutError) as err:
82
- raise GoogleWeatherApiConnectionError(
83
- f"Error connecting to API: {err}"
84
- ) from err
85
-
86
- async def async_get_current_conditions(self) -> dict[str, Any]:
75
+ except TimeoutError as err:
76
+ raise GoogleWeatherApiConnectionError("Timeout") from err
77
+ except aiohttp.ClientError as err:
78
+ raise GoogleWeatherApiConnectionError(err) from err
79
+
80
+ async def async_get_current_conditions(
81
+ self, latitude: float, longitude: float
82
+ ) -> dict[str, Any]:
87
83
  """Fetch current weather conditions."""
88
84
  return await self._async_get(
89
85
  "currentConditions:lookup",
90
- {},
86
+ {
87
+ "location.latitude": latitude,
88
+ "location.longitude": longitude,
89
+ },
91
90
  )
92
91
 
93
- async def async_get_hourly_forecast(self, hours: int = 48) -> dict[str, Any]:
92
+ async def async_get_hourly_forecast(
93
+ self, latitude: float, longitude: float, hours: int = 48
94
+ ) -> dict[str, Any]:
94
95
  """Fetch hourly weather forecast."""
95
96
  return await self._async_get(
96
97
  "forecast/hours:lookup",
97
98
  {
99
+ "location.latitude": latitude,
100
+ "location.longitude": longitude,
98
101
  "hours": hours,
99
102
  "page_size": hours,
100
103
  },
101
104
  )
102
105
 
103
- async def async_get_daily_forecast(self, days: int = 10) -> dict[str, Any]:
106
+ async def async_get_daily_forecast(
107
+ self, latitude: float, longitude: float, days: int = 10
108
+ ) -> dict[str, Any]:
104
109
  """Fetch daily weather forecast."""
105
110
  return await self._async_get(
106
111
  "forecast/days:lookup",
107
112
  {
113
+ "location.latitude": latitude,
114
+ "location.longitude": longitude,
108
115
  "days": days,
109
116
  "page_size": days,
110
117
  },
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-google-weather-api
3
- Version: 0.0.1
3
+ Version: 0.0.2
4
4
  Summary: A python client library for Google Weather API
5
5
  Author-email: tronikos <tronikos@gmail.com>
6
6
  License-Expression: Apache-2.0