/* eslint-disable @typescript-eslint/no-explicit-any */
import axios from "@/lib/axios";

class ConversationApiService {
  async index(query: Record<string, any>) {
    try {
      const { data } = await axios({
        url: "conversations",
        params: query,
      });

      console.log("[NestJS] Response (conversation-index):", data);
      return data;
    } catch (err) {
      console.error("[NestJS] Error (conversation-index):", err);
      throw err;
    }
  }

  async getConversationByPrefix() {
    try {
      const { data } = await axios({
        url: "conversations/prefix",
        method: "POST",
      });

      console.log("[NestJS] Response (conversation-prefix):", data);
      return data;
    } catch (err) {
      console.error("[NestJS] Error (conversation-prefix):", err);
      throw err;
    }
  }
}

export const conversationApi = new ConversationApiService();
