implement client for meteo weather api
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package SuMoC.backend.dev;
|
||||
|
||||
import SuMoC.backend.meteo.MeteoClient;
|
||||
import SuMoC.backend.scheduling.ScheduledTasks;
|
||||
import SuMoC.backend.trend.services.StatTableUpdateService;
|
||||
import com.google.firebase.messaging.FirebaseMessaging;
|
||||
@@ -25,6 +26,8 @@ public class DevController {
|
||||
|
||||
private final FirebaseMessaging firebaseMessaging;
|
||||
|
||||
private final MeteoClient meteoClient;
|
||||
|
||||
@PostMapping("/trigger-trend-calculation")
|
||||
public void triggerTrendCalculation() {
|
||||
LocalDate dayOfLastWeek = LocalDate.now().minusDays(7);
|
||||
@@ -51,4 +54,26 @@ public class DevController {
|
||||
}
|
||||
}
|
||||
|
||||
@GetMapping("/test-meteo")
|
||||
public ResponseEntity<String> testMeteoClient() {
|
||||
try {
|
||||
// Test with Zurich coordinates
|
||||
double lat = 47.3769;
|
||||
double lon = 8.5417;
|
||||
|
||||
var forecast = meteoClient.getForecastWeatherCodeToday(lat, lon).block();
|
||||
|
||||
if (forecast != null) {
|
||||
return ResponseEntity.ok("✓ Meteo API working! Received forecast for " +
|
||||
forecast.latitude() + ", " + forecast.longitude() +
|
||||
" with " + (forecast.hourly() != null ? forecast.hourly().weatherCode().size() : 0) +
|
||||
" hourly weather codes");
|
||||
} else {
|
||||
return ResponseEntity.status(500).body("✗ No response from Meteo API");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return ResponseEntity.status(500).body("✗ Failed: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user