import { Controller, Get, Query } from '@nestjs/common';
import { ApiTags, ApiOperation, ApiQuery } from '@nestjs/swagger';
import { RevenueService } from './revenue.service';

@ApiTags('Revenue')
@Controller('revenue')
export class RevenueController {
  constructor(private readonly revenueService: RevenueService) {}

  @Get('summary')
  @ApiOperation({ summary: 'Get revenue summary metrics' })
  @ApiQuery({ name: 'startDate', required: true })
  @ApiQuery({ name: 'endDate', required: true })
  async getRevenueSummary(
    @Query('startDate') startDate: string,
    @Query('endDate') endDate: string,
  ) {
    return this.revenueService.getRevenueSummary(startDate, endDate);
  }

  @Get('ltv')
  @ApiOperation({ summary: 'Get customer lifetime value metrics' })
  async getLTV(
    @Query('startDate') startDate: string,
    @Query('endDate') endDate: string,
  ) {
    return this.revenueService.getLTV(startDate, endDate);
  }

  @Get('arpu')
  @ApiOperation({ summary: 'Get average revenue per user' })
  async getARPU(
    @Query('startDate') startDate: string,
    @Query('endDate') endDate: string,
    @Query('granularity') granularity: 'day' | 'week' | 'month' = 'day',
  ) {
    return this.revenueService.getARPU(startDate, endDate, granularity);
  }

  @Get('mrr')
  @ApiOperation({ summary: 'Get monthly recurring revenue' })
  async getMRR(@Query('month') month: string) {
    return this.revenueService.getMRR(month);
  }
}
