import httpClient from './httpClient';

export const mediaService = {
    getMedias({ page = 1, limit = 10 } = {}) {
        return httpClient.get('/admin/medias', {
            params: { page, limit }
        });
    },

    createMedia(mediaInfo) {
        return httpClient.post('/admin/medias', mediaInfo);
    },

    preUploadedCheck(md5, ext, mime) {
        return httpClient.get(`/admin/uploads/pre-uploaded-check/${md5}.${ext}`, {
            params: { mime }
        });
    },

    uploadedSuccess(data) {
        return httpClient.post('/admin/uploads/post-uploaded-action', data);
    },

    getMediaPreviewUrl(id) {
        const token = localStorage.getItem('__token');
        return `${httpClient.defaults.baseURL}/admin/medias/${id}?token=${token}`;
    },
    delete(id) {
        return httpClient.delete(`/admin/medias/${id}`);
    },
};