import { Body, Controller, Headers, HttpCode, Post } from '@nestjs/common';
import { TeamsWebhookPayload, WebhooksService } from './webhooks.service';

@Controller('webhooks')
export class WebhooksController {
  constructor(private readonly webhooksService: WebhooksService) {}

  @Post('teams')
  @HttpCode(202)
  async teamsWebhook(
    @Body() body: TeamsWebhookPayload | TeamsWebhookPayload[],
    @Headers('x-webhook-token') token?: string
  ): Promise<{ ok: true }> {
    return this.webhooksService.handleTeamsWebhook(body, token);
  }
}
