
* Initial changes * OAuth done and credentials stored * Added "other" integrations * Switching to hubspot api client * Event creation for all attendees * Update and delete done * Doc update * Fixing types * App label is not mandatory * Fixing bad merge: App label deleted * Fixing bad automerge * Removing c.log Co-authored-by: Omar López <zomars@me.com> Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
20 lines
767 B
TypeScript
20 lines
767 B
TypeScript
import { Credential } from "@prisma/client";
|
|
|
|
import logger from "@calcom/lib/logger";
|
|
import { Calendar } from "@calcom/types/Calendar";
|
|
|
|
import appStore from "..";
|
|
|
|
const log = logger.getChildLogger({ prefix: ["CalendarManager"] });
|
|
|
|
export const getCalendar = (credential: Credential | null): Calendar | null => {
|
|
if (!credential) return null;
|
|
const { type: calendarType } = credential;
|
|
const calendarApp = appStore[calendarType.split("_").join("") as keyof typeof appStore];
|
|
if (!(calendarApp && "lib" in calendarApp && "CalendarService" in calendarApp.lib)) {
|
|
log.warn(`calendar of type ${calendarType} is not implemented`);
|
|
return null;
|
|
}
|
|
const CalendarService = calendarApp.lib.CalendarService;
|
|
return new CalendarService(credential);
|
|
};
|