import { client } from "@/shared/api"; import { ENDPOINT } from "@/shared/config"; import type { ContentsService, ContentsParams, ContentsList, ContentsFormData, ContentsVersionParams, ContentsVersionList, ContentsDetail, } from "../model/contents-interface"; export class ContentsApiService implements ContentsService { public async getContentsList(params: ContentsParams): Promise { const response = await client.get( `${ENDPOINT.CMS_SERVICE.CONTENTS}`, { params }, ); return response.data; } public async getContentsVersionList( params: ContentsVersionParams, ): Promise { const response = await client.get( `${ENDPOINT.CMS_SERVICE.CONTENTS_DETAILS}`, { params }, ); return response.data; } public async getLatestContentsInfo( contsSn: number, contsVer: number, ): Promise { const response = await client.get( `${ENDPOINT.CMS_SERVICE.CONTENTS_DETAILS}/${contsSn}/${contsVer}`, ); return response.data; } public async createContents(data: ContentsFormData): Promise { const response = await client.post( `${ENDPOINT.CMS_SERVICE.CONTENTS_DETAILS}`, data, ); return response.data; } public async updateContents( contsSn: number, contsVer: number, data: ContentsFormData, ): Promise { const response = await client.put( `${ENDPOINT.CMS_SERVICE.CONTENTS_DETAILS}/${contsSn}/${contsVer}`, data, ); return response.data; } public async deleteContents( contsSn: number, contsVer: number, ): Promise { await client.delete( `${ENDPOINT.CMS_SERVICE.CONTENTS_DETAILS}/${contsSn}/${contsVer}`, ); } public async requestApprove( contsSn: number, contsVer: number, ): Promise { await client.put( `${ENDPOINT.CMS_SERVICE.CONTENTS_DETAILS}/${contsSn}/${contsVer}/approveRequest`, ); } public async approveContents( contsSn: number, contsVer: number, ): Promise { await client.put( `${ENDPOINT.CMS_SERVICE.CONTENTS_DETAILS}/${contsSn}/${contsVer}/approve`, ); } } export const ContentsApi = new ContentsApiService();