Class: RiotLolApi::Client
- Inherits:
-
Object
- Object
- RiotLolApi::Client
- Includes:
- HelperClass, Request::Champion, Request::ChampionMastery, Request::Game, Request::Item, Request::Mastery, Request::Rune, Request::Spell, Request::Summoner
- Defined in:
- lib/riot_lol_api/clients.rb
Constant Summary collapse
- BASE_URL_API =
'api.pvp.net/api/lol/'
Class Attribute Summary collapse
-
.realm ⇒ Object
Returns the value of attribute realm.
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#platform ⇒ Object
Returns the value of attribute platform.
-
#region ⇒ Object
Returns the value of attribute region.
Instance Method Summary collapse
- #get(url:, domaine:, data: {}, overide_base_uri: BASE_URL_API) ⇒ Object
-
#initialize(options = {}) {|_self| ... } ⇒ Client
constructor
A new instance of Client.
- #realm ⇒ Object
- #versions ⇒ Object
Methods included from Request::ChampionMastery
#championmastery_by_summoner_by_champion
Methods included from Request::Game
#current_game, #featured_games, #match
Methods included from Request::Spell
#get_all_summoner_spells, #get_summoner_spell_by_id
Methods included from Request::Rune
#get_all_runes, #get_rune_by_id
Methods included from Request::Mastery
#get_all_masteries, #get_mastery_by_id
Methods included from Request::Item
#get_all_items, #get_item_by_id
Methods included from Request::Champion
#get_all_champions, #get_champion_by_id
Methods included from Request::Summoner
#get_summoner_by_id, #get_summoner_by_name, #get_summoners_by_id
Methods included from HelperClass
Constructor Details
#initialize(options = {}) {|_self| ... } ⇒ Client
Returns a new instance of Client.
28 29 30 31 32 33 34 35 |
# File 'lib/riot_lol_api/clients.rb', line 28 def initialize( = {}) .each do |key, value| instance_variable_set("@#{key}", value) end yield(self) if block_given? @platform = platform unless region.nil? realm unless region.nil? end |
Class Attribute Details
.realm ⇒ Object
Returns the value of attribute realm.
38 39 40 |
# File 'lib/riot_lol_api/clients.rb', line 38 def realm @realm end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
26 27 28 |
# File 'lib/riot_lol_api/clients.rb', line 26 def api_key @api_key end |
#platform ⇒ Object
Returns the value of attribute platform.
26 27 28 |
# File 'lib/riot_lol_api/clients.rb', line 26 def platform @platform end |
#region ⇒ Object
Returns the value of attribute region.
26 27 28 |
# File 'lib/riot_lol_api/clients.rb', line 26 def region @region end |
Instance Method Details
#get(url:, domaine:, data: {}, overide_base_uri: BASE_URL_API) ⇒ Object
54 55 56 57 58 59 60 61 |
# File 'lib/riot_lol_api/clients.rb', line 54 def get(url:, domaine:, data: {}, overide_base_uri: BASE_URL_API) return fail('need api key') if @api_key.nil? data.merge!(api_key: @api_key) domaine_url = "#{domaine}.#{overide_base_uri}" response = HTTParty.get("https://#{domaine_url}#{url}", query: data) return JSON.parse(response.body) if response.code == 200 nil end |
#realm ⇒ Object
41 42 43 44 |
# File 'lib/riot_lol_api/clients.rb', line 41 def realm response = get(url: "static-data/#{region}/v1.2/realm", domaine: 'global') self.class.realm = response unless response.nil? end |
#versions ⇒ Object
50 51 52 |
# File 'lib/riot_lol_api/clients.rb', line 50 def versions get(url: "static-data/#{@region}/v1.2/versions", domaine: 'global') end |