import type { AxiosResponse } from "axios"; import { client } from "@/shared/api"; import { ENDPOINT } from "@/shared/config"; import type { Attachment, AttachmentList, AttachmentParams, AttachmentService, } from "../model/attachment-interface"; export class AttachmentApiService implements AttachmentService { public async getAttachmentsList( params: AttachmentParams, ): Promise { const response = await client.get( `${ENDPOINT.ATTACH_SERVICE.ATTACHMENTS}`, { params }, ); return response.data; } public async getAttachmentsInfo(atflCd: string): Promise { const response = await client.get( `${ENDPOINT.ATTACH_SERVICE.ATTACHMENTS}/${atflCd}`, ); return response.data; } public async deleteAttachmentByAtflId(atflId: string): Promise { await client.delete(`${ENDPOINT.ATTACH_SERVICE.ATTACHMENTS}/${atflId}`); } public async deleteAttachmentByAtflCd(atflCd: string): Promise { await client.delete( `${ENDPOINT.ATTACH_SERVICE.ATTACHMENTS}/atflCd/${atflCd}`, ); } public async getImageUrlByAtflId(atflId: string): Promise { if (!atflId) return ""; const response = await fetch(`${ENDPOINT.ATTACH_SERVICE.IMAGES}/${atflId}`); const blob = await response.blob(); return URL.createObjectURL(blob); } public async getImageUrlByAtflCd(atflCd: string): Promise { if (!atflCd) return ""; const response = await fetch( `${ENDPOINT.ATTACH_SERVICE.IMAGES}/atflCd/${atflCd}`, ); const blob = await response.blob(); return URL.createObjectURL(blob); } public async getStreamVideoUrlByAtflId(atflId: string): Promise { const response = await fetch( `${ENDPOINT.ATTACH_SERVICE.STREAM_VIDEO}/${atflId}`, ); const blob = await response.blob(); return URL.createObjectURL(blob); } public async getMovieThumbnailUrlByAtflId(atflId: string): Promise { const response = await fetch( `${ENDPOINT.ATTACH_SERVICE.MOVIE_THUMBNAIL}/${atflId}`, ); const blob = await response.blob(); return URL.createObjectURL(blob); } public async getMovieThumbnailUrlByAtflCd(atflCd: string): Promise { const response = await fetch( `${ENDPOINT.ATTACH_SERVICE.MOVIE_THUMBNAIL}/atflCd/${atflCd}`, ); const blob = await response.blob(); return URL.createObjectURL(blob); } public async downloadAttachmentByAtflCd( atflCd: string, ): Promise { const response = await client.get( `${ENDPOINT.ATTACH_SERVICE.DOWNLOAD}/${atflCd}`, { responseType: "blob" }, ); return response; } } export const AttachmentApi = new AttachmentApiService();