Files
gridpilot.gg/apps/website/lib/gateways/api/drivers/DriversApiClient.ts
Marc Mintel 9ac74f5046
Some checks failed
CI / lint-typecheck (pull_request) Failing after 12s
CI / tests (pull_request) Has been skipped
CI / contract-tests (pull_request) Has been skipped
CI / e2e-tests (pull_request) Has been skipped
CI / comment-pr (pull_request) Has been skipped
CI / commit-types (pull_request) Has been skipped
code quality
2026-01-26 17:22:01 +01:00

59 lines
1.9 KiB
TypeScript

import type {
CompleteOnboardingInputDTO,
CompleteOnboardingOutputDTO,
DriverLeaderboardItemDTO,
DriverRegistrationStatusDTO,
GetDriverOutputDTO,
GetDriverProfileOutputDTO
} from '../../../types/generated';
import { BaseApiClient } from '../base/BaseApiClient';
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<GetDriverOutputDTO | null> {
return this.get<GetDriverOutputDTO | null>('/drivers/current', {
allowUnauthenticated: true,
retry: false
});
}
/** 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<GetDriverOutputDTO | null> {
return this.get<GetDriverOutputDTO | null>(`/drivers/${driverId}`);
}
/** Get driver profile with full details */
getDriverProfile(driverId: string): Promise<GetDriverProfileOutputDTO> {
return this.get<GetDriverProfileOutputDTO>(`/drivers/${driverId}/profile`);
}
/** Update current driver profile */
updateProfile(updates: { bio?: string; country?: string }): Promise<GetDriverOutputDTO> {
return this.put<GetDriverOutputDTO>('/drivers/profile', updates);
}
}