// 地址相关接口
import { get, post } from '@/core/http/http-client'
import { buildRestPath } from '@/core/config/api-paths'

/**
 * 获取地址列表
 * 对接 88live 的 /wanlshop/address/getaddress 接口
 */
export async function pullAddressList() {
	const { data } = await get(buildRestPath('address/getaddress'))
	return Array.isArray(data) ? data : (data.data || [])
}

/**
 * 新增/编辑地址
 * 对接 88live 的 /wanlshop/address/address 接口
 * type: 'add' | 'edit' | 'newadd'
 */
export async function postAddressSave({ data, type = 'add' }) {
	const { data: resData } = await post(buildRestPath('address/address'), { data, type })
	return resData
}

/**
 * 删除地址
 * 对接 88live 的 /wanlshop/address/deladdress 接口
 */
export async function postAddressDelete({ id }) {
	await post(buildRestPath('address/deladdress'), { id })
}