import client, { apiPrefix, unwrap, type ApiResponse } from './client' export type OpenRecord = Record & { id: number } export type OpenSearch = { total: number; list: OpenRecord[]; counts: Record } export const openApi = { async search(params: Record) { const { data } = await client.get>(`${apiPrefix()}/opens/search`, { params }) return unwrap(data) }, async get(id: number) { const { data } = await client.get>(`${apiPrefix()}/opens/${id}`) return unwrap(data) }, async create(payload: Record) { const { data } = await client.post(`${apiPrefix()}/opens`, payload) return unwrap(data) }, async save(id: number, payload: Record) { const { data } = await client.put(`${apiPrefix()}/opens/${id}`, payload) return unwrap(data) }, async remove(id: number) { const { data } = await client.delete(`${apiPrefix()}/opens/${id}`) return unwrap(data) }, async serialLookup(serial: string, gubun = '휴대폰') { const { data } = await client.get[]>>(`${apiPrefix()}/opens/serial-lookup`, { params: { serial, gubun } }) return unwrap(data) }, }