import { apiClient } from './client'

export const reportingApi = {
  exportBacktestCSV: async (results: any): Promise<Blob> => {
    const response = await apiClient.post('/api/reporting/backtest/csv', results, {
      responseType: 'blob',
    })
    return response.data
  },

  exportBacktestPDF: async (results: any): Promise<Blob> => {
    const response = await apiClient.post('/api/reporting/backtest/pdf', results, {
      responseType: 'blob',
    })
    return response.data
  },

  exportTradesCSV: async (startDate?: string, endDate?: string, paperTrading: boolean = true): Promise<Blob> => {
    const response = await apiClient.get('/api/reporting/trades/csv', {
      params: { start_date: startDate, end_date: endDate, paper_trading: paperTrading },
      responseType: 'blob',
    })
    return response.data
  },

  exportPortfolioCSV: async (paperTrading: boolean = true): Promise<Blob> => {
    const response = await apiClient.get('/api/reporting/portfolio/csv', {
      params: { paper_trading: paperTrading },
      responseType: 'blob',
    })
    return response.data
  },
}
