import axios from 'axios' const api = axios.create({ baseURL: '/api', timeout: 30000, headers: { 'Content-Type': 'application/json', }, }) // Subscriptions API export const subscriptionsApi = { list: (params = {}) => api.get('/subscriptions', { params }), get: (id) => api.get(`/subscriptions/${id}`), create: (data) => api.post('/subscriptions', data), update: (id, data) => api.patch(`/subscriptions/${id}`, data), delete: (id) => api.delete(`/subscriptions/${id}`), triggerCheck: (id) => api.post(`/subscriptions/${id}/check`), listSources: (id) => api.get(`/subscriptions/${id}/sources`), addSource: (id, data) => api.post(`/subscriptions/${id}/sources`, data), } // Sources API export const sourcesApi = { list: (params = {}) => api.get('/sources', { params }), get: (id) => api.get(`/sources/${id}`), create: (data) => api.post('/sources', data), update: (id, data) => api.patch(`/sources/${id}`, data), delete: (id) => api.delete(`/sources/${id}`), triggerCheck: (id) => api.post(`/sources/${id}/check`), } // Downloads API export const downloadsApi = { list: (params = {}) => api.get('/downloads', { params }), get: (id) => api.get(`/downloads/${id}`), retry: (id) => api.post(`/downloads/${id}/retry`), stats: (params = {}) => api.get('/downloads/stats', { params }), recentActivity: (params = {}) => api.get('/downloads/recent-activity', { params }), resetOrphaned: (thresholdMinutes = 0) => api.post('/downloads/reset-orphaned', { threshold_minutes: thresholdMinutes }), requeueStale: (thresholdMinutes = 0) => api.post('/downloads/requeue-stale', { threshold_minutes: thresholdMinutes }), } // Credentials API export const credentialsApi = { list: () => api.get('/credentials'), upload: (data) => api.post('/credentials', data), delete: (platform) => api.delete(`/credentials/${platform}`), verify: (platform) => api.post('/credentials/verify', { platform }), } // Settings API export const settingsApi = { get: () => api.get('/settings'), update: (data) => api.patch('/settings', data), getGalleryDL: () => api.get('/settings/gallery-dl'), updateGalleryDL: (config) => api.put('/settings/gallery-dl', { config }), getApiKey: () => api.get('/settings/api-key'), regenerateApiKey: () => api.post('/settings/api-key/regenerate'), getLogs: (params = {}) => api.get('/settings/logs', { params }), refreshStorageStats: () => api.post('/settings/storage-stats/refresh'), } // Platforms API export const platformsApi = { list: () => api.get('/platforms'), get: (platform) => api.get(`/platforms/${platform}`), getConfigSchema: (platform) => api.get(`/platforms/${platform}/config-schema`), } export default api