Refactor device controller and service

This commit is contained in:
faris Aljohari
2024-06-25 10:02:55 +03:00
parent 640a92619e
commit b0dba387fb
2 changed files with 7 additions and 7 deletions

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',

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,
);
@ -468,7 +468,7 @@ export class DeviceService {
}
}
async getDevicesInGetawayTuya(
async getDevicesInGatewayTuya(
deviceId: string,
): Promise<GetDeviceDetailsInterface[]> {
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[];
});