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,
|
Controller,
|
||||||
Delete,
|
Delete,
|
||||||
Get,
|
Get,
|
||||||
|
HttpException,
|
||||||
Inject,
|
Inject,
|
||||||
Param,
|
Param,
|
||||||
Post,
|
Post,
|
||||||
|
|
@ -102,7 +103,6 @@ export class ReservationsController {
|
||||||
|
|
||||||
@Post()
|
@Post()
|
||||||
async createReservation(@Body() req: CreateReservationRequest) {
|
async createReservation(@Body() req: CreateReservationRequest) {
|
||||||
console.log(req)
|
|
||||||
const reservation = await this.reservationsService.create(req)
|
const reservation = await this.reservationsService.create(req)
|
||||||
if (!reservation.isAvailableForReservation()) {
|
if (!reservation.isAvailableForReservation()) {
|
||||||
this.loggerService.debug('Reservation not available for reservation')
|
this.loggerService.debug('Reservation not available for reservation')
|
||||||
|
|
@ -113,6 +113,18 @@ export class ReservationsController {
|
||||||
return 'Reservation queued'
|
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')
|
@Delete(':id')
|
||||||
async deleteReservationById(@Param('id') id: string) {
|
async deleteReservationById(@Param('id') id: string) {
|
||||||
await this.reservationsService.deleteById(id)
|
await this.reservationsService.deleteById(id)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue