services refactor

This commit is contained in:
2025-12-17 22:17:02 +01:00
parent 26f7a2b6aa
commit 055a7f67b5
93 changed files with 7434 additions and 659 deletions

View File

@@ -1,8 +1,27 @@
import { api as api } from '../../api';
import { presentWallet } from '../../presenters';
import { WalletViewModel } from '../../view-models';
import { PaymentsApiClient } from '../../api/payments/PaymentsApiClient';
import { presentWallet } from '../../presenters/WalletPresenter';
import type { WalletViewModel } from '../../view-models';
export async function getWallet(driverId: string): Promise<WalletViewModel> {
const dto = await api.payments.getWallet(driverId);
return presentWallet(dto);
/**
* 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;
}
}
}