// frontend/src/api/services/external.ts /** * External Data API Service * Handles weather and traffic data operations */ import { apiClient } from '../client'; import type { CityInfoResponse, DataAvailabilityResponse, WeatherDataResponse, TrafficDataResponse, HistoricalWeatherRequest, HistoricalTrafficRequest, } from '../types/external'; class ExternalDataService { /** * List all supported cities */ async listCities(): Promise { const response = await apiClient.get( '/api/v1/external/cities' ); return response.data; } /** * Get data availability for a specific city */ async getCityAvailability(cityId: string): Promise { const response = await apiClient.get( `/api/v1/external/operations/cities/${cityId}/availability` ); return response.data; } /** * Get historical weather data (optimized city-based endpoint) */ async getHistoricalWeatherOptimized( tenantId: string, params: { latitude: number; longitude: number; start_date: string; end_date: string; } ): Promise { const response = await apiClient.get( `/api/v1/tenants/${tenantId}/external/operations/historical-weather-optimized`, { params } ); return response.data; } /** * Get historical traffic data (optimized city-based endpoint) */ async getHistoricalTrafficOptimized( tenantId: string, params: { latitude: number; longitude: number; start_date: string; end_date: string; } ): Promise { const response = await apiClient.get( `/api/v1/tenants/${tenantId}/external/operations/historical-traffic-optimized`, { params } ); return response.data; } /** * Get current weather for a location (real-time) */ async getCurrentWeather( tenantId: string, params: { latitude: number; longitude: number; } ): Promise { const response = await apiClient.get( `/api/v1/tenants/${tenantId}/external/operations/weather/current`, { params } ); return response.data; } /** * Get weather forecast */ async getWeatherForecast( tenantId: string, params: { latitude: number; longitude: number; days?: number; } ): Promise { const response = await apiClient.get( `/api/v1/tenants/${tenantId}/external/operations/weather/forecast`, { params } ); return response.data; } /** * Get current traffic conditions (real-time) */ async getCurrentTraffic( tenantId: string, params: { latitude: number; longitude: number; } ): Promise { const response = await apiClient.get( `/api/v1/tenants/${tenantId}/external/operations/traffic/current`, { params } ); return response.data; } } export const externalDataService = new ExternalDataService(); export default externalDataService;