Class: RiotGamesApi::LOL::Client
- Inherits:
-
Object
- Object
- RiotGamesApi::LOL::Client
- Defined in:
- lib/riot_games_api/lol/client.rb
Instance Method Summary collapse
- #champions ⇒ Object
- #connection ⇒ Object
- #games ⇒ Object
-
#initialize(params = {}) ⇒ Client
constructor
A new instance of Client.
- #leagues ⇒ Object
- #static_data ⇒ Object
- #stats ⇒ Object
- #summoner ⇒ Object
- #team ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ Client
Returns a new instance of Client.
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/riot_games_api/lol/client.rb', line 4 def initialize(params = {}) @api_key = params[:api_key] || ENV['RIOT_GAMES_API_KEY'] @region = params[:region] || 'na' @base_url = "https://#{@region}.api.pvp.net/" @adapter = params[:adapter] || Faraday.default_adapter @logger = params[:debug] ? :logger : :raise_error @locale = params[:locale] || 'en_US' fail ArgumentError, 'You should need "Riot Games API Key" at leaet.' unless @api_key end |
Instance Method Details
#champions ⇒ Object
28 29 30 |
# File 'lib/riot_games_api/lol/client.rb', line 28 def champions RiotGamesApi::LOL::Resource::Champion.new(connection, @region) end |
#connection ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/riot_games_api/lol/client.rb', line 15 def connection Faraday.new(url: @base_url) do |faraday| faraday.request :url_encoded faraday.response :rashify faraday.response :json faraday.response @logger faraday.adapter @adapter faraday.params[:api_key] = @api_key faraday.params[:locale] = @locale faraday.headers['User-Agent'] = "RiotGamesApi gem v#{RiotGamesApi::VERSION}" end end |
#games ⇒ Object
32 33 34 |
# File 'lib/riot_games_api/lol/client.rb', line 32 def games RiotGamesApi::LOL::Resource::Game.new(connection, @region) end |
#leagues ⇒ Object
36 37 38 |
# File 'lib/riot_games_api/lol/client.rb', line 36 def leagues RiotGamesApi::LOL::Resource::League.new(connection, @region) end |
#static_data ⇒ Object
40 41 42 |
# File 'lib/riot_games_api/lol/client.rb', line 40 def static_data RiotGamesApi::LOL::Resource::StaticData.new(connection, @region) end |
#stats ⇒ Object
44 45 46 |
# File 'lib/riot_games_api/lol/client.rb', line 44 def stats RiotGamesApi::LOL::Resource::Stats.new(connection, @region) end |
#summoner ⇒ Object
48 49 50 |
# File 'lib/riot_games_api/lol/client.rb', line 48 def summoner RiotGamesApi::LOL::Resource::Summoner.new(connection, @region) end |
#team ⇒ Object
52 53 54 |
# File 'lib/riot_games_api/lol/client.rb', line 52 def team RiotGamesApi::LOL::Resource::Team.new(connection, @region) end |