import { get, put, post } from '../utils/request';

export interface UserProfile {
  id: string;
  phone?: string;
  email?: string;
  nickname?: string;
  kycLevel: number;
  avatarUrl?: string;
}

export interface UserStats {
  ownedCount: number;
  usedCount: number;
  expiredCount: number;
}

export interface KycStatus {
  level: number;
  status: string; // 'pending' | 'approved' | 'rejected'
  dailyLimit: number;
}

/** 获取用户资料 */
export function getProfile() {
  return get<UserProfile>('/api/v1/users/me');
}

/** 获取用户统计 */
export function getUserStats() {
  return get<UserStats>('/api/v1/users/me/stats');
}

/** 获取KYC状态 */
export function getKycStatus() {
  return get<KycStatus>('/api/v1/users/kyc');
}

/** 提交KYC验证 */
export function submitKyc(data: { level: number; documents: Record<string, string> }) {
  return post<{ submissionId: string }>('/api/v1/users/kyc', data);
}

/** 更新用户设置 */
export function updateSettings(settings: {
  language?: string;
  currency?: string;
  notificationPrefs?: { trade: boolean; expiry: boolean; marketing: boolean };
}) {
  return put<void>('/api/v1/users/me/settings', settings);
}
