This repository has been archived on 2021-04-27. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
telenor-test/src/apis/telenor-client/telenor-client.ts
2021-04-27 18:24:01 +02:00

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;
};
}