Compare commits

...

2 commits

Author SHA1 Message Date
a6dbb94d90
feat: add api call file 2023-03-27 19:12:23 +02:00
99c9a1d09f
fix: apparently precipitation is a float 2023-03-27 19:11:46 +02:00
2 changed files with 18 additions and 1 deletions

17
src/weather/api.rs Normal file
View file

@ -0,0 +1,17 @@
use super::data::WeatherData;
use super::secret::API_TOKEN;
pub fn get_weather_data() -> reqwest::Result<WeatherData> {
let api_url = format!(
"https://api.openweathermap.org/data/3.0/onecall?units={units}&lat={lat}&lon={lon}&exclude={exclude}&lang={lang}&appid={token}",
units = "metric",
lat = 51.03866,
lon = 13.70031,
exclude = "minutely",
lang = "de",
token = API_TOKEN,
);
reqwest::blocking::get(dbg!(api_url))?.json()
}

View file

@ -145,7 +145,7 @@ pub struct WeatherAlert {
pub struct Precipitation {
/// Precipitation volume in the last hour in mm
#[serde(rename = "1h")]
pub(self) hour: u16,
pub(self) hour: f32,
}
#[derive(Deserialize)]