import type { DriversApiClient } from '../../api/drivers/DriversApiClient'; import { DriverLeaderboardViewModel } from '../../view-models'; import { DriverViewModel } from '../../view-models/DriverViewModel'; import { CompleteOnboardingViewModel } from '../../view-models/CompleteOnboardingViewModel'; import type { CompleteOnboardingInputDTO } from '../../types/generated'; /** * Driver Service * * Orchestrates driver operations by coordinating API calls and view model creation. * All dependencies are injected via constructor. */ export class DriverService { constructor( private readonly apiClient: DriversApiClient ) {} /** * Get driver leaderboard with view model transformation */ async getDriverLeaderboard(): Promise { const dto = await this.apiClient.getLeaderboard(); return new DriverLeaderboardViewModel(dto); } /** * Complete driver onboarding with view model transformation */ async completeDriverOnboarding(input: CompleteOnboardingInputDTO): Promise { const dto = await this.apiClient.completeOnboarding(input); return new CompleteOnboardingViewModel(dto); } /** * Get current driver with view model transformation */ async getCurrentDriver(): Promise { const dto = await this.apiClient.getCurrent(); if (!dto) { return null; } return new DriverViewModel(dto); } }