-
Notifications
You must be signed in to change notification settings - Fork 0
/
api.rb
26 lines (23 loc) · 793 Bytes
/
api.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
# frozen_string_literal: true
module API
def self.country(country_name)
country_name = "drc" if country_name == "rdc"
response = HTTP.headers(
"X-RapidAPI-Host": ENV['API_HOST'],
"X-RapidAPI-Key": ENV['API_KEY']
)
.get("https://covid-193.p.rapidapi.com/statistics?country=#{country_name}")
JSON.parse(response.to_s, symbolize_names: true)[:response]
end
def self.summary
summary_response = ["drc", "rwanda", "usa"].map do |country|
response = HTTP.headers(
"X-RapidAPI-Host": ENV['API_HOST'],
"X-RapidAPI-Key": ENV['API_KEY']
)
.get("https://covid-193.p.rapidapi.com/statistics?country=#{country}")
JSON.parse(response.to_s, symbolize_names: true)[:response].first
end
summary_response
end
end