services refactor
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user