summoner runes 1.3 and call for multiple summoners runepages
This commit is contained in:
@@ -103,11 +103,11 @@ class SummonerModule < SightstoneBaseModule
|
||||
else
|
||||
summoner
|
||||
end
|
||||
uri = "http://prod.api.pvp.net/api/lol/#{region}/v1.2/summoner/#{id}/runes"
|
||||
uri = "http://prod.api.pvp.net/api/lol/#{region}/v1.3/summoner/#{id}/runes"
|
||||
response = _get_api_response(uri)
|
||||
_parse_response(response) { |resp|
|
||||
data = JSON.parse(resp)
|
||||
book = RuneBook.new(data)
|
||||
book = RuneBook.new(data.values[0])
|
||||
if block_given?
|
||||
yield book
|
||||
else
|
||||
@@ -116,6 +116,37 @@ class SummonerModule < SightstoneBaseModule
|
||||
}
|
||||
end
|
||||
|
||||
# returns the runebook for multiple summoners
|
||||
# @param summoners [Array<(Summoner, Integer)>] list of summoner objects or ids of summoners
|
||||
# @param optional [Hash<Symbol, String>] optional arguments: :region => replaces default region
|
||||
# @return [Hash<Integer, Runebook>] A hash mapping runebooks to the ids of summoners
|
||||
def runebooks(summoners, optional={})
|
||||
return {} if summoners.empty?
|
||||
|
||||
region = optional[:region] || @sightstone.region
|
||||
ids = summoners.collect { |summoner|
|
||||
if summoner.is_a? Summoner
|
||||
summoner.id
|
||||
else
|
||||
summoner
|
||||
end
|
||||
}
|
||||
uri = "http://prod.api.pvp.net/api/lol/#{region}/v1.3/summoner/#{ids.join(',')}/runes"
|
||||
response = _get_api_response(uri)
|
||||
_parse_response(response) { |resp|
|
||||
data = JSON.parse(resp)
|
||||
books = {}
|
||||
data.each do |key, raw_book|
|
||||
books[key] = RuneBook.new(raw_book)
|
||||
end
|
||||
if block_given?
|
||||
yield books
|
||||
else
|
||||
return books
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
# returns the masterybook of a summoner
|
||||
# @param summoner [Summoner, id] summoner object or id of a summoner
|
||||
# @param optional [Hash<Symbol, String>] optional arguments: :region => replaces default region
|
||||
|
||||
Reference in New Issue
Block a user