1 import { CALENDAR_VALIDATION_MODE } from '../calendar/constants';
4 CalendarNotificationSettings,
7 } from '../interfaces/calendar';
9 type CalendarCreateArguments,
10 type CalendarCreateOrUpdateEventBlobData,
11 type CalendarEventsIDsQuery,
12 type CalendarEventsQuery,
13 type CalendarExportEventsQuery,
14 type CalendarKeysResetData,
15 type CalendarSetupData,
16 type CreateCalendarMemberData,
17 type CreatePublicLinks,
18 type CreateSinglePersonalEventData,
19 type GetBusySlotsParams,
20 type GetEventByUIDArguments,
21 type QueryCalendarAlarms,
22 type SyncMultipleEventsData,
23 type UpdateCalendarInviteData,
24 type UpdateCalendarMemberData,
25 VIDEO_CONFERENCE_PROVIDER,
26 } from '../interfaces/calendar/Api';
27 import type { Nullable, RequireOnly } from '../interfaces/utils';
28 import type { PaginationParams } from './interface';
30 const CALENDAR_V1 = 'calendar/v1';
32 export const queryLatestModelEventID = (calendarID: string) => ({
33 url: `${CALENDAR_V1}/${calendarID}/modelevents/latest`,
37 export const queryModelEvents = (calendarID: string, eventID: string) => ({
38 url: `${CALENDAR_V1}/${calendarID}/modelevents/${eventID}`,
42 export const queryCalendars = () => ({
43 url: `${CALENDAR_V1}`,
47 export const createCalendar = (data: CalendarCreateArguments) => ({
48 url: `${CALENDAR_V1}`,
53 export const setupCalendar = (calendarID: string, data: CalendarSetupData) => ({
54 url: `${CALENDAR_V1}/${calendarID}/keys`,
59 export const getCalendar = (calendarID: string) => ({
60 url: `${CALENDAR_V1}/${calendarID}`,
64 export const getFullCalendar = (calendarID: string) => ({
65 url: `${CALENDAR_V1}/${calendarID}/bootstrap`,
69 export const getCalendarKeys = (calendarID: string) => ({
70 url: `${CALENDAR_V1}/${calendarID}/keys`,
74 export const getAllCalendarKeys = (calendarID: string) => ({
75 url: `${CALENDAR_V1}/${calendarID}/keys/all`,
79 export const getPassphrases = (calendarID: string) => ({
80 url: `${CALENDAR_V1}/${calendarID}/passphrases`,
84 export const getPassphrase = (calendarID: string) => ({
85 url: `${CALENDAR_V1}/${calendarID}/passphrase`,
89 export const reactivateCalendarKey = (calendarID: string, keyID: string, data: { PrivateKey: string }) => ({
90 url: `${CALENDAR_V1}/${calendarID}/keys/${keyID}`,
95 export const getCalendarGroupReset = () => ({
96 url: `${CALENDAR_V1}/keys/reset`,
100 export const resetCalendars = (data: { CalendarKeys: CalendarKeysResetData }) => ({
101 url: `${CALENDAR_V1}/keys/reset`,
106 export const removeCalendar = (calendarID: string) => ({
107 url: `${CALENDAR_V1}/${calendarID}`,
111 export const removeHolidaysCalendar = (calendarID: string) => ({
112 url: `${CALENDAR_V1}/${calendarID}/managed`,
116 export const queryMembers = (calendarID: string, params?: PaginationParams) => ({
117 url: `${CALENDAR_V1}/${calendarID}/members`,
122 export const getAllMembers = (calendarID: string) => ({
123 url: `${CALENDAR_V1}/${calendarID}/members/all`,
127 export const getCalendarInvitations = (calendarID: string) => ({
128 url: `${CALENDAR_V1}/${calendarID}/invitations`,
132 export const getAllInvitations = () => ({
133 url: `${CALENDAR_V1}/invitations`,
137 export const addMember = (
139 data: { AddressID: string; Signature: string; Members: CreateCalendarMemberData[] }
141 url: `${CALENDAR_V1}/${calendarID}/members`,
146 export const updateMember = (calendarID: string, memberID: string, data: Partial<UpdateCalendarMemberData>) => ({
147 url: `${CALENDAR_V1}/${calendarID}/members/${memberID}`,
152 export const updateMemberPermission = (
155 data: RequireOnly<Pick<UpdateCalendarMemberData, 'Permissions' | 'PassphraseKeyPacket'>, 'Permissions'>
157 url: `${CALENDAR_V1}/${calendarID}/members/${memberID}/permission`,
162 export const updateInvitation = (
164 invitationID: string,
165 data: Partial<UpdateCalendarInviteData>
167 url: `${CALENDAR_V1}/${calendarID}/invitations/${invitationID}`,
172 export const removeMember = (calendarID: string, memberID: string) => ({
173 url: `${CALENDAR_V1}/${calendarID}/members/${memberID}`,
177 export const getInvitation = (calendarID: string, invitationID: string) => ({
178 url: `${CALENDAR_V1}/${calendarID}/invitations/${invitationID}`,
182 export const removeInvitation = (calendarID: string, invitationID: string) => ({
183 url: `${CALENDAR_V1}/${calendarID}/invitations/${invitationID}`,
187 export const acceptInvitation = (calendarID: string, addressID: string, data: { Signature: string }) => ({
188 url: `${CALENDAR_V1}/${calendarID}/invitations/${addressID}/accept`,
193 export const rejectInvitation = (calendarID: string, addressID: string) => ({
194 url: `${CALENDAR_V1}/${calendarID}/invitations/${addressID}/reject`,
198 export const getEventsCount = (calendarID: string) => ({
199 url: `${CALENDAR_V1}/${calendarID}/events/count`,
203 export const queryEvents = (
205 params: CalendarEventsQuery | CalendarExportEventsQuery | GetEventByUIDArguments
207 url: `${CALENDAR_V1}/${calendarID}/events`,
212 export const queryEventsIDs = (calendarID: string, params: CalendarEventsIDsQuery) => ({
213 url: `${CALENDAR_V1}/${calendarID}/events/ids`,
218 export const getEvent = (calendarID: string, eventID: string) => ({
219 url: `${CALENDAR_V1}/${calendarID}/events/${eventID}`,
223 export const getEventByUID = (params: GetEventByUIDArguments) => ({
224 url: `${CALENDAR_V1}/events`,
229 export const deleteEvent = (calendarID: string, eventID: string) => ({
230 url: `${CALENDAR_V1}/${calendarID}/events/${eventID}`,
234 export const updatePersonalEventPart = (calendarID: string, eventID: string, data: CreateSinglePersonalEventData) => ({
235 url: `${CALENDAR_V1}/${calendarID}/events/${eventID}/personal`,
240 export const updateAttendeePartstat = (
244 data: Pick<Attendee, 'Status' | 'UpdateTime'>
246 url: `${CALENDAR_V1}/${calendarID}/events/${eventID}/attendees/${attendeeID}`,
251 export const attendeeDeleteSingleEdit = (
254 data: Pick<CalendarCreateOrUpdateEventBlobData, 'CalendarEventContent'>
256 url: `${CALENDAR_V1}/${calendarID}/events/${eventID}/attendee_delete_single_edit`,
261 export const upgradeP2PInvite = (
264 data: Pick<CalendarCreateOrUpdateEventBlobData, 'SharedKeyPacket'>
266 url: `${CALENDAR_V1}/${calendarID}/events/${eventID}/upgrade`,
271 export const acceptInvite = (uid: string, data: { Signature: string }) => ({
272 url: `${CALENDAR_V1}/events/${uid}/accept`,
277 export const getCalendarSettings = (calendarID: string) => ({
278 url: `${CALENDAR_V1}/${calendarID}/settings`,
282 export const updateCalendarSettings = (calendarID: string, data: Partial<CalendarSettings>) => ({
283 url: `${CALENDAR_V1}/${calendarID}/settings`,
288 export const getCalendarUserSettings = () => ({
289 url: 'settings/calendar',
293 export const updateCalendarUserSettings = (data: Partial<CalendarUserSettings>) => ({
294 url: 'settings/calendar',
299 export const getAllowedTimeZones = () => ({
300 url: `${CALENDAR_V1}/timezones`,
304 export const getVtimezones = (Timezones: string[]) => ({
305 // params doesn't work correctly so
306 url: `${CALENDAR_V1}/vtimezones?${Timezones.map((tzid) => `Timezones[]=${tzid}`).join('&')}`,
308 // params: { Timezones }
311 export const queryCalendarAlarms = (calendarID: string, params: QueryCalendarAlarms) => ({
312 url: `${CALENDAR_V1}/${calendarID}/alarms`,
317 export const getCalendarAlarm = (calendarID: string, alarmID: string) => ({
318 url: `${CALENDAR_V1}/${calendarID}/alarms/${alarmID}`,
322 export const syncMultipleEvents = (calendarID: string, data: SyncMultipleEventsData) => ({
323 url: `${CALENDAR_V1}/${calendarID}/events/sync`,
328 export const createPublicLink = (calendarID: string, data: CreatePublicLinks) => ({
329 url: `${CALENDAR_V1}/${calendarID}/urls`,
334 export const getPublicLinks = (calendarID: string) => ({
335 url: `${CALENDAR_V1}/${calendarID}/urls`,
339 export const deletePublicLink = ({ calendarID, urlID }: { calendarID: string; urlID: string }) => ({
340 url: `${CALENDAR_V1}/${calendarID}/urls/${urlID}`,
344 export const editPublicLink = ({
351 encryptedPurpose: Nullable<string>;
353 url: `${CALENDAR_V1}/${calendarID}/urls/${urlID}`,
355 data: { EncryptedPurpose: encryptedPurpose },
358 export const getSubscriptionParameters = (calendarID: string) => ({
359 url: `${CALENDAR_V1}/${calendarID}/subscription`,
363 export const validateSubscription = ({
365 mode: Mode = CALENDAR_VALIDATION_MODE.DOWNLOAD_AND_PARSE,
368 mode?: CALENDAR_VALIDATION_MODE;
370 url: `${CALENDAR_V1}/subscription/validate`,
375 export const getDirectoryCalendars = (type: number) => ({
376 url: `${CALENDAR_V1}/directory?Type=${type}`,
380 export const joinHolidaysCalendar = (
384 PassphraseKeyPacket: string;
387 DefaultFullDayNotifications: CalendarNotificationSettings[];
391 url: `${CALENDAR_V1}/${calendarID}/invitations/${addressID}/join`,
396 export const getBusySlots = (emailAddress: string, params: GetBusySlotsParams) => ({
397 url: `${CALENDAR_V1}/${emailAddress}/busy-schedule`,
403 * Only Zoom is supported for the moment
405 export const createZoomMeeting = () => ({
406 url: `${CALENDAR_V1}/videoconferences`,
408 data: { Provider: VIDEO_CONFERENCE_PROVIDER.ZOOM },