1 import { getEventByUID } from '../api/calendars';
2 import type { Api } from '../interfaces';
3 import type { CalendarEvent, GetEventByUIDArguments } from '../interfaces/calendar';
4 import type { CALENDAR_TYPE } from './constants';
6 const MAX_ITERATIONS = 100;
8 export const getPaginatedEventsByUID = async ({
17 recurrenceID?: number;
19 calendarType?: CALENDAR_TYPE;
23 let result: CalendarEvent[] = [];
25 while (pageNumber < max) {
26 const params: GetEventByUIDArguments = {
28 RecurrenceID: recurrenceID,
33 if (calendarType !== undefined) {
34 params.CalendarType = calendarType;
36 const page = await api<{ Events: CalendarEvent[] }>(getEventByUID(params));
37 result = result.concat(page.Events);
38 if (page.Events.length !== pageSize) {
47 export const reformatApiErrorMessage = (message: string) => {
48 if (message.toLowerCase().endsWith('. please try again')) {
49 return message.slice(0, -18);