Skip to content

Instantly share code, notes, and snippets.

@onedebos
Last active March 26, 2020 15:57
Show Gist options
  • Save onedebos/604ce086ad9f7ccc960fab0b5112bf1f to your computer and use it in GitHub Desktop.
Save onedebos/604ce086ad9f7ccc960fab0b5112bf1f to your computer and use it in GitHub Desktop.
module Types
class SummaryType < Types::BaseObject
field :total_cases, Integer, null: false
field :total_deaths, Integer, null: false
field :total_recovered, Integer, null: false
def request
base_url = "https://corona.lmao.ninja/all"
request = HTTParty.get(base_url).body
response = JSON.parse(request)
end
def total_cases
request["cases"]
end
def total_deaths
request["deaths"]
end
def total_recovered
request["recovered"]
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment