import { apiClient } from './client'
import type { Wallet, Transaction } from '@/types'

export const walletApi = {
  getWallet: async (): Promise<Wallet> => {
    const response = await apiClient.get<Wallet>('/api/v1/wallet')
    return response.data
  },

  deposit: async (amount: string): Promise<Wallet> => {
    const response = await apiClient.post<Wallet>('/api/v1/wallet/deposit', { amount })
    return response.data
  },

  withdraw: async (amount: string): Promise<Wallet> => {
    const response = await apiClient.post<Wallet>('/api/v1/wallet/withdraw', { amount })
    return response.data
  },

  getTransactions: async (limit = 50, offset = 0): Promise<Transaction[]> => {
    const response = await apiClient.get<Transaction[]>('/api/v1/wallet/transactions', {
      params: { limit, offset },
    })
    return response.data
  },
}
