import { Controller, Get, Param, Patch, Body, UseGuards } from '@nestjs/common';
import { FraudService } from './fraud.service';
import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard';

@Controller('fraud')
@UseGuards(JwtAuthGuard)
export class FraudController {
    constructor(private readonly fraudService: FraudService) { }

    /**
     * GET /fraud/alerts
     * List active fraud alerts
     */
    @Get('alerts')
    async getAlerts() {
        return this.fraudService.getAlerts();
    }

    /**
     * GET /fraud/analyze/:companyId
     * Run fraud analysis on a specific company
     */
    @Get('analyze/:companyId')
    async analyzeCompany(@Param('companyId') companyId: string) {
        return this.fraudService.analyzeCompany(companyId);
    }

    /**
     * PATCH /fraud/alerts/:id/dismiss
     * Dismiss a fraud alert (mark as false positive)
     */
    @Patch('alerts/:id/dismiss')
    async dismissAlert(
        @Param('id') id: string,
        @Body() data: { reason: string },
    ) {
        return this.fraudService.dismissAlert(id, data.reason);
    }

    /**
     * PATCH /fraud/alerts/:id/confirm
     * Confirm and act on a fraud alert
     */
    @Patch('alerts/:id/confirm')
    async confirmAlert(
        @Param('id') id: string,
        @Body() data: { action: 'suspend' | 'warn' | 'ban'; notes: string },
    ) {
        return this.fraudService.confirmAlert(id, data);
    }
}
