Files
gridpilot.gg/apps/website/lib/api/payments/PaymentsApiClient.ts
2025-12-17 22:17:02 +01:00

54 lines
1.8 KiB
TypeScript

import { BaseApiClient } from '../base/BaseApiClient';
import type {
GetPaymentsOutputDto,
CreatePaymentInputDto,
CreatePaymentOutputDto,
GetMembershipFeesOutputDto,
GetPrizesOutputDto,
GetWalletOutputDto,
ProcessWalletTransactionInputDto,
ProcessWalletTransactionOutputDto,
UpdateMemberPaymentInputDto,
UpdateMemberPaymentOutputDto,
GetWalletTransactionsOutputDto,
} from '../../dtos';
/**
* Payments API Client
*
* Handles all payment-related API operations.
*/
export class PaymentsApiClient extends BaseApiClient {
/** Get payments */
getPayments(leagueId?: string, driverId?: string): Promise<GetPaymentsOutputDto> {
const params = new URLSearchParams();
if (leagueId) params.append('leagueId', leagueId);
if (driverId) params.append('driverId', driverId);
const query = params.toString();
return this.get<GetPaymentsOutputDto>(`/payments${query ? `?${query}` : ''}`);
}
/** Create a payment */
createPayment(input: CreatePaymentInputDto): Promise<CreatePaymentOutputDto> {
return this.post<CreatePaymentOutputDto>('/payments', input);
}
/** Get membership fees */
getMembershipFees(leagueId: string): Promise<GetMembershipFeesOutputDto> {
return this.get<GetMembershipFeesOutputDto>(`/payments/membership-fees?leagueId=${leagueId}`);
}
/** Get prizes */
getPrizes(leagueId?: string, seasonId?: string): Promise<GetPrizesOutputDto> {
const params = new URLSearchParams();
if (leagueId) params.append('leagueId', leagueId);
if (seasonId) params.append('seasonId', seasonId);
const query = params.toString();
return this.get<GetPrizesOutputDto>(`/payments/prizes${query ? `?${query}` : ''}`);
}
/** Get wallet */
getWallet(driverId: string): Promise<GetWalletOutputDto> {
return this.get<GetWalletOutputDto>(`/payments/wallets?driverId=${driverId}`);
}
}