Sha256: c037e3dbd5361bd41cb0dfd7f836ece41603c19f011e916bb3d5dfd1d0d05733
Contents?: true
Size: 1.74 KB
Versions: 1
Compression:
Stored size: 1.74 KB
Contents
module Lolxin class Summoner BASE_ENDPOINT = "https://%s.api.pvp.net/api/lol/%s/%s/summoner" attr_accessor :conn def initialize(options = {}) region = options[:region] api_key = options[:api_key] version = options[:version] endpoint = BASE_ENDPOINT % [region, region, version] @conn = Faraday.new(endpoint, options[:conn_options]) do |faraday| faraday.request(:url_encoded) faraday.response(:logger) faraday.adapter(Faraday.default_adapter) faraday.params[:api_key] = api_key end end def by_name(params = {}, &block) summ_name = params.delete(:summonerNames) # Riot limits list to 40 summ_name = summ_name[0...40].join(',') if summ_name.is_a? Array conn.get("by-name/#{summ_name}", params, &block) end def by_id(params = {}, &block) summ_id = params.delete(:summonerIds) # Riot limits list to 40 summ_id = summ_id[0...40].join(',') if summ_id.is_a? Array conn.get("#{summ_id}", params, &block) end def masteries(params = {}, &block) summ_id = params.delete(:summonerIds) # Riot limits list to 40 summ_id = summ_id[0...40].join(',') if summ_id.is_a? Array conn.get("#{summ_id}/masteries", params, &block) end def name(params = {}, &block) summ_id = params.delete(:summonerIds) # Riot limits list to 40 summ_id = summ_id[0...40].join(',') if summ_id.is_a? Array conn.get("#{summ_id}/name", params, &block) end def runes(params = {}, &block) summ_id = params.delete(:summonerIds) # Riot limits list to 40 summ_id = summ_id[0...40].join(',') if summ_id.is_a? Array conn.get("#{summ_id}/runes", params, &block) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
lolxin-0.12.1 | lib/lolxin/summoner.rb |