28 lines
703 B
TypeScript
28 lines
703 B
TypeScript
import { IAppConfig } from "../../app-config";
|
|
import { ITelenorClient } from "./types";
|
|
|
|
export class TelenorClient implements ITelenorClient {
|
|
constructor(private appConfig: IAppConfig) {}
|
|
|
|
getAppointments = async () => {
|
|
const response = await fetch(
|
|
`${this.appConfig.telenorApiUrl}/api/Appointments`,
|
|
{
|
|
headers: {
|
|
accept: "application/json",
|
|
key: this.appConfig.telenorApiKey,
|
|
},
|
|
}
|
|
);
|
|
const json = await response.json();
|
|
const mapped = json.map((apt: any) => ({
|
|
...apt,
|
|
endTime: new Date(apt.endTime),
|
|
startTime: new Date(apt.startTime),
|
|
date: new Date(apt.date),
|
|
}));
|
|
|
|
return mapped;
|
|
};
|
|
}
|