Refactor getDevicesInstructionStatus method for improved readability

This commit is contained in:
faris Aljohari
2024-03-25 14:36:31 +03:00
parent 6c02f60f28
commit 46e7fc4260

View File

@ -381,12 +381,18 @@ export class DeviceService {
} }
async getDevicesInstructionStatus(deviceId: string) { async getDevicesInstructionStatus(deviceId: string) {
try { 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 { return {
result: response.result, result: {
success: response.success, productId: productId,
msg: response.msg, productType: productType,
status: deviceStatus.result[0].status,
},
success: deviceStatus.success,
msg: deviceStatus.msg,
}; };
} catch (error) { } catch (error) {
throw new HttpException( throw new HttpException(