import { BaseApiClient } from '../base/BaseApiClient'; import type { AllLeaguesWithCapacityDTO } from '../../types/generated/AllLeaguesWithCapacityDTO'; import type { TotalLeaguesDTO } from '../../types/generated/TotalLeaguesDTO'; import type { LeagueStandingsDTO } from '../../types/generated/LeagueStandingsDTO'; import type { LeagueScheduleDTO } from '../../types/generated/LeagueScheduleDTO'; import type { LeagueMembershipsDTO } from '../../types/generated/LeagueMembershipsDTO'; import type { CreateLeagueInputDTO } from '../../types/generated/CreateLeagueInputDTO'; import type { CreateLeagueOutputDTO } from '../../types/generated/CreateLeagueOutputDTO'; import type { SponsorshipDetailDTO } from '../../types/generated/SponsorshipDetailDTO'; import type { RaceDTO } from '../../types/generated/RaceDTO'; import type { GetLeagueAdminConfigOutputDTO } from '../../types/generated/GetLeagueAdminConfigOutputDTO'; import type { LeagueScoringPresetDTO } from '../../types/generated/LeagueScoringPresetDTO'; import type { LeagueSeasonSummaryDTO } from '../../types/generated/LeagueSeasonSummaryDTO'; import type { AllLeaguesWithCapacityAndScoringDTO } from '../../types/AllLeaguesWithCapacityAndScoringDTO'; /** * Leagues API Client * * Handles all league-related API operations. */ export class LeaguesApiClient extends BaseApiClient { /** Get all leagues with capacity information */ getAllWithCapacity(): Promise { return this.get('/leagues/all-with-capacity'); } /** Get all leagues with capacity + scoring summary (for leagues page filters) */ getAllWithCapacityAndScoring(): Promise { return this.get('/leagues/all-with-capacity-and-scoring'); } /** Get total number of leagues */ getTotal(): Promise { return this.get('/leagues/total-leagues'); } /** Get league standings */ getStandings(leagueId: string): Promise { return this.get(`/leagues/${leagueId}/standings`); } /** Get league schedule */ getSchedule(leagueId: string): Promise { return this.get(`/leagues/${leagueId}/schedule`); } /** Get league memberships */ getMemberships(leagueId: string): Promise { return this.get(`/leagues/${leagueId}/memberships`); } /** Create a new league */ create(input: CreateLeagueInputDTO): Promise { return this.post('/leagues', input); } /** Remove a member from league */ removeMember(leagueId: string, performerDriverId: string, targetDriverId: string): Promise<{ success: boolean }> { return this.patch<{ success: boolean }>(`/leagues/${leagueId}/members/${targetDriverId}/remove`, { performerDriverId }); } /** Update a member's role in league */ updateMemberRole(leagueId: string, performerDriverId: string, targetDriverId: string, newRole: string): Promise<{ success: boolean }> { return this.patch<{ success: boolean }>(`/leagues/${leagueId}/members/${targetDriverId}/role`, { performerDriverId, newRole }); } /** Get league seasons */ getSeasons(leagueId: string): Promise { return this.get(`/leagues/${leagueId}/seasons`); } /** Get season sponsorships */ getSeasonSponsorships(seasonId: string): Promise<{ sponsorships: SponsorshipDetailDTO[] }> { return this.get<{ sponsorships: SponsorshipDetailDTO[] }>(`/leagues/seasons/${seasonId}/sponsorships`); } /** Get league config */ getLeagueConfig(leagueId: string): Promise { return this.get(`/leagues/${leagueId}/config`); } /** Get league scoring presets */ getScoringPresets(): Promise<{ presets: LeagueScoringPresetDTO[] }> { return this.get<{ presets: LeagueScoringPresetDTO[] }>(`/leagues/scoring-presets`); } /** Transfer league ownership */ transferOwnership(leagueId: string, currentOwnerId: string, newOwnerId: string): Promise<{ success: boolean }> { return this.post<{ success: boolean }>(`/leagues/${leagueId}/transfer-ownership`, { currentOwnerId, newOwnerId, }); } /** Get races for a league */ getRaces(leagueId: string): Promise<{ races: RaceDTO[] }> { return this.get<{ races: RaceDTO[] }>(`/leagues/${leagueId}/races`); } }