import {
  DataClient,
  type PlatformSummaryViewModel,
  type TopStrategiesByRoiViewModel,
  type TopStrategiesViewModel,
  type TopAgentsByPnLViewModel
} from '../generated/ManagingApi'

export interface PlatformData {
  platform: PlatformSummaryViewModel
  topStrategies: TopStrategiesViewModel
  topStrategiesByRoi: TopStrategiesByRoiViewModel
  topAgentsByPnL: TopAgentsByPnLViewModel
}

export const fetchPlatformData = async (apiUrl: string): Promise<PlatformData> => {
  const client = new DataClient({}, apiUrl)
  
  // Fetch all platform data in parallel
  const [platform, topStrategies, topStrategiesByRoi, topAgentsByPnL] = await Promise.all([
    client.data_GetPlatformSummary(),
    client.data_GetTopStrategies(),
    client.data_GetTopStrategiesByRoi(),
    client.data_GetTopAgentsByPnL()
  ])
  
  return {
    platform,
    topStrategies,
    topStrategiesByRoi,
    topAgentsByPnL
  }
}
