From b0dba387fb233c20730655c575bcc368628862e6 Mon Sep 17 00:00:00 2001 From: faris Aljohari <83524184+farisaljohari@users.noreply.github.com> Date: Tue, 25 Jun 2024 10:02:55 +0300 Subject: [PATCH] Refactor device controller and service --- src/device/controllers/device.controller.ts | 6 +++--- src/device/services/device.service.ts | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/device/controllers/device.controller.ts b/src/device/controllers/device.controller.ts index c9fc59c..acf1632 100644 --- a/src/device/controllers/device.controller.ts +++ b/src/device/controllers/device.controller.ts @@ -200,10 +200,10 @@ export class DeviceController { } @ApiBearerAuth() @UseGuards(JwtAuthGuard) - @Get('getaway/:gatewayUuid/devices') - async getDevicesInGetaway(@Param('gatewayUuid') gatewayUuid: string) { + @Get('gateway/:gatewayUuid/devices') + async getDevicesInGateway(@Param('gatewayUuid') gatewayUuid: string) { try { - return await this.deviceService.getDevicesInGetaway(gatewayUuid); + return await this.deviceService.getDevicesInGateway(gatewayUuid); } catch (error) { throw new HttpException( error.message || 'Internal server error', diff --git a/src/device/services/device.service.ts b/src/device/services/device.service.ts index ef45960..bc9ed2c 100644 --- a/src/device/services/device.service.ts +++ b/src/device/services/device.service.ts @@ -428,7 +428,7 @@ export class DeviceService { }); return device.permission[0].permissionType.type; } - async getDevicesInGetaway(gatewayUuid: string) { + async getDevicesInGateway(gatewayUuid: string) { try { const deviceDetails = await this.getDeviceByDeviceUuid(gatewayUuid); @@ -438,7 +438,7 @@ export class DeviceService { throw new BadRequestException('This is not a gateway device'); } - const response = await this.getDevicesInGetawayTuya( + const response = await this.getDevicesInGatewayTuya( deviceDetails.deviceTuyaUuid, ); @@ -468,7 +468,7 @@ export class DeviceService { } } - async getDevicesInGetawayTuya( + async getDevicesInGatewayTuya( deviceId: string, ): Promise { try { @@ -479,7 +479,7 @@ export class DeviceService { }); const camelCaseResponse = response.result.map((device: any) => { // eslint-disable-next-line @typescript-eslint/no-unused-vars - const { product_id, category, id, ...rest } = device; + const { product_id, category, ...rest } = device; const camelCaseDevice = convertKeysToCamelCase({ ...rest }); return camelCaseDevice as GetDeviceDetailsInterface[]; });