import { Body, Controller, Delete, Get, Param, Post, Put, Query, } from '@nestjs/common'; import { CreditNoteApplication } from './CreditNoteApplication.service'; import { ICreditNotesQueryDTO } from './types/CreditNotes.types'; import { PublicRoute } from '../Auth/Jwt.guard'; import { ApiTags } from '@nestjs/swagger'; import { CreateCreditNoteDto, EditCreditNoteDto } from './dtos/CreditNote.dto'; @Controller('credit-notes') @ApiTags('credit-notes') @PublicRoute() export class CreditNotesController { /** * @param {CreditNoteApplication} creditNoteApplication - The credit note application service. */ constructor(private creditNoteApplication: CreditNoteApplication) {} @Post() createCreditNote(@Body() creditNoteDTO: CreateCreditNoteDto) { return this.creditNoteApplication.createCreditNote(creditNoteDTO); } @Get() getCreditNotes(@Query() creditNotesQuery: ICreditNotesQueryDTO) { return this.creditNoteApplication.getCreditNotes(creditNotesQuery); } @Put(':id') editCreditNote( @Param('id') creditNoteId: number, @Body() creditNoteDTO: EditCreditNoteDto, ) { return this.creditNoteApplication.editCreditNote( creditNoteId, creditNoteDTO, ); } @Put(':id/open') openCreditNote(@Param('id') creditNoteId: number) { return this.creditNoteApplication.openCreditNote(creditNoteId); } @Delete(':id') deleteCreditNote(@Param('id') creditNoteId: number) { return this.creditNoteApplication.deleteCreditNote(creditNoteId); } }