58 lines
1.9 KiB
TypeScript
58 lines
1.9 KiB
TypeScript
import { BaseApiClient } from '../base/BaseApiClient';
|
|
// Import generated types
|
|
import type { CompleteOnboardingInputDTO, CompleteOnboardingOutputDTO, DriverRegistrationStatusDTO, DriverLeaderboardItemDTO, DriverProfileDTO } from '../../types/generated';
|
|
|
|
// TODO: Create proper DriverDTO in generated types
|
|
type DriverDTO = {
|
|
id: string;
|
|
name: string;
|
|
avatarUrl?: string;
|
|
iracingId?: string;
|
|
rating?: number;
|
|
};
|
|
|
|
type DriversLeaderboardDto = {
|
|
drivers: DriverLeaderboardItemDTO[];
|
|
};
|
|
|
|
/**
|
|
* Drivers API Client
|
|
*
|
|
* Handles all driver-related API operations.
|
|
*/
|
|
export class DriversApiClient extends BaseApiClient {
|
|
/** Get drivers leaderboard */
|
|
getLeaderboard(): Promise<DriversLeaderboardDto> {
|
|
return this.get<DriversLeaderboardDto>('/drivers/leaderboard');
|
|
}
|
|
|
|
/** Complete driver onboarding */
|
|
completeOnboarding(input: CompleteOnboardingInputDTO): Promise<CompleteOnboardingOutputDTO> {
|
|
return this.post<CompleteOnboardingOutputDTO>('/drivers/complete-onboarding', input);
|
|
}
|
|
|
|
/** Get current driver (based on session) */
|
|
getCurrent(): Promise<DriverDTO | null> {
|
|
return this.get<DriverDTO | null>('/drivers/current');
|
|
}
|
|
|
|
/** Get driver registration status for a specific race */
|
|
getRegistrationStatus(driverId: string, raceId: string): Promise<DriverRegistrationStatusDTO> {
|
|
return this.get<DriverRegistrationStatusDTO>(`/drivers/${driverId}/races/${raceId}/registration-status`);
|
|
}
|
|
|
|
/** Get driver by ID */
|
|
getDriver(driverId: string): Promise<DriverDTO | null> {
|
|
return this.get<DriverDTO | null>(`/drivers/${driverId}`);
|
|
}
|
|
|
|
/** Get driver profile with full details */
|
|
getDriverProfile(driverId: string): Promise<DriverProfileDTO> {
|
|
return this.get<DriverProfileDTO>(`/drivers/${driverId}/profile`);
|
|
}
|
|
|
|
/** Update current driver profile */
|
|
updateProfile(updates: { bio?: string; country?: string }): Promise<DriverDTO> {
|
|
return this.put<DriverDTO>('/drivers/profile', updates);
|
|
}
|
|
} |