Я последовал примеру с страницы HTTParty на github и получил следующее:
class MatchHistory
include HTTParty
base_uri = "api.steampowered.com/IDOTA2Match_570"
def initialize
@options = { query: { key: STEAM_API_KEY } }
end
def latest
self.class.get("/GetMatchHistory/V001", @options)
end
end
get '/' do
history = MatchHistory.new
history.latest.body
end
Я получаю следующую ошибку:
URI::InvalidURIError at /
the scheme http does not accept registry part: :80 (or bad hostname?)
Однако, когда я использую более простое решение, подобное следующему, оно отлично возвращает результаты:
class MatchHistory
def initialize
@base_uri = "http://api.steampowered.com/IDOTA2Match_570"
end
def latest
HTTParty.get(@base_uri + "/GetMatchHistory/V001/?key=" + STEAM_API_KEY)
end
end