-
Notifications
You must be signed in to change notification settings - Fork 7
/
acuity.rb
156 lines (142 loc) · 5.07 KB
/
acuity.rb
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
require 'rest-client'
require 'nokogiri'
require_relative '../sentry_helper'
require_relative './base_clinic'
module Acuity
SITES = {
'Southbridge Community Center (non-local residents) in Southbridge, MA' => {
sign_up_url: 'https://www.harringtonhospital.org/coronavirus/covid-19-vaccination/',
api_url: 'https://app.acuityscheduling.com/schedule.php?action=showCalendar&fulldate=1&owner=22192301&template=weekly',
api_params: {
type: 20819310,
calendar: 5202038,
skip: true,
'options[qty]' => 1,
'options[numDays]' => 27,
ignoreAppointment: '',
appointmentType: '',
calendarID: 5202038,
},
},
'Southbridge Community Center (local residents only) in Southbridge, MA' => {
sign_up_url: 'https://www.harringtonhospital.org/coronavirus/covid-19-vaccination/',
api_url: 'https://app.acuityscheduling.com/schedule.php?action=showCalendar&fulldate=1&owner=22192301&template=weekly',
api_params: {
type: 20926295,
calendar: 5202050,
skip: true,
'options[qty]' => 1,
'options[numDays]' => 27,
ignoreAppointment: '',
appointmentType: '',
calendarID: 5202050,
},
},
'700 Essex St. (GLFHC patients only) in Lawrence, MA' => {
sign_up_url: 'https://glfhc.org/covid-19-vaccine-signup-form/',
api_url: 'https://glfhccovid19iz.as.me/schedule.php?action=showCalendar&fulldate=1&owner=21956779&template=weekly&location=700+Essex+Street%2C+Lawrence+MA',
api_params: {
type: 20223228,
calendar: 5075244,
skip: true,
'options[qty]' => 1,
'options[numDays]' => 27,
ignoreAppointment: '',
appointmentType: '',
calendarID: '',
},
},
'147 Pelham St. in Methuen, MA' => {
sign_up_url: 'https://glfhc.org/covid-19-vaccine-signup-form/',
api_url: 'https://glfhccovid19iz.as.me/schedule.php?action=showCalendar&fulldate=1&owner=21956779&template=weekly',
api_params: {
type: 20223228,
calendar: 5114836,
skip: true,
'options[qty]' => 1,
'options[numDays]' => 27,
ignoreAppointment: '',
appointmentType: '',
calendarID: 5114836,
},
},
'Central Plaza - 2 Water St. in Haverhill, MA' => {
sign_up_url: 'https://glfhc.org/covid-19-vaccine-signup-form/',
api_url: 'https://glfhccovid19iz.as.me/schedule.php?action=showCalendar&fulldate=1&owner=21956779&template=weekly&location=Central+Plaza%2C+2+Water+Street%2C+Haverhill+MA',
api_params: {
type: 20223228,
calendar: 5236989,
skip: true,
'options[qty]' => 1,
'options[numDays]' => 27,
ignoreAppointment: '',
appointmentType: '',
calendarID: '',
},
},
'Northern Essex Community College 45 Franklin St. (Lawrence residents only) in Lawrence, MA' => {
sign_up_url: 'https://glfhc.org/covid-19-vaccine-signup-form/',
api_url: 'https://glfhccovid19iz.as.me/schedule.php?action=showCalendar&fulldate=1&owner=21956779&template=weekly&location=45+Franklin+Street%2C+Lawrence+MA',
api_params: {
type: 20223228,
calendar: 5341082,
skip: true,
'options[qty]' => 1,
'options[numDays]' => 27,
ignoreAppointment: '',
appointmentType: '',
calendarID: '',
},
},
# NOTE: Trinity is showing a message that all appointment types are private
#'Trinity EMS in Haverhill, MA' => {
#sign_up_url: 'https://trinityems.com/what-we-do/covid-19-vaccine-clinics/',
#api_url: 'https://app.acuityscheduling.com/schedule.php?action=showCalendar&fulldate=1&owner=21713854&template=weekly',
#api_params: {
#type: 19620839,
#calendar: 5109380,
#skip: true,
#'options[qty]' => 1,
#'options[numDays]' => 5,
#ignoreAppointment: '',
#appointmentType: '',
#calendarID: 5109380,
#},
#}
}.freeze
def self.all_clinics(storage, logger)
SITES.flat_map do |site_name, config|
sleep(1)
SentryHelper.catch_errors(logger, 'Acuity') do
logger.info "[Acuity] Checking site #{site_name}"
fetch_appointments(config).map do |date, appointments|
logger.info "[Acuity] Site #{site_name} found #{appointments} appointments on #{date}"
Clinic.new(storage, site_name, date, appointments, config[:sign_up_url])
end
end
end
end
def self.fetch_appointments(config)
res = RestClient.post(config[:api_url], config[:api_params])
html = Nokogiri::HTML(res.body)
html.search('input.time-selection').each_with_object(Hash.new(0)) do |appt, h|
h[appt['data-readable-date']] += 1
end
end
class Clinic < BaseClinic
attr_reader :name, :date, :appointments, :link
def initialize(storage, name, date, appointments, link)
super(storage)
@name = name
@date = date
@appointments = appointments
@link = link
end
def module_name
'ACUITY'
end
def title
"#{name} on #{date}"
end
end
end