export const createZoomMeeting = async ({
  topic,
  startTime,
  duration,
  hostEmail,
}) => {
  const token = await getZoomAccessToken();

  try {
    const response = await axios.post(
      `https://api.zoom.us/v2/users/${hostEmail}/meetings`,
      {
        topic,
        type: 2,
        start_time: startTime,
        duration,
        timezone: "UTC",
        settings: {
          host_video: true,
          participant_video: true,
          join_before_host: false,
          mute_upon_entry: true,
          waiting_room: true,
        },
      },
      {
        headers: {
          Authorization: `Bearer ${token}`,
          "Content-Type": "application/json",
        },
      },
    );

    return response.data;
  } catch (err) {
    console.error(
      "Zoom meeting creation error:",
      err.response?.data || err.message,
    );
    throw err;
  }
};
