import { apiRequest } from './api';

export interface SettingsState {
  debug_mode: boolean;
  email_notifications: boolean;
  log_retention: number;
  max_retries: number;
  retry_delay: number;
  webhook_timeout: number;
}

export const SETTINGS_DEFAULTS: SettingsState = {
  debug_mode: false,
  email_notifications: true,
  log_retention: 30,
  max_retries: 3,
  retry_delay: 1,
  webhook_timeout: 30,
};

export async function getSettings(): Promise<SettingsState> {
  return apiRequest<SettingsState>('/settings');
}

export async function saveSettings(settings: SettingsState): Promise<SettingsState> {
  return apiRequest<SettingsState>('/settings', {
    method: 'POST',
    body: JSON.stringify(settings),
  });
}
