import { API_BASE, fetchWithAuth } from "./client"; export interface SubscriptionInfo { id: string; plan: string; status: string; start_date: string; end_date: string; amount: number | null; payment_method: string | null; created_at: string; } export const subscriptionsApi = { getPlans: async () => { const res = await fetch(`${API_BASE}/api/v1/subscriptions/plans`); if (!res.ok) throw new Error("获取套餐失败"); return res.json(); }, getCurrent: async (token: string): Promise => fetchWithAuth("/api/v1/subscriptions/current", {}, token), subscribe: async (token: string, plan: string) => fetchWithAuth( "/api/v1/subscriptions/subscribe", { method: "POST", body: JSON.stringify({ plan }), }, token ), cancel: async (token: string) => fetchWithAuth( "/api/v1/subscriptions/cancel", { method: "POST" }, token ), getHistory: async (token: string) => fetchWithAuth("/api/v1/subscriptions/history", {}, token), };