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

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

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

    await this.tokenRepository.delete(tokenId);
  }
}
