2022-10-18 19:55:31 +00:00
|
|
|
import z from "zod";
|
|
|
|
|
2022-03-16 23:36:43 +00:00
|
|
|
import { handleErrorsJson } from "@calcom/lib/errors";
|
2022-03-23 22:00:30 +00:00
|
|
|
import { randomString } from "@calcom/lib/random";
|
|
|
|
import type { PartialReference } from "@calcom/types/EventManager";
|
|
|
|
import type { VideoApiAdapter, VideoCallData } from "@calcom/types/VideoApiAdapter";
|
2022-02-03 11:59:02 +00:00
|
|
|
|
2022-10-18 19:55:31 +00:00
|
|
|
const huddle01Schema = z.object({ url: z.string().url(), roomId: z.string() });
|
|
|
|
|
2022-02-03 11:59:02 +00:00
|
|
|
const Huddle01VideoApiAdapter = (): VideoApiAdapter => {
|
|
|
|
return {
|
|
|
|
getAvailability: () => {
|
|
|
|
return Promise.resolve([]);
|
|
|
|
},
|
|
|
|
createMeeting: async (): Promise<VideoCallData> => {
|
|
|
|
const res = await fetch(
|
|
|
|
"https://wpss2zlpb9.execute-api.us-east-1.amazonaws.com/new-meeting?utmCampaign=cal.com&utmSource=partner&utmMedium=calendar"
|
|
|
|
);
|
|
|
|
|
2022-10-31 22:06:03 +00:00
|
|
|
const json = await handleErrorsJson<{ url: string }>(res);
|
2022-10-18 19:55:31 +00:00
|
|
|
const { url } = huddle01Schema.parse(json);
|
2022-10-31 22:06:03 +00:00
|
|
|
if (url) {
|
|
|
|
return Promise.resolve({
|
|
|
|
type: "huddle01_video",
|
|
|
|
id: randomString(21),
|
|
|
|
password: "",
|
|
|
|
url,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
return Promise.reject("Url was not received in response body.");
|
2022-02-03 11:59:02 +00:00
|
|
|
},
|
|
|
|
deleteMeeting: async (): Promise<void> => {
|
|
|
|
Promise.resolve();
|
|
|
|
},
|
|
|
|
updateMeeting: (bookingRef: PartialReference): Promise<VideoCallData> => {
|
|
|
|
return Promise.resolve({
|
|
|
|
type: "huddle01_video",
|
|
|
|
id: bookingRef.meetingId as string,
|
|
|
|
password: bookingRef.meetingPassword as string,
|
|
|
|
url: bookingRef.meetingUrl as string,
|
|
|
|
});
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
export default Huddle01VideoApiAdapter;
|