.
This commit is contained in:
27
src/apis/telenor-client/telenor-client.ts
Normal file
27
src/apis/telenor-client/telenor-client.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
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;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user