import apiClient from '../../../shared/services/apiClient';

export interface Backup {
  filename: string;
  path: string;
  size_bytes: number;
  size_mb: number;
  created_at: string;
  database: string;
  status: string;
}

class BackupService {
  async checkStatus() {
    const response = await apiClient.get('/backups/status');
    return response.data;
  }

  async createBackup() {
    const response = await apiClient.post('/backups/create');
    return response.data;
  }

  async listBackups() {
    const response = await apiClient.get('/backups');
    return response.data;
  }

  async downloadBackup(filename: string) {
    const response = await apiClient.get(`/backups/${filename}`, {
      responseType: 'blob',
    });
    return response.data;
  }

  async cleanupOldBackups() {
    const response = await apiClient.post('/backups/cleanup');
    return response.data;
  }
}

export default new BackupService();

