Class: RiotKit::Clients::DataDragon
- Inherits:
-
Object
- Object
- RiotKit::Clients::DataDragon
- Defined in:
- lib/riot_kit/clients/data_dragon.rb
Constant Summary collapse
- BASE_URL =
'https://ddragon.leagueoflegends.com'
Instance Method Summary collapse
- #get_champions(version:, locale: 'pt_BR') ⇒ Object
- #get_items(version:, locale: 'pt_BR') ⇒ Object
- #get_runes(version:, locale: 'pt_BR') ⇒ Object
- #get_summoner_spells(version:, locale: 'pt_BR') ⇒ Object
- #get_versions ⇒ Object
-
#initialize(config: RiotKit.config) ⇒ DataDragon
constructor
A new instance of DataDragon.
Constructor Details
#initialize(config: RiotKit.config) ⇒ DataDragon
Returns a new instance of DataDragon.
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/riot_kit/clients/data_dragon.rb', line 10 def initialize(config: RiotKit.config) @config = config @client = Http::Client.new( base_url: BASE_URL, headers: { 'Content-Type' => 'application/json' }, timeout: config.http_timeout, logger: config.logger, retry_attempts: config.retry_attempts, retry_base_delay: config.retry_base_delay ) end |
Instance Method Details
#get_champions(version:, locale: 'pt_BR') ⇒ Object
34 35 36 37 38 39 40 |
# File 'lib/riot_kit/clients/data_dragon.rb', line 34 def get_champions(version:, locale: 'pt_BR') path = "/cdn/#{version}/data/#{locale}/champion.json" response = @client.get(path) return response if response.success? @client.get("/cdn/#{version}/data/en_US/champion.json") end |
#get_items(version:, locale: 'pt_BR') ⇒ Object
26 27 28 29 30 31 32 |
# File 'lib/riot_kit/clients/data_dragon.rb', line 26 def get_items(version:, locale: 'pt_BR') path = "/cdn/#{version}/data/#{locale}/item.json" response = @client.get(path) return response if response.success? @client.get("/cdn/#{version}/data/en_US/item.json") end |
#get_runes(version:, locale: 'pt_BR') ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/riot_kit/clients/data_dragon.rb', line 50 def get_runes(version:, locale: 'pt_BR') path = "/cdn/#{version}/data/#{locale}/runesReforged.json" response = @client.get(path) return response if response.success? @client.get("/cdn/#{version}/data/en_US/runesReforged.json") end |
#get_summoner_spells(version:, locale: 'pt_BR') ⇒ Object
42 43 44 45 46 47 48 |
# File 'lib/riot_kit/clients/data_dragon.rb', line 42 def get_summoner_spells(version:, locale: 'pt_BR') path = "/cdn/#{version}/data/#{locale}/summoner.json" response = @client.get(path) return response if response.success? @client.get("/cdn/#{version}/data/en_US/summoner.json") end |
#get_versions ⇒ Object
22 23 24 |
# File 'lib/riot_kit/clients/data_dragon.rb', line 22 def get_versions @client.get('/api/versions.json') end |