import express from 'express';
import { ReportingService } from '../services/reporting.service.js';
import { TimeManager } from '../utils/time.utils.js';

export function createReportingRouter(apiKey, apiRevision) {
  const router = express.Router();
  const reportingService = new ReportingService(apiKey, apiRevision);
  const timeManager = new TimeManager();

  // Get campaign reports by time range
  router.get('/campaigns/:timeRange', async (req, res) => {
    try {
      const { timeRange } = req.params;
      const { channel } = req.query;
      
      const reports = await reportingService.getCampaignReports({
        timeRange,
        channel
      });

      res.json(reports);
    } catch (error) {
      console.error('[ReportingRoutes] Error fetching campaign reports:', error);
      res.status(500).json({ error: error.message });
    }
  });

  return router;
} 