import { client } from "@/shared/api"; import { ENDPOINT } from "@/shared/config"; import { LwpoCodeFormSchema, type LwpoCodeService, type LwpoCodeList, type LwpoCodeDetail, type LwpoCodeParams, type LwpoCodeFormData, } from "../model/lwpocode-interface"; export class LwpoCodeApiService implements LwpoCodeService { public async getLwpoCodeList(params?: LwpoCodeParams): Promise { const response = await client.get( `${ENDPOINT.CMS_SERVICE.LWPO_CODE}`, { params }, ); return response.data; } public async getUpCodeLwpoCodeList(upCd: string): Promise { const response = await client.get( `${ENDPOINT.CMS_SERVICE.LWPO_CODE}/up-cd/${upCd}`, ); return response.data; } public async LwpoCodeDetail(upCd: string, LwpoCd: string): Promise { const response = await client.get( `${ENDPOINT.CMS_SERVICE.LWPO_CODE}/${LwpoCd}/up-cd/${upCd}`, ); return response.data; } public async createLwpoCode(data: LwpoCodeFormData): Promise { const validatedData = LwpoCodeFormSchema.parse(data); const response = await client.post( `${ENDPOINT.CMS_SERVICE.LWPO_CODE}`, validatedData, ); return response.data; } public async updateLwpoCode(upCd: string, LwpoCd: string, data: LwpoCodeFormData): Promise { const validatedData = LwpoCodeFormSchema.parse(data); const response = await client.put( `${ENDPOINT.CMS_SERVICE.LWPO_CODE}/${LwpoCd}/up-cd/${upCd}`, validatedData, ); return response.data; } public async deleteLwpoCode(upCd: string, LwpoCd: string): Promise { await client.delete( `${ENDPOINT.CMS_SERVICE.LWPO_CODE}/${LwpoCd}/up-cd/${upCd}`, ); } } export const lwpoCodeApi = new LwpoCodeApiService();