Files
gridpilot.gg/apps/website/lib/api/wallets/WalletsApiClient.ts
2025-12-19 21:58:03 +01:00

54 lines
1.3 KiB
TypeScript

import { BaseApiClient } from '../base/BaseApiClient';
export interface LeagueWalletDTO {
balance: number;
currency: string;
totalRevenue: number;
totalFees: number;
totalWithdrawals: number;
pendingPayouts: number;
canWithdraw: boolean;
withdrawalBlockReason?: string;
transactions: WalletTransactionDTO[];
}
export interface WalletTransactionDTO {
id: string;
type: 'sponsorship' | 'membership' | 'withdrawal' | 'prize';
description: string;
amount: number;
fee: number;
netAmount: number;
date: string; // ISO string
status: 'completed' | 'pending' | 'failed';
reference?: string;
}
export interface WithdrawRequestDTO {
amount: number;
currency: string;
seasonId: string;
destinationAccount: string;
}
export interface WithdrawResponseDTO {
success: boolean;
message?: string;
}
/**
* Wallets API Client
*
* Handles all wallet-related API operations.
*/
export class WalletsApiClient extends BaseApiClient {
/** Get league wallet */
getLeagueWallet(leagueId: string): Promise<LeagueWalletDTO> {
return this.get<LeagueWalletDTO>(`/leagues/${leagueId}/wallet`);
}
/** Withdraw from league wallet */
withdrawFromLeagueWallet(leagueId: string, request: WithdrawRequestDTO): Promise<WithdrawResponseDTO> {
return this.post<WithdrawResponseDTO>(`/leagues/${leagueId}/wallet/withdraw`, request);
}
}