import { Body, Controller, Post } from '@nestjs/common';
import { ApiCreatedResponse, ApiOkResponse, ApiTags } from '@nestjs/swagger';
import {
  DeviceHeartbeatRequestDto,
  DeviceHeartbeatResponseDto,
  RegisterDeviceRequestDto,
  RegisterDeviceResponseDto,
} from './devices.dto';
import { DevicesService } from './devices.service';

@ApiTags('devices')
@Controller({
  path: 'devices',
  version: '1',
})
export class DevicesController {
  constructor(private readonly devicesService: DevicesService) {}

  @Post('register')
  @ApiCreatedResponse({ type: RegisterDeviceResponseDto })
  async register(
    @Body() body: RegisterDeviceRequestDto,
  ): Promise<RegisterDeviceResponseDto> {
    return this.devicesService.register(body);
  }

  @Post('heartbeat')
  @ApiOkResponse({ type: DeviceHeartbeatResponseDto })
  async heartbeat(
    @Body() body: DeviceHeartbeatRequestDto,
  ): Promise<DeviceHeartbeatResponseDto> {
    return this.devicesService.heartbeat(body);
  }
}
