Skip to content

Commit

Permalink
Change our keys are checked in responses (#103)
Browse files Browse the repository at this point in the history
  • Loading branch information
siaw23-retired committed Apr 9, 2020
1 parent 87ece19 commit a266b9e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
kovid (0.6.2)
kovid (0.6.3)
ascii_charts (~> 0.9.1)
rainbow (~> 3.0)
terminal-table (~> 1.8)
Expand Down
22 changes: 10 additions & 12 deletions lib/kovid/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,26 +69,24 @@ def asia_aggregate

def by_country(country_name)
response = fetch_country(country_name)
Kovid::Tablelize.country_table(response)

# if response.values.first.include?('not found')
# not_found(country_name)
# else
# Kovid::Tablelize.country_table(response)
# end
if response.key?('message')
not_found(country_name)
else
Kovid::Tablelize.country_table(response)
end
rescue JSON::ParserError
puts SERVER_DOWN
end

def by_country_full(country_name)
response = fetch_country(country_name)
Kovid::Tablelize.full_country_table(response)

# if response.values.first.include?('not found')
# not_found(country_name)
# else
# Kovid::Tablelize.full_country_table(response)
# end
if response.key?('message')
not_found(country_name)
else
Kovid::Tablelize.full_country_table(response)
end
rescue JSON::ParserError
puts SERVER_DOWN
end
Expand Down

0 comments on commit a266b9e

Please sign in to comment.