Adding endpoint to force performing a reservation
This commit is contained in:
parent
67c5374832
commit
7a022fccc1
1 changed files with 13 additions and 1 deletions
|
|
@ -5,6 +5,7 @@ import {
|
|||
Controller,
|
||||
Delete,
|
||||
Get,
|
||||
HttpException,
|
||||
Inject,
|
||||
Param,
|
||||
Post,
|
||||
|
|
@ -102,7 +103,6 @@ export class ReservationsController {
|
|||
|
||||
@Post()
|
||||
async createReservation(@Body() req: CreateReservationRequest) {
|
||||
console.log(req)
|
||||
const reservation = await this.reservationsService.create(req)
|
||||
if (!reservation.isAvailableForReservation()) {
|
||||
this.loggerService.debug('Reservation not available for reservation')
|
||||
|
|
@ -113,6 +113,18 @@ export class ReservationsController {
|
|||
return 'Reservation queued'
|
||||
}
|
||||
|
||||
@Post(':id')
|
||||
async performReservation(@Param('id') id: string) {
|
||||
const reservation = await this.reservationsService.getById(id)
|
||||
if (reservation == null) throw new HttpException('Not found', 404)
|
||||
|
||||
if (!reservation.isAvailableForReservation())
|
||||
throw new HttpException('Not available', 400)
|
||||
|
||||
await this.reservationsQueue.add(reservation)
|
||||
return 'Reservation queued'
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
async deleteReservationById(@Param('id') id: string) {
|
||||
await this.reservationsService.deleteById(id)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue