import { createCoreAPIClient } from "../../coreClient";
import { CHATBOT_API_ROUTES } from "../constants/api_constants";

const coreClient = createCoreAPIClient();

export async function createPrompt(payload: {
  prompt_name: string;
  prompt_value: string;
  prompt_key?: string;
}) {
  return coreClient<any>(CHATBOT_API_ROUTES.PROMPTS, {
    method: "POST",
    body: JSON.stringify(payload),
  });
}

export async function updatePrompt(
  id: string,
  payload: {
    prompt_name: string;
    prompt_value: string;
    prompt_key?: string;
  },
  options?: RequestInit,
) {
  return coreClient<any>(`${CHATBOT_API_ROUTES.PROMPTS}/${id}`, {
    ...options,
    method: "PUT",
    body: JSON.stringify(payload),
    headers: {
      "Content-Type": "application/json",
      ...(options?.headers || {}),
    },
  });
}

export async function deletePrompt(id: string, options?: RequestInit) {
  return coreClient<any>(`${CHATBOT_API_ROUTES.PROMPTS}/${id}`, {
    method: "DELETE",
    ...options,
  });
}
