import { Device } from '../../../domain/entities/device';
import { NotFoundError } from '../../../domain/errors/not-found-error';
import { IDeviceRepository } from '../../../domain/repositories/device-repository';

export class GetDeviceByIdUseCase {
  constructor(private readonly deviceRepository: IDeviceRepository) {}

  async execute(id: string): Promise<Device> {
    const device = await this.deviceRepository.findById(id);
    if (!device) {
      throw new NotFoundError('Device', id);
    }
    return device;
  }
}
