import { Body, Controller, Get, Post } from '@nestjs/common';
import { Paginate, PaginateQuery } from 'nestjs-paginate';
import { CreateBulkMessageDto } from './dtos/create-bulk-message.dto';
import { CreateMessageDto } from './dtos/create-message.dto';
import { ReplyMessageDto } from './dtos/reply-message.dto';
import { SendLogDto } from './dtos/send-log.dto';
import { SendMessageDto } from './dtos/send-message.dto';
import { LogsService } from './logs.service';
import { MessagesService } from './messages.service';

@Controller('messages')
export class MessagesController {
  constructor(
    private readonly service: MessagesService,
    private readonly logService: LogsService,
  ) {}

  @Get('')
  index(@Paginate() query: PaginateQuery) {
    return this.service.index(query);
  }

  @Post('send-message')
  sendMessage(@Body() data: SendMessageDto) {
    return this.service.sendMessage(data);
  }

  @Post('create-and-send')
  createAndSendToZulip(@Body() data: CreateBulkMessageDto) {
    return this.service.createAndSendToZulip(data);
  }

  @Post('')
  save(@Body() data: CreateMessageDto) {
    return this.service.create(data);
  }

  @Post('reply-message')
  replyMessage(@Body() data: ReplyMessageDto) {
    return this.service.replyMessage(data);
  }

  @Post('logs')
  saveLog(@Body() data: SendLogDto) {
    return this.logService.saveLog(data);
  }
}
