Sha256: 619b3890fb2f364bbbd685fc69b4b495bd6ada7f4d2712dbda829586f559db74

Contents?: true

Size: 739 Bytes

Versions: 2

Compression:

Stored size: 739 Bytes

Contents

# frozen_string_literal: true

require 'typhoeus'
require 'json'
require_relative 'tablelize'

module Kovid
  class Request
    BASE_URL = 'https://corona.lmao.ninja'

    class << self
      require 'pry'
      def by_country(name)
        path = "/countries/#{name}"
        fetch_url = BASE_URL + path

        response ||= JSON.parse(Typhoeus.get(fetch_url.to_s, cache_ttl: 3600).response_body)
        Kovid::Tablelize.country_table(response)
      end

      def by_country_full(name)
        path = "/countries/#{name}"
        fetch_url = BASE_URL + path

        response ||= JSON.parse(Typhoeus.get(fetch_url.to_s, cache_ttl: 3600).response_body)
        Kovid::Tablelize.full_country_table(response)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
kovid-0.1.2 lib/kovid/request.rb
kovid-0.1.1 lib/kovid/request.rb