import { DeleteDTO, Role } from '@hed-hog/api';
import { Pagination } from '@hed-hog/api-pagination';
import {
  Body,
  Controller,
  Delete,
  Get,
  Inject,
  Param,
  ParseIntPipe,
  Patch,
  Post,
  forwardRef,
} from '@nestjs/common';
import { CreateDTO } from './dto/create.dto';
import { UpdateDTO } from './dto/update.dto';
import { MailProfileService } from './mail-profile.service';

@Role()
@Controller('mail-profile')
export class MailProfileController {
  constructor(
    @Inject(forwardRef(() => MailProfileService))
    private readonly mailProfileService: MailProfileService,
  ) {}

  @Get()
  async list(@Pagination() paginationParams) {
    return this.mailProfileService.list(paginationParams);
  }

  @Get(':id')
  async get(@Param('id', ParseIntPipe) id: number) {
    return this.mailProfileService.get(id);
  }

  @Post()
  async create(@Body() data: CreateDTO) {
    return this.mailProfileService.create(data);
  }

  @Post('test')
  async test(@Body() data: CreateDTO) {
    return this.mailProfileService.test(data);
  }

  @Patch(':id')
  async update(@Param('id', ParseIntPipe) id: number, @Body() data: UpdateDTO) {
    return this.mailProfileService.update({ id, data });
  }

  @Delete()
  async delete(@Body() data: DeleteDTO) {
    return this.mailProfileService.delete(data);
  }
}
