1 import { CALENDAR_VALIDATION_MODE } from '../calendar/constants';
4 CalendarNotificationSettings,
7 } from '../interfaces/calendar';
9 CalendarCreateArguments,
10 CalendarCreateOrUpdateEventBlobData,
11 CalendarEventsIDsQuery,
13 CalendarExportEventsQuery,
14 CalendarKeysResetData,
16 CreateCalendarMemberData,
18 CreateSinglePersonalEventData,
20 GetEventByUIDArguments,
22 SyncMultipleEventsData,
23 UpdateCalendarInviteData,
24 UpdateCalendarMemberData,
25 } from '../interfaces/calendar/Api';
26 import type { Nullable, RequireOnly } from '../interfaces/utils';
27 import type { PaginationParams } from './interface';
29 const CALENDAR_V1 = 'calendar/v1';
31 export const queryLatestModelEventID = (calendarID: string) => ({
32 url: `${CALENDAR_V1}/${calendarID}/modelevents/latest`,
36 export const queryModelEvents = (calendarID: string, eventID: string) => ({
37 url: `${CALENDAR_V1}/${calendarID}/modelevents/${eventID}`,
41 export const queryCalendars = () => ({
42 url: `${CALENDAR_V1}`,
46 export const createCalendar = (data: CalendarCreateArguments) => ({
47 url: `${CALENDAR_V1}`,
52 export const setupCalendar = (calendarID: string, data: CalendarSetupData) => ({
53 url: `${CALENDAR_V1}/${calendarID}/keys`,
58 export const getCalendar = (calendarID: string) => ({
59 url: `${CALENDAR_V1}/${calendarID}`,
63 export const getFullCalendar = (calendarID: string) => ({
64 url: `${CALENDAR_V1}/${calendarID}/bootstrap`,
68 export const getCalendarKeys = (calendarID: string) => ({
69 url: `${CALENDAR_V1}/${calendarID}/keys`,
73 export const getAllCalendarKeys = (calendarID: string) => ({
74 url: `${CALENDAR_V1}/${calendarID}/keys/all`,
78 export const getPassphrases = (calendarID: string) => ({
79 url: `${CALENDAR_V1}/${calendarID}/passphrases`,
83 export const getPassphrase = (calendarID: string) => ({
84 url: `${CALENDAR_V1}/${calendarID}/passphrase`,
88 export const reactivateCalendarKey = (calendarID: string, keyID: string, data: { PrivateKey: string }) => ({
89 url: `${CALENDAR_V1}/${calendarID}/keys/${keyID}`,
94 export const getCalendarGroupReset = () => ({
95 url: `${CALENDAR_V1}/keys/reset`,
99 export const resetCalendars = (data: { CalendarKeys: CalendarKeysResetData }) => ({
100 url: `${CALENDAR_V1}/keys/reset`,
105 export const removeCalendar = (calendarID: string) => ({
106 url: `${CALENDAR_V1}/${calendarID}`,
110 export const removeHolidaysCalendar = (calendarID: string) => ({
111 url: `${CALENDAR_V1}/${calendarID}/managed`,
115 export const queryMembers = (calendarID: string, params?: PaginationParams) => ({
116 url: `${CALENDAR_V1}/${calendarID}/members`,
121 export const getAllMembers = (calendarID: string) => ({
122 url: `${CALENDAR_V1}/${calendarID}/members/all`,
126 export const getCalendarInvitations = (calendarID: string) => ({
127 url: `${CALENDAR_V1}/${calendarID}/invitations`,
131 export const getAllInvitations = () => ({
132 url: `${CALENDAR_V1}/invitations`,
136 export const addMember = (
138 data: { AddressID: string; Signature: string; Members: CreateCalendarMemberData[] }
140 url: `${CALENDAR_V1}/${calendarID}/members`,
145 export const updateMember = (calendarID: string, memberID: string, data: Partial<UpdateCalendarMemberData>) => ({
146 url: `${CALENDAR_V1}/${calendarID}/members/${memberID}`,
151 export const updateMemberPermission = (
154 data: RequireOnly<Pick<UpdateCalendarMemberData, 'Permissions' | 'PassphraseKeyPacket'>, 'Permissions'>
156 url: `${CALENDAR_V1}/${calendarID}/members/${memberID}/permission`,
161 export const updateInvitation = (
163 invitationID: string,
164 data: Partial<UpdateCalendarInviteData>
166 url: `${CALENDAR_V1}/${calendarID}/invitations/${invitationID}`,
171 export const removeMember = (calendarID: string, memberID: string) => ({
172 url: `${CALENDAR_V1}/${calendarID}/members/${memberID}`,
176 export const getInvitation = (calendarID: string, invitationID: string) => ({
177 url: `${CALENDAR_V1}/${calendarID}/invitations/${invitationID}`,
181 export const removeInvitation = (calendarID: string, invitationID: string) => ({
182 url: `${CALENDAR_V1}/${calendarID}/invitations/${invitationID}`,
186 export const acceptInvitation = (calendarID: string, addressID: string, data: { Signature: string }) => ({
187 url: `${CALENDAR_V1}/${calendarID}/invitations/${addressID}/accept`,
192 export const rejectInvitation = (calendarID: string, addressID: string) => ({
193 url: `${CALENDAR_V1}/${calendarID}/invitations/${addressID}/reject`,
197 export const getEventsCount = (calendarID: string) => ({
198 url: `${CALENDAR_V1}/${calendarID}/events/count`,
202 export const queryEvents = (
204 params: CalendarEventsQuery | CalendarExportEventsQuery | GetEventByUIDArguments
206 url: `${CALENDAR_V1}/${calendarID}/events`,
211 export const queryEventsIDs = (calendarID: string, params: CalendarEventsIDsQuery) => ({
212 url: `${CALENDAR_V1}/${calendarID}/events/ids`,
217 export const getEvent = (calendarID: string, eventID: string) => ({
218 url: `${CALENDAR_V1}/${calendarID}/events/${eventID}`,
222 export const getEventByUID = (params: GetEventByUIDArguments) => ({
223 url: `${CALENDAR_V1}/events`,
228 export const deleteEvent = (calendarID: string, eventID: string) => ({
229 url: `${CALENDAR_V1}/${calendarID}/events/${eventID}`,
233 export const updatePersonalEventPart = (calendarID: string, eventID: string, data: CreateSinglePersonalEventData) => ({
234 url: `${CALENDAR_V1}/${calendarID}/events/${eventID}/personal`,
239 export const updateAttendeePartstat = (
243 data: Pick<Attendee, 'Status' | 'UpdateTime'>
245 url: `${CALENDAR_V1}/${calendarID}/events/${eventID}/attendees/${attendeeID}`,
250 export const attendeeDeleteSingleEdit = (
253 data: Pick<CalendarCreateOrUpdateEventBlobData, 'CalendarEventContent'>
255 url: `${CALENDAR_V1}/${calendarID}/events/${eventID}/attendee_delete_single_edit`,
260 export const upgradeP2PInvite = (
263 data: Pick<CalendarCreateOrUpdateEventBlobData, 'SharedKeyPacket'>
265 url: `${CALENDAR_V1}/${calendarID}/events/${eventID}/upgrade`,
270 export const acceptInvite = (uid: string, data: { Signature: string }) => ({
271 url: `${CALENDAR_V1}/events/${uid}/accept`,
276 export const getCalendarSettings = (calendarID: string) => ({
277 url: `${CALENDAR_V1}/${calendarID}/settings`,
281 export const updateCalendarSettings = (calendarID: string, data: Partial<CalendarSettings>) => ({
282 url: `${CALENDAR_V1}/${calendarID}/settings`,
287 export const getCalendarUserSettings = () => ({
288 url: 'settings/calendar',
292 export const updateCalendarUserSettings = (data: Partial<CalendarUserSettings>) => ({
293 url: 'settings/calendar',
298 export const getAllowedTimeZones = () => ({
299 url: `${CALENDAR_V1}/timezones`,
303 export const getVtimezones = (Timezones: string[]) => ({
304 // params doesn't work correctly so
305 url: `${CALENDAR_V1}/vtimezones?${Timezones.map((tzid) => `Timezones[]=${tzid}`).join('&')}`,
307 // params: { Timezones }
310 export const queryCalendarAlarms = (calendarID: string, params: QueryCalendarAlarms) => ({
311 url: `${CALENDAR_V1}/${calendarID}/alarms`,
316 export const getCalendarAlarm = (calendarID: string, alarmID: string) => ({
317 url: `${CALENDAR_V1}/${calendarID}/alarms/${alarmID}`,
321 export const syncMultipleEvents = (calendarID: string, data: SyncMultipleEventsData) => ({
322 url: `${CALENDAR_V1}/${calendarID}/events/sync`,
327 export const createPublicLink = (calendarID: string, data: CreatePublicLinks) => ({
328 url: `${CALENDAR_V1}/${calendarID}/urls`,
333 export const getPublicLinks = (calendarID: string) => ({
334 url: `${CALENDAR_V1}/${calendarID}/urls`,
338 export const deletePublicLink = ({ calendarID, urlID }: { calendarID: string; urlID: string }) => ({
339 url: `${CALENDAR_V1}/${calendarID}/urls/${urlID}`,
343 export const editPublicLink = ({
350 encryptedPurpose: Nullable<string>;
352 url: `${CALENDAR_V1}/${calendarID}/urls/${urlID}`,
354 data: { EncryptedPurpose: encryptedPurpose },
357 export const getSubscriptionParameters = (calendarID: string) => ({
358 url: `${CALENDAR_V1}/${calendarID}/subscription`,
362 export const validateSubscription = ({
364 mode: Mode = CALENDAR_VALIDATION_MODE.DOWNLOAD_AND_PARSE,
367 mode?: CALENDAR_VALIDATION_MODE;
369 url: `${CALENDAR_V1}/subscription/validate`,
374 export const getDirectoryCalendars = (type: number) => ({
375 url: `${CALENDAR_V1}/directory?Type=${type}`,
379 export const joinHolidaysCalendar = (
383 PassphraseKeyPacket: string;
386 DefaultFullDayNotifications: CalendarNotificationSettings[];
390 url: `${CALENDAR_V1}/${calendarID}/invitations/${addressID}/join`,
395 export const getBusySlots = (emailAddress: string, params: GetBusySlotsParams) => ({
396 url: `${CALENDAR_V1}/${emailAddress}/busy-schedule`,