import { Token } from '../../../domain/entities/token';
import { NotFoundError } from '../../../domain/errors/not-found-error';
import { ITokenRepository } from '../../../domain/repositories/token-repository';

export class GetTokenByIdUseCase {
  constructor(private readonly tokenRepository: ITokenRepository) {}

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