import { Controller, Get, Param, Post, Query } from '@nestjs/common';

import { MODULE_NAME } from 'src/core/strings/constants/module.constants';
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';

import { QueueAdminOrchestrator } from '../../domain/queue-admin.orchestrator';
import { PaginationResponse } from 'src/core/response/domain/ok-response.interface';
import { Queue } from '../../domain/entities/queue.entity';
import { QueueDto } from './dto/queue.filter';
import { Pagination } from 'src/core/response';
import { Public } from 'src/core/guards';

@ApiTags(`Queue Admin`)
@Controller(`v1/${MODULE_NAME.QUEUE}-admin`)
@ApiBearerAuth('JWT')
@Public(true)
export class QueueAdminController {
  constructor(private orchestrator: QueueAdminOrchestrator) {}

  @Get('queues')
  @Pagination()
  async index(@Query() params: QueueDto): Promise<PaginationResponse<Queue>> {
    return await this.orchestrator.index(params);
  }

  @Post('queues/:id/call')
  async call(@Param('id') id: string) {
    return await this.orchestrator.call(id);
  }
}
