-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcurative.js
39 lines (32 loc) · 982 Bytes
/
curative.js
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
28
29
30
31
32
33
34
35
36
37
38
39
const fetch = require("node-fetch");
require("dotenv").config();
const getCurativeSites = () => {
return {
24181: "DoubleTree Hotel - Danvers",
24182: "Eastfield Mall - Springfield",
25336: "Circuit City - Dartmouth",
};
};
async function getCurativeAvailability() {
const sites = getCurativeSites();
const responses = await Promise.all(
Object.keys(sites).map((site) => {
return fetch(
`https://labtools.curativeinc.com/api/v1/testing_sites/${site}`
);
})
);
const results = await Promise.all(
responses.map((response) => response.json())
);
const availability = {};
results.forEach((result) => {
const availableWindows = result.appointment_windows.filter(
(window) =>
window.public_slots_available > 0 && window.status === "Active"
);
availability[result.id] = availableWindows.length > 0;
});
return availability;
}
module.exports = { getCurativeAvailability, getCurativeSites };