27 lines
757 B
TypeScript
27 lines
757 B
TypeScript
import { PaymentsApiClient } from '../../api/payments/PaymentsApiClient';
|
|
import { presentWallet } from '../../presenters/WalletPresenter';
|
|
import type { WalletViewModel } from '../../view-models';
|
|
|
|
/**
|
|
* Wallet Service
|
|
*
|
|
* Orchestrates wallet operations by coordinating API calls and presentation logic.
|
|
* All dependencies are injected via constructor.
|
|
*/
|
|
export class WalletService {
|
|
constructor(
|
|
private readonly apiClient: PaymentsApiClient
|
|
) {}
|
|
|
|
/**
|
|
* Get wallet by driver ID with presentation transformation
|
|
*/
|
|
async getWallet(driverId: string): Promise<WalletViewModel> {
|
|
try {
|
|
const dto = await this.apiClient.getWallet(driverId);
|
|
return presentWallet(dto);
|
|
} catch (error) {
|
|
throw error;
|
|
}
|
|
}
|
|
} |