vaccine_slot_finder 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,19 @@
1
+ # Use this file to easily define all of your cron jobs.
2
+ #
3
+ # It's helpful, but not entirely necessary to understand cron before proceeding.
4
+ # http://en.wikipedia.org/wiki/Cron
5
+
6
+ # Example:
7
+ #
8
+ set :output, "/Users/nakumar/learnings/vaccine_slot_finder/config/cron_log.log"
9
+
10
+ # Need to run it every 40 mins to prevent api throttling.
11
+ every 40.minutes do
12
+ command "vaccine_slot_finder"
13
+ end
14
+ #
15
+ # every 4.days do
16
+ # runner "AnotherModel.prune_old_records"
17
+ # end
18
+
19
+ # Learn more: http://github.com/javan/whenever
@@ -1,16 +1,16 @@
1
1
  require_relative "vaccine_slot_finder/version"
2
2
  require 'httparty'
3
3
  require 'byebug'
4
+ require 'twilio-ruby'
5
+ require 'whenever'
4
6
 
5
7
  module VaccineSlotFinder
6
8
  class VaccineFinder
7
9
  include HTTParty
8
10
  base_uri 'https://cdn-api.co-vin.in/api/v2/appointment/sessions/public'
9
11
 
10
- TEAMS_WEBHOOK = ''
11
-
12
-
13
12
  def initialize(pincode, date)
13
+ @pincode = pincode
14
14
  @query_params = { query: { pincode: pincode, date: date } }
15
15
  end
16
16
 
@@ -18,8 +18,20 @@ module VaccineSlotFinder
18
18
  data = self.class.get("/calendarByPin", @query_params)
19
19
  parsed_data = JSON.parse(data.body)
20
20
  relevant_data = extract_relevant_data(parsed_data)
21
- puts 'No data found! Stay at HOME' if relevant_data.empty?
21
+ puts 'No vaccines available for age group 18-45! Stay at HOME please!' if relevant_data.empty?
22
22
  puts relevant_data
23
+ send_to_teams_channel unless relevant_data.empty?
24
+ # send_sms_to_me unless relevant_data.empty?
25
+ end
26
+
27
+ def send_sms_to_me
28
+ @client = Twilio::REST::Client.new ENV['TWILIO_ACCOUNT_SID'], ENV['TWILIO_AUTH_TOKEN']
29
+ message = @client.messages.create(
30
+ body: "Pincode:- #{@pincode} seems to have have some vaccine slots available for you!",
31
+ to: ENV['TWILIO_TO'], # Replace with your phone number
32
+ from: ENV['TWILIO_FROM']) # Use this Magic Number for creating SMS
33
+
34
+ puts "Message sent with message using ID:- #{message.sid} and for pincode:- #{@pincode}"
23
35
  end
24
36
 
25
37
  def extract_relevant_data(parsed_data)
@@ -53,16 +65,25 @@ module VaccineSlotFinder
53
65
  sessions
54
66
  end
55
67
 
