import { Body, Controller, Post } from '@nestjs/common';
import { ErrorResponse, MailInfo } from '../models/main.model';
import { MailService } from './mail.service.js';

@Controller('mail')
export class MailController {
  constructor(private mailService: MailService) {}
  @Post()
  sendEMail(@Body() mailInfo: MailInfo): Promise<void | ErrorResponse> {
    if (mailInfo.listing) {
      return this.mailService.sendInquiry(mailInfo);
    } else {
      return this.mailService.sendRequest(mailInfo);
    }
  }
}
