Repository URL to install this package:
|
Version:
0.0.0-eb7f46753a3bdc ▾
|
const revhash = require('rev-hash');
const { MEETING_TYPES, MEETING_LOCATIONS, VIDEO_CONFERENCING_TOOLS } = require('../constants');
const { OPTION_STRATEGIES, MeetingOptions } = require('./meeting-options-builder');
const { NEXT_THREE_DAYS } = OPTION_STRATEGIES;
class SchedulingAttempt {
constructor() {
this.descriptionText = 'Meeting Description';
this.meetingType = MEETING_TYPES['Groups (Schedex)'];
this.videoConferencingProvider = null;
this.meetingTitle = 'Meeting Title';
this.allDayOptions = false;
this.locations = [];
}
withMeetingType(meetingType) {
this.meetingType = meetingType;
return this;
}
withMeetingTitle(meetingTitle) {
this.meetingTitle = meetingTitle;
return this;
}
withAllDayOptions(value) {
this.allDayOptions = value;
return this;
}
withLocationText(locationText) {
this.locations.push({
value: locationText,
type: MEETING_LOCATIONS.Text,
});
return this;
}
withDescriptionText(descriptionText) {
this.descriptionText = descriptionText;
return this;
}
withVideoConferencingProvider(videoConferencingProvider) {
if (Object.values(VIDEO_CONFERENCING_TOOLS).includes(videoConferencingProvider)) {
this.videoConferencingProvider = videoConferencingProvider;
this.locations.push({
type: videoConferencingProvider,
value: '',
});
}
return this;
}
build() {
return {
// TODO: What will break if we don't supply this availabilityCalendars value?
// TODO: Where can we fetch this availabilityCalendars calendar id?
availabilityCalendars: [],
preCreationSchedulingAttemptId: revhash(new Date().toUTCString()),
title: this.meetingTitle,
description: this.descriptionText,
timezone: 'Europe/Zurich',
state: 'OPEN',
type: this.meetingType,
options: new MeetingOptions()
.withGenerationStrategy(NEXT_THREE_DAYS)
.withAllDayOptions(this.allDayOptions)
.build(),
locations: this.locations,
features: {
automaticReminder: false,
deadline: null,
isHidden: false,
voteLimitPerOption: null,
},
notifyOrganizer: false,
questions: [],
lockTimezone: true,
syncQuestions: true,
};
}
}
module.exports = SchedulingAttempt;