23 lines
812 B
TypeScript
23 lines
812 B
TypeScript
import { WalletViewModel } from '@/lib/view-models/WalletViewModel';
|
|
import { PaymentsApiClient } from '../../api/payments/PaymentsApiClient';
|
|
import { FullTransactionDto } from '../../view-models/WalletTransactionViewModel';
|
|
|
|
/**
|
|
* Wallet Service
|
|
*
|
|
* Orchestrates wallet operations by coordinating API calls and view model creation.
|
|
* All dependencies are injected via constructor.
|
|
*/
|
|
export class WalletService {
|
|
constructor(
|
|
private readonly apiClient: PaymentsApiClient
|
|
) {}
|
|
|
|
/**
|
|
* Get wallet by driver ID with view model transformation
|
|
*/
|
|
async getWallet(driverId: string): Promise<WalletViewModel> {
|
|
const { wallet, transactions } = await this.apiClient.getWallet(driverId);
|
|
return new WalletViewModel({ ...wallet, transactions: transactions as FullTransactionDto[] });
|
|
}
|
|
} |