Class: RiotGamesApi::LOL::Client
- Inherits:
-
Object
- Object
- RiotGamesApi::LOL::Client
- Defined in:
- lib/riot_games_api/lol/client.rb
Instance Method Summary (collapse)
- - (Object) champions
- - (Object) connection
- - (Object) games
-
- (Client) initialize(params = {})
constructor
A new instance of Client.
- - (Object) leagues
- - (Object) static_data
- - (Object) stats
- - (Object) summoner
- - (Object) team
Constructor Details
- (Client) initialize(params = {})
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
- (Object) champions
28 29 30 |
# File 'lib/riot_games_api/lol/client.rb', line 28 def champions RiotGamesApi::LOL::Resource::Champion.new(connection, @region) end |
- (Object) connection
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 |
- (Object) games
32 33 34 |
# File 'lib/riot_games_api/lol/client.rb', line 32 def games RiotGamesApi::LOL::Resource::Game.new(connection, @region) end |
- (Object) leagues
36 37 38 |
# File 'lib/riot_games_api/lol/client.rb', line 36 def leagues RiotGamesApi::LOL::Resource::League.new(connection, @region) end |
- (Object) static_data
40 41 42 |
# File 'lib/riot_games_api/lol/client.rb', line 40 def static_data RiotGamesApi::LOL::Resource::StaticData.new(connection, @region) end |
- (Object) stats
44 45 46 |
# File 'lib/riot_games_api/lol/client.rb', line 44 def stats RiotGamesApi::LOL::Resource::Stats.new(connection, @region) end |
- (Object) summoner
48 49 50 |
# File 'lib/riot_games_api/lol/client.rb', line 48 def summoner RiotGamesApi::LOL::Resource::Summoner.new(connection, @region) end |
- (Object) team
52 53 54 |
# File 'lib/riot_games_api/lol/client.rb', line 52 def team RiotGamesApi::LOL::Resource::Team.new(connection, @region) end |