import { fetchWithAuth } from "./client";

export const queriesApi = {
  list: (token: string) => fetchWithAuth("/api/v1/queries/", {}, token),
  create: (token: string, data: unknown) =>
    fetchWithAuth(
      "/api/v1/queries/",
      { method: "POST", body: JSON.stringify(data) },
      token
    ),
  update: (token: string, id: string, data: unknown) =>
    fetchWithAuth(
      `/api/v1/queries/${id}`,
      { method: "PUT", body: JSON.stringify(data) },
      token
    ),
  delete: (token: string, id: string) =>
    fetchWithAuth(`/api/v1/queries/${id}`, { method: "DELETE" }, token),
  runNow: (token: string, id: string) =>
    fetchWithAuth(`/api/v1/queries/${id}/run-now`, { method: "POST" }, token),
};
