class LolApi::Client
Attributes
config[R]
Public Class Methods
new(options = {})
click to toggle source
# File lib/lol_api/client.rb, line 16 def initialize(options = {}) @config = Configuration.new(options) end
Public Instance Methods
champion_by_id(id, options = {})
click to toggle source
# File lib/lol_api/client.rb, line 34 def champion_by_id(id, options = {}) response = run_request('global','champion', options, 'static-data', 'euw', id.to_s, 'v1.2') Champion.new(response) if response["id"] end
champions(options ={})
click to toggle source
# File lib/lol_api/client.rb, line 25 def champions(options ={}) response = run_request('global', 'champion', options, 'static-data', 'euw', '', 'v1.2') if response && (champions = response["data"]) champions.map do | champ | Champion.new(champ[1]) end end end
configure() { |config| ... }
click to toggle source
# File lib/lol_api/client.rb, line 19 def configure yield config end
connection()
click to toggle source
# File lib/lol_api/client.rb, line 22 def connection @connection ||= Connection.new end
history_by_id(id)
click to toggle source
# File lib/lol_api/client.rb, line 58 def history_by_id(id) response = run_request('euw','matchhistory', {}, '', "euw", id.to_s, "v2.2") if matches = response['matches'] matches.map do |match| HistoryMatch.new(match) end end end
item_by_id(id, options = {})
click to toggle source
# File lib/lol_api/client.rb, line 48 def item_by_id(id, options = {}) response = run_request('global','item', options, 'static-data', 'euw', id.to_s, 'v1.2') Item.new(response) if response["id"] end
items(options = {})
click to toggle source
# File lib/lol_api/client.rb, line 38 def items(options = {}) response = run_request('global','item', options, 'static-data', 'euw', '', 'v1.2') if response && (items = response['data']) items.map do |item| Item.new(item[1]) end end end
masteries(options = {})
click to toggle source
# File lib/lol_api/client.rb, line 66 def masteries(options = {}) response = run_request('global', 'mastery', options, 'static-data', 'euw', '', 'v1.2') if response && masteries = response['data'] masteries.map do |mastery| Mastery.new(mastery) end end end
mastery_by_id(id=0, options = {})
click to toggle source
# File lib/lol_api/client.rb, line 75 def mastery_by_id(id=0, options = {}) response = run_request('global', 'mastery', options, 'static-data', 'euw', id, 'v1.2') Mastery.new(response) if response["id"] end
match_details(id, timeline = true)
click to toggle source
# File lib/lol_api/client.rb, line 53 def match_details(id, timeline = true) response = run_request('euw', 'match', {:includeTimeline => timeline}, '', 'euw', id.to_s, 'v2.2') Match.new(response) if response['region'] end
run_request(prefix, method, options = {}, interface='static-data' , region = 'euw', id = '', version = 'v1.2')
click to toggle source
# File lib/lol_api/client.rb, line 100 def run_request(prefix, method, options = {}, interface='static-data' , region = 'euw', id = '', version = 'v1.2') url = "https://#{prefix}.api.pvp.net/api/lol#{("/" << interface) unless interface == ''}/#{region}/#{version}/#{method}/#{id}" connection.request(:get, url, options.merge(api_key: config.api_key)) end
summoner_by_id(id)
click to toggle source
# File lib/lol_api/client.rb, line 85 def summoner_by_id(id) response = run_request('euw', 'summoner', {}, '', 'euw', id, 'v1.4') Summoner.new(response[id.to_s]) if response[id.to_s] end
summoner_by_name(name)
click to toggle source
# File lib/lol_api/client.rb, line 80 def summoner_by_name(name) response = run_request('euw', 'summoner/by-name', {}, '', 'euw', name, 'v1.4') Summoner.new(response[name]) if response[name] end
summoner_masteries(id)
click to toggle source
# File lib/lol_api/client.rb, line 90 def summoner_masteries(id) response = run_request('euw', 'summoner', {}, '', 'euw', id.to_s << "/masteries", 'v1.4') SummonerMasteries.new(response[id.to_s]) if response[id.to_s] end
summoner_runes(id)
click to toggle source
# File lib/lol_api/client.rb, line 95 def summoner_runes(id) response = run_request('euw', 'summoner', {}, '', 'euw', id.to_s << "/runes", 'v1.4') SummonerRunes.new(response[id.to_s]) if response[id.to_s] end