import { PenaltiesApiClient } from '../../api/penalties/PenaltiesApiClient';
import type { PenaltyTypesReferenceDTO } from '../../types/PenaltyTypesReferenceDTO';

/**
 * Penalty Service
 *
 * Orchestrates penalty operations by coordinating API calls and view model creation.
 * All dependencies are injected via constructor.
 */
export class PenaltyService {
  constructor(
    private readonly apiClient: PenaltiesApiClient
  ) {}

  /**
   * Find penalties by race ID
   */
  async findByRaceId(raceId: string): Promise<any[]> {
    const dto = await this.apiClient.getRacePenalties(raceId);
    return dto.penalties;
  }

  /**
   * Get allowed penalty types and semantics
   */
  async getPenaltyTypesReference(): Promise<PenaltyTypesReferenceDTO> {
    return this.apiClient.getPenaltyTypesReference();
  }

  /**
   * Apply a penalty
   */
  async applyPenalty(input: any): Promise<void> {
    await this.apiClient.applyPenalty(input);
  }
}