import { get, post, put } from "./client";
import { ENDPOINTS } from "./endpoints";
import type {
  ServerSettingsResponse,
  ServerSettingsUpdate,
} from "../types/config";

export async function fetchServerSettings(): Promise<ServerSettingsResponse> {
  return get<ServerSettingsResponse>(ENDPOINTS.serverSettings);
}

export async function updateServerSettings(
  update: ServerSettingsUpdate,
): Promise<void> {
  await put<undefined>(ENDPOINTS.serverSettings, update);
}

export async function flushLogs(): Promise<string> {
  const resp = await post<{ message: string }>(
    ENDPOINTS.serverFlushLogs,
    undefined,
  );
  return resp.message;
}
