import { request } from "../utils/request";

export const userApi = {
  getMe: () => request("/me"),
  updateMe: (data) => request("/me", { method: "PUT", body: data }),
  realName: (data) => request("/me/realname", { method: "POST", body: data }),
  getWallet: () => request("/me/wallet"),
  recharge: (data) =>
    request("/me/wallet/recharge", { method: "POST", body: data }),
  getOrders: (status) => request(`/me/orders?status=${status || "all"}`),
  getOrder: (id) => request(`/me/orders/${id}`),
  getLibrary: () => request("/me/library"),
  getFavorites: () => request("/me/favorites"),
  addFavorite: (contentId) =>
    request(`/me/favorites?contentId=${contentId}`, { method: "POST" }),
  removeFavorite: (contentId) =>
    request(`/me/favorites/${contentId}`, { method: "DELETE" }),
  getLikes: () => request("/me/likes"),
  addLike: (contentId) =>
    request(`/me/likes?contentId=${contentId}`, { method: "POST" }),
  removeLike: (contentId) =>
    request(`/me/likes/${contentId}`, { method: "DELETE" }),
  getNotifications: (type, page) =>
    request(`/me/notifications?type=${type || "all"}&page=${page || 1}`),
  markNotificationRead: (id) =>
    request(`/me/notifications/${id}/read`, { method: "POST" }),
  markAllNotificationsRead: () =>
    request("/me/notifications/read-all", { method: "POST" }),
  getFollowing: () => request("/me/following"),
  getCoupons: (status) => request(`/me/coupons?status=${status || "unused"}`),
  getAvailableCoupons: (amount) =>
    request(`/me/coupons/available?amount=${amount}`),
  receiveCoupon: (couponId) =>
    request("/me/coupons/receive", {
      method: "POST",
      body: { coupon_id: couponId },
    }),
};
