Merge pull request #52 from SyncrowIOT/fix-gateway-issue

Fix gateway issue
This commit is contained in:
faris Aljohari
2024-06-25 10:19:22 +03:00
committed by GitHub
2 changed files with 11 additions and 8 deletions
+3 -3
View File
@@ -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',
+8 -5
View File
@@ -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,
);
@@ -446,8 +446,11 @@ export class DeviceService {
response.map(async (device: any) => {
const deviceDetails = await this.getDeviceByDeviceTuyaUuid(device.id);
if (deviceDetails.deviceTuyaUuid) {
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const { id, ...rest } = device;
return {
...device,
...rest,
tuyaUuid: deviceDetails.deviceTuyaUuid,
uuid: deviceDetails.uuid,
productUuid: deviceDetails.productDevice.uuid,
productType: deviceDetails.productDevice.prodType,
@@ -468,7 +471,7 @@ export class DeviceService {
}
}
async getDevicesInGetawayTuya(
async getDevicesInGatewayTuya(
deviceId: string,
): Promise<GetDeviceDetailsInterface[]> {
try {
@@ -479,7 +482,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[];
});