import { get, post, del } from '../utils/http'; import { configService } from './configService'; // @ts-ignore import { MeetRoom, MeetRoomOptions } from '../../../typings/src/room'; export async function getAllRooms(): Promise<{pagination:any, rooms: MeetRoom[]}> { const url = `${configService.meetApiUrl}/rooms`; return get<{pagination:any, rooms: MeetRoom[]}>(url, { headers: { 'x-api-key': configService.apiKey }, }); } export async function createRoom(roomData: MeetRoomOptions): Promise { const url = `${configService.meetApiUrl}/rooms`; // Default to 1 hour if autoDeletionDate is not provided if(!roomData.autoDeletionDate) roomData.autoDeletionDate = new Date(Date.now() + 60 * 61 * 1000).getTime(); console.log('Creating room with options:', roomData); return post(url, { headers: { 'x-api-key': configService.apiKey }, body: roomData, }); } export async function deleteRoom(roomId: string): Promise { const url = `${configService.meetApiUrl}/rooms/${roomId}`; await del(url, { headers: { 'x-api-key': configService.apiKey }, }); }