import { lotteryRequest } from "@/lib/lottery-http";
import type { WalletBalanceData } from "@/types/api/wallet-balance";
import type {
  WalletTransferBody,
  WalletTransferResultData,
} from "@/types/api/wallet-transfer";
import type { GetWalletLogsParams, WalletLogsData } from "@/types/api/wallet-logs";

export type GetWalletBalanceParams = {
  /** Query `currency`，不传则用玩家默认币种 */
  currency?: string;
};

/** `GET /api/v1/wallet/balance`（需玩家 Token） */
export function getWalletBalance(
  params?: GetWalletBalanceParams,
): Promise<WalletBalanceData> {
  return lotteryRequest.get<WalletBalanceData>(
    `/wallet/balance`,
    { params },
  );
}

/** `GET /api/v1/wallet/logs`（需玩家 Token） */
export function getWalletLogs(
  params?: GetWalletLogsParams,
): Promise<WalletLogsData> {
  return lotteryRequest.get<WalletLogsData>(
    `/wallet/logs`,
    { params },
  );
}

/** `POST /api/v1/wallet/transfer-in`（主站 → 彩票） */
export function postWalletTransferIn(
  body: WalletTransferBody,
): Promise<WalletTransferResultData> {
  return lotteryRequest.post<WalletTransferResultData>(
    `/wallet/transfer-in`,
    body,
  );
}

/** `POST /api/v1/wallet/transfer-out`（彩票 → 主站） */
export function postWalletTransferOut(
  body: WalletTransferBody,
): Promise<WalletTransferResultData> {
  return lotteryRequest.post<WalletTransferResultData>(
    `/wallet/transfer-out`,
    body,
  );
}

export type { WalletTransferBody, WalletTransferResultData } from "@/types/api/wallet-transfer";
export type {
  GetWalletLogsParams,
  WalletLogItem,
  WalletLogsData,
  WalletPendingTransfer,
} from "@/types/api/wallet-logs";
