-
Notifications
You must be signed in to change notification settings - Fork 0
/
mittvaccin.ps1
32 lines (25 loc) · 1.1 KB
/
mittvaccin.ps1
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
### Quick and dirty script to read the mittvaccin.se open API's
$sites=@('https://booking-api.mittvaccin.se/clinique/1352/appointments/11916/slots/','https://booking-api.mittvaccin.se/clinique/1351/appointments/11924/slots/',
'https://booking-api.mittvaccin.se/clinique/1350/appointments/11941/slots/')
$collection = @()
$today=Get-Date
$start = $today.ToString("yyMMdd")
$end = $today.AddDays(10).ToString("yyMMdd")
foreach ($site in $sites){
Write-Host "Processing: $site$start-$end"
$data=(Invoke-restmethod -Uri "$site$start-$end")
if ($data.slots | Where-Object available -like "True"){
foreach ($dates in $($data).Where({ $_.slots -like "*True*" })) {
if ($site -like "*11941*") {$newsite ="Hallsberg"}
if ($site -like "*11916*") {$newsite ="Conventum"}
if ($site -like "*11924*") {$newsite ="Boglunds"}
#echo "site $site $newsite $dates.date"
$collection += [pscustomobject] @{
site = $newsite
date = $dates.date
slots = $data | Select -ExpandProperty slots| where {$_.Available -like "True"}
}
}
}
$collection |ft
}