56
- # TODO: Push to Microsoft Teams channel. Needs webhook url, where the data will be posted.
57
- def send_to_teams_channel(relevant_data)
58
- response = self.class.post(TEAMS_WEBHOOK,
59
- :body => {"text" => relevant_data.to_s}.to_json,
68
+ # Push to Microsoft Teams channel. Needs webhook url, where the data will be posted.
69
+ def send_to_teams_channel
70
+ response = self.class.post(ENV['TEAMS_WEBHOOK'],
71
+ :body => {"text" => "Pincode:- #{@pincode} has some vaccine for 18-45 age group. Try booking now!"}.to_json,
60
72
  :headers => { 'Content-Type' => 'application/json' } )
61
73
  puts response.code
62
74
  end
63
75
  end
64
76
  end
65
77
 
78
+
66
79
  # puts ARGV
67
- # slots = VaccineSlotFinder::VaccineFinder.new(ARGV.first, ARGV.last)
68
- # slots.by_pincode
80
+ # yml = YAML.load_file('lib/vaccine_slot_finder/bengaluru_pincodes.yaml')
81
+ # yml = yml['pincodes'].split(" ")
82
+ #
83
+ # # APi response returns availability for next 7 days
84
+ # time = Time.now.strftime('%d/%m/%Y')
85
+ # yml.each do |pin|
86
+ # puts "Searching for pincode:- #{pin}"
87
+ # puts VaccineSlotFinder::VaccineFinder.new(pin, time).by_pincode
88
+ # sleep 4
89
+ # end
@@ -0,0 +1,453 @@
1
+ pincodes:
2
+ 560063
3
+ 560107
4
+ 561101
5
+ 560030
6
+ 560034
7
+ 560007
8
+ 560007
9
+ 561201
10
+ 562110
11
+ 562162
12
+ 560092
13
+ 560024
14
+ 562106
15
+ 560108
16
+ 562110
17
+ 561203
18
+ 560045
19
+ 562110
20
+ 562163
21
+ 561203
22
+ 562123
23
+ 562111
24
+ 561204
25
+ 560050
26
+ 562107
27
+ 560064
28
+ 560047
29
+ 562164
30
+ 560070
31
+ 560073
32
+ 562149
33
+ 562131
34
+ 561204
35
+ 560085
36
+ 560050
37
+ 560043
38
+ 562127
39
+ 562149
40
+ 560001
41
+ 560002
42
+ 560002
43
+ 560009
44
+ 560001
45
+ 560300
46
+ 560025
47
+ 560076
48
+ 560083
49
+ 560091
50
+ 562111
51
+ 560004
52
+ 560079
53
+ 562163
54
+ 560068
55
+ 562122
56
+ 560103
57
+ 562129
58
+ 560046
59
+ 562106
60
+ 562157
61
+ 562129
62
+ 560049
63
+ 562164
64
+ 562107
65
+ 560049
66
+ 562164
67
+ 562111
68
+ 562131
69
+ 560056
70
+ 560082
71
+ 560068
72
+ 560099
73
+ 560063
74
+ 562129
75
+ 562123
76
+ 562106
77
+ 560092
78
+ 560089
79
+ 562127
80
+ 562122
81
+ 560093
82
+ 560035
83
+ 562120
84
+ 560018
85
+ 560099
86
+ 560081
87
+ 560040
88
+ 562135
89
+ 560053
90
+ 560090
91
+ 560073
92
+ 562157
93
+ 560061
94
+ 562130
95
+ 560060
96
+ 562130
97
+ 560001
98
+ 560025
99
+ 560064
100
+ 562162
101
+ 560050
102
+ 560026
103
+ 560067
104
+ 562110
105
+ 562111
106
+ 560036
107
+ 560029
108
+ 562111
109
+ 561203
110
+ 561203
111
+ 561204
112
+ 562132
113
+ 562114
114
+ 560077
115
+ 561204
116
+ 562157
117
+ 560062
118
+ 562131
119
+ 562114
120
+ 560037
121
+ 562110
122
+ 562131
123
+ 562163
124
+ 560071
125
+ 562125
126
+ 560016
127
+ 560001
128
+ 560077
129
+ 560100
130
+ 560066
131
+ 560005
132
+ 560065
133
+ 562131
134
+ 561205
135
+ 560019
136
+ 560021
137
+ 560085
138
+ 562123
139
+ 560083
140
+ 560026
141
+ 562106
142
+ 562127
143
+ 561203
144
+ 560087
145
+ 560024
146
+ 560008
147
+ 560051
148
+ 561205
149
+ 560104
150
+ 561203
151
+ 562125
152
+ 560105
153
+ 562135
154
+ 562114
155
+ 560024
156
+ 561205
157
+ 562110
158
+ 562111
159
+ 560105
160
+ 560091
161
+ 560089
162
+ 560088
163
+ 560001
164
+ 562122
165
+ 562123
166
+ 560048
167
+ 560043
168
+ 561203
169
+ 562114
170
+ 562114
171
+ 560102
172
+ 561101
173
+ 561204
174
+ 560105
175
+ 560076
176
+ 560076
177
+ 562162
178
+ 562131
179
+ 560008
180
+ 562157
181
+ 560099
182
+ 562162
183
+ 562129
184
+ 562106
185
+ 560038
186
+ 560010
187
+ 560094
188
+ 560078
189
+ 560006
190
+ 562114
191
+ 562123
192
+ 560064
193
+ 560014
194
+ 560013
195
+ 560015
196
+ 560043
197
+ 562110
198
+ 560046
199
+ 560041
200
+ 560070
201
+ 560011
202
+ 560075
203
+ 560105
204
+ 562114
205
+ 560078
206
+ 560076
207
+ 560079
208
+ 560009
209
+ 562122
210
+ 562130
211
+ 561204
212
+ 561204
213
+ 560067
214
+ 560067
215
+ 560082
216
+ 560089
217
+ 560083
218
+ 560067
219
+ 560105
220
+ 560043
221
+ 560079
222
+ 562111
223
+ 561203
224
+ 560067
225
+ 561203
226
+ 562110
227
+ 562149
228
+ 562164
229
+ 560085
230
+ 562114
231
+ 562114
232
+ 560060
233
+ 562130
234
+ 560092
235
+ 560091
236
+ 561203
237
+ 560112
238
+ 562164
239
+ 561204
240
+ 562132
241
+ 562114
242
+ 560062
243
+ 561203
244
+ 562163
245
+ 560034
246
+ 560034
247
+ 560095
248
+ 562122
249
+ 560077
250
+ 560016
251
+ 560036
252
+ 561101
253
+ 562125
254
+ 562111
255
+ 560078
256
+ 560074
257
+ 562114
258
+ 560074
259
+ 560037
260
+ 562110
261
+ 560058
262
+ 562127
263
+ 562114
264
+ 562111
265
+ 562162
266
+ 560001
267
+ 560084
268
+ 562123
269
+ 562162
270
+ 562162
271
+ 560011
272
+ 562127
273
+ 560068
274
+ 560023
275
+ 562123
276
+ 560048
277
+ 560086
278
+ 560001
279
+ 562162
280
+ 562123
281
+ 560056
282
+ 561203
283
+ 560003
284
+ 560055
285
+ 562135
286
+ 562123
287
+ 562132
288
+ 562127
289
+ 562111
290
+ 561101
291
+ 560037
292
+ 562127
293
+ 562106
294
+ 560033
295
+ 562162
296
+ 560054
297
+ 560004
298
+ 562107
299
+ 561101
300
+ 560067
301
+ 561205
302
+ 560076
303
+ 562127
304
+ 560076
305
+ 560054
306
+ 562114
307
+ 562119
308
+ 560049
309
+ 560025
310
+ 560099
311
+ 560087
312
+ 562123
313
+ 560067
314
+ 562163
315
+ 560072
316
+ 560073
317
+ 560017
318
+ 562122
319
+ 560096
320
+ 562127
321
+ 562111
322
+ 562135
323
+ 560039
324
+ 560073
325
+ 562123
326
+ 562122
327
+ 562107
328
+ 562125
329
+ 560075
330
+ 562132
331
+ 562132
332
+ 560032
333
+ 560070
334
+ 560003
335
+ 560004
336
+ 560103
337
+ 560057
338
+ 560058
339
+ 560058
340
+ 561204
341
+ 560032
342
+ 560094
343
+ 560083
344
+ 561203
345
+ 560010
346
+ 560010
347
+ 560064
348
+ 560098
349
+ 560001
350
+ 560016
351
+ 560037
352
+ 561204
353
+ 560074
354
+ 562129
355
+ 560025
356
+ 560059
357
+ 562110
358
+ 560080
359
+ 560092
360
+ 560083
361
+ 561204
362
+ 562106
363
+ 560067
364
+ 560027
365
+ 562131
366
+ 562125
367
+ 561204
368
+ 560012
369
+ 560020
370
+ 560027
371
+ 562111
372
+ 560089
373
+ 562162
374
+ 562122
375
+ 562163
376
+ 562106
377
+ 560090
378
+ 560064
379
+ 560068
380
+ 561101
381
+ 560042
382
+ 562130
383
+ 562127
384
+ 560082
385
+ 562130
386
+ 560054
387
+ 561203
388
+ 560021
389
+ 560034
390
+ 560084
391
+ 560050
392
+ 560061
393
+ 561101
394
+ 562129
395
+ 560060
396
+ 560003
397
+ 561204
398
+ 560090
399
+ 562157
400
+ 560082
401
+ 562122
402
+ 560029
403
+ 562130
404
+ 562123
405
+ 560109
406
+ 562106
407
+ 560082
408
+ 560082
409
+ 562131
410
+ 560004
411
+ 560041
412
+ 561203
413
+ 560006
414
+ 561205
415
+ 560070
416
+ 562132
417
+ 560082
418
+ 562127
419
+ 562110
420
+ 560110
421
+ 562114
422
+ 562106
423
+ 560087
424
+ 560001
425
+ 562163
426
+ 562164
427
+ 560045
428
+ 560001
429
+ 562157
430
+ 560097
431
+ 560040
432
+ 560040
433
+ 562135
434
+ 560017
435
+ 560049
436
+ 562110
437
+ 560091
438
+ 560047
439
+ 560003
440
+ 560086
441
+ 560066
442
+ 560027
443
+ 560100
444
+ 562107
445
+ 560078
446
+ 560064
447
+ 560064
448
+ 562111
449
+ 562110
450
+ 562127
451
+ 562123
452
+ 560022
453
+ 560022