import axios from "@/lib/axios";

class MessageApiService {
  async sendSingleMessage(message: IMessage) {
    try {
      const { data } = await axios.post("/messages", message);
      console.log("[NestJS] Response (single):", data);
      return data;
    } catch (err) {
      console.error("[NestJS] Error (single):", err);
      throw err;
    }
  }

  async sendBulkMessages(messages: IMessage[]) {
    try {
      const { data } = await axios.post("/messages/bulk", { data: messages });
      console.log("[NestJS] Response (bulk):", data);
      return data;
    } catch (err) {
      console.error("[NestJS] Error (bulk):", err);
      throw err;
    }
  }
}

export const messageApi = new MessageApiService();
