import request from '@/utils/request'
import type { ShopGiftCard } from './model'

/** 获取我的礼品卡列表 */
export function listMyGiftCards() {
  return request.get<{ code: number; data: ShopGiftCard[] }>('/shop/shop-gift/my')
}

/** 绑定/兑换礼品卡
 * @param code - 礼品卡代码
 */
export function bindGiftCard(code: string) {
  return request.post<{ code: number; message: string }>('/shop/shop-gift/bind', {
    code,
  })
}

/** 获取礼品卡余额（从用户卡包统计中获取） */
export function getGiftCardBalance() {
  return request.get<{ code: number; data: { giftCards: number } }>('/user/card/stats')
}
