Refactor Scene Module: Add Update Scene Tap To Run Endpoint

This commit is contained in:
faris Aljohari
2024-06-24 16:03:01 +03:00
parent d6f846086c
commit feaae7341a
4 changed files with 126 additions and 16 deletions
+30 -3
View File
@@ -8,10 +8,11 @@ import {
HttpStatus,
Param,
Post,
Put,
UseGuards,
} from '@nestjs/common';
import { ApiTags, ApiBearerAuth } from '@nestjs/swagger';
import { AddSceneTapToRunDto } from '../dtos/add.scene.dto';
import { AddSceneTapToRunDto, UpdateSceneTapToRunDto } from '../dtos/scene.dto';
import { JwtAuthGuard } from '@app/common/guards/jwt.auth.guard';
@ApiTags('Scene Module')
@@ -99,11 +100,37 @@ export class SceneController {
@ApiBearerAuth()
@UseGuards(JwtAuthGuard)
@Get('tap-to-run/details/:sceneId')
async triggerTapToRunSceneDetails(@Param('sceneId') sceneId: string) {
async getTapToRunSceneDetails(@Param('sceneId') sceneId: string) {
try {
const tapToRunScenes =
await this.sceneService.triggerTapToRunSceneDetails(sceneId);
await this.sceneService.getTapToRunSceneDetails(sceneId);
return tapToRunScenes;
} catch (error) {
throw new HttpException(
error.message || 'Internal server error',
error.status || HttpStatus.INTERNAL_SERVER_ERROR,
);
``;
}
}
@ApiBearerAuth()
@UseGuards(JwtAuthGuard)
@Put('tap-to-run/:sceneId')
async updateTapToRunScene(
@Body() updateSceneTapToRunDto: UpdateSceneTapToRunDto,
@Param('sceneId') sceneId: string,
) {
try {
const tapToRunScene = await this.sceneService.updateTapToRunScene(
updateSceneTapToRunDto,
sceneId,
);
return {
statusCode: HttpStatus.CREATED,
success: true,
message: 'Scene updated successfully',
data: tapToRunScene,
};
} catch (error) {
throw new HttpException(
error.message || 'Internal server error',