From 46e7fc426070c39066d024f5f12d30b28e18cfaa Mon Sep 17 00:00:00 2001 From: faris Aljohari <83524184+farisaljohari@users.noreply.github.com> Date: Mon, 25 Mar 2024 14:36:31 +0300 Subject: [PATCH] Refactor getDevicesInstructionStatus method for improved readability --- src/device/services/device.service.ts | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/device/services/device.service.ts b/src/device/services/device.service.ts index 649aadc..1a240d0 100644 --- a/src/device/services/device.service.ts +++ b/src/device/services/device.service.ts @@ -381,12 +381,18 @@ export class DeviceService { } async getDevicesInstructionStatus(deviceId: string) { try { - const response = await this.getDevicesInstructionStatusTuya(deviceId); - + const deviceStatus = await this.getDevicesInstructionStatusTuya(deviceId); + const productId: string = await this.getProductIdByDeviceId(deviceId); + const productType: string = + await this.getProductTypeByProductId(productId); return { - result: response.result, - success: response.success, - msg: response.msg, + result: { + productId: productId, + productType: productType, + status: deviceStatus.result[0].status, + }, + success: deviceStatus.success, + msg: deviceStatus.msg, }; } catch (error) { throw new HttpException(