-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCalendarService.ts
27 lines (22 loc) · 987 Bytes
/
CalendarService.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
// Copyright (c) 2022. Heusala Group Oy <info@heusalagroup.fi>. All rights reserved.
import { CalendarDTO } from "./types/CalendarDTO";
import { HttpService } from "./HttpService";
import { LogService } from "./LogService";
import { CalendarUtils } from "./CalendarUtils";
import { ContentType } from "./request/types/ContentType";
const LOG = LogService.createLogger('CalendarService');
export class CalendarService {
public static async fetchFromUrl (url : string) : Promise<CalendarDTO> {
const responseString : string | undefined = await HttpService.getText(
url,
{
'Accept': ContentType.CALENDAR
}
);
if (!responseString) {
LOG.error(`Response was not calendar data: `, responseString);
throw new TypeError(`CalendarService.fetchFromUrl: Response was not calendar data`);
}
return CalendarUtils.parseCalendarDTOFromInternetCalendar(responseString);
}
}