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

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

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