website refactor
This commit is contained in:
@@ -1,9 +1,16 @@
|
||||
import { Result } from '@/lib/contracts/Result';
|
||||
import { Service, DomainError } from '@/lib/contracts/services/Service';
|
||||
import { LeagueWalletApiDto } from '@/lib/types/tbd/LeagueWalletApiDto';
|
||||
import { WalletsApiClient } from '@/lib/api/wallets/WalletsApiClient';
|
||||
|
||||
export class LeagueWalletService implements Service {
|
||||
constructor(private readonly apiClient?: WalletsApiClient) {}
|
||||
|
||||
async getWalletForLeague(leagueId: string): Promise<LeagueWalletApiDto> {
|
||||
if (this.apiClient) {
|
||||
const res = await this.apiClient.getLeagueWallet(leagueId);
|
||||
return ((res as any).value || res) as any;
|
||||
}
|
||||
const result = await this.getWalletData(leagueId);
|
||||
if (result.isErr()) throw new Error(result.getError().message);
|
||||
return result.unwrap();
|
||||
@@ -14,8 +21,17 @@ export class LeagueWalletService implements Service {
|
||||
amount: number,
|
||||
currency: string,
|
||||
seasonId: string,
|
||||
destinationId: string
|
||||
destinationAccount: string
|
||||
): Promise<{ success: boolean; message?: string }> {
|
||||
if (this.apiClient) {
|
||||
const res = await this.apiClient.withdrawFromLeagueWallet(leagueId, {
|
||||
amount,
|
||||
currency,
|
||||
seasonId,
|
||||
destinationAccount,
|
||||
});
|
||||
return (res as any).value || res;
|
||||
}
|
||||
// Mock implementation
|
||||
return { success: true };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user