Skip to content
20 changes: 10 additions & 10 deletions lib/lol/champion_mastery_request.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Lol
# Bindings for the Champion Mastery API.
#
# See: https://developer.riotgames.com/api-methods/#champion-mastery-v3
# See: https://developer.riotgames.com/api-methods/#champion-mastery-v4
class ChampionMasteryRequest < Request
# @!visibility private
def api_base_path
Expand All @@ -10,30 +10,30 @@ def api_base_path

# Get a player's total champion mastery score, which is the sum of individual champion mastery levels
#
# See: https://developer.riotgames.com/api-methods/#champion-mastery-v3/GET_getDynamicModelScore
# See: https://developer.riotgames.com/api-methods/#champion-mastery-v4/GET_getDynamicModelScore
# @param [Integer] summoner_id Summoner ID associated with the player
# @return [Integer] Player's total champion master score
def total_score summoner_id:
perform_request api_url "scores/by-summoner/#{summoner_id}"
def total_score encrypted_summoner_id:
perform_request api_url "scores/by-summoner/#{encrypted_summoner_id}"
end

# Get all champion mastery entries sorted by number of champion points descending
#
# See: https://developer.riotgames.com/api-methods/#champion-mastery-v3/GET_getAllChampionMasteries
# See: https://developer.riotgames.com/api-methods/#champion-mastery-v4/GET_getAllChampionMasteries
# @param [Integer] summoner_id Summoner ID associated with the player
# @return [Array<Lol::DynamicModel>] Champion Masteries
def all summoner_id:
result = perform_request api_url "champion-masteries/by-summoner/#{summoner_id}"
def all encrypted_summoner_id:
result = perform_request api_url "champion-masteries/by-summoner/#{encrypted_summoner_id}"
result.map { |c| DynamicModel.new c }
end

# Get a champion mastery by player ID and champion ID
#
# See: https://developer.riotgames.com/api-methods/#champion-mastery-v3/GET_getDynamicModel
# See: https://developer.riotgames.com/api-methods/#champion-mastery-v4/GET_getDynamicModel
# @param [Integer] summoner_id Summoner ID associated with the player
# @return [Lol::DynamicModel] Champion Mastery
def find champion_id, summoner_id:
result = perform_request api_url "champion-masteries/by-summoner/#{summoner_id}/by-champion/#{champion_id}"
def find champion_id, encrypted_summoner_id:
result = perform_request api_url "champion-masteries/by-summoner/#{encrypted_summoner_id}/by-champion/#{champion_id}"
DynamicModel.new result
end
end
Expand Down
24 changes: 9 additions & 15 deletions lib/lol/champion_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,18 @@ module Lol
#
# See: https://developer.riotgames.com/api-methods/#champion-v3
class ChampionRequest < Request
# Retrieve all champions
#
# See: https://developer.riotgames.com/api-methods/#champion-v3/GET_getChampions
# @param free_to_play [Boolean] filter param to retrieve only free to play champions
# @return [Array<Lol::DynamicModel>] an array of champions
def all free_to_play: false
result = perform_request api_url("champions", "freeToPlay" => free_to_play)
result["champions"].map { |c| DynamicModel.new c }
# Returns the supported API Version.
# @return [String] v3
def self.api_version
'v3'
end

# Retrieve champion by ID
# Retrieve free champion rotation
#
# See: https://developer.riotgames.com/api-methods/#champion-v3/GET_getChampionsById
# @param id [Integer] id of the champion to get
# @return [Lol::DynamicModel] the found champion
def find id
result = perform_request api_url "champions/#{id}"
DynamicModel.new result
# See: https://developer.riotgames.com/api-methods/#champion-v3/GET_getChampionInfo
# @return [DynamicModel] free champion rotation arrays
def champion_rotations
DynamicModel.new perform_request api_url('champion-rotations')
end
end
end
12 changes: 6 additions & 6 deletions lib/lol/league_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,18 @@ def find_master queue: 'RANKED_SOLO_5x5'
end

# Get leagues in all queues for a given summoner ID
# @param [Integer] summoner_id Summoner ID associated with the player
# @param [Integer] encrypted_summoner_id Encrypted summoner ID associated with the player
# @return [Array<DynamicModel>] List of leagues summoner is participating in
def summoner_leagues summoner_id:
result = perform_request api_url "leagues/by-summoner/#{summoner_id}"
def summoner_leagues encrypted_summoner_id:
result = perform_request api_url "leagues/by-summoner/#{encrypted_summoner_id}"
result.map { |c| DynamicModel.new c }
end

# Get league positions in all queues for a given summoner ID
# @param [Integer] summoner_id Summoner ID associated with the player
# @param [Integer] encrypted_summoner_id Encrypted summoner ID associated with the player
# @return [Array<DynamicModel>] list of league positions
def summoner_positions summoner_id:
result = perform_request api_url "positions/by-summoner/#{summoner_id}"
def summoner_positions encrypted_summoner_id:
result = perform_request api_url "positions/by-summoner/#{encrypted_summoner_id}"
result.map { |c| DynamicModel.new c }
end
end
Expand Down
6 changes: 6 additions & 0 deletions lib/lol/lol_status_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@ module Lol
#
# See: https://developer.riotgames.com/api-methods/#lol-status-v3
class LolStatusRequest < Request
# Returns the supported API Version.
# @return [String] v3
def self.api_version
"v3"
end

# @!visibility private
def api_base_path
"/lol/status/#{self.class.api_version}"
Expand Down
14 changes: 0 additions & 14 deletions lib/lol/masteries_request.rb

This file was deleted.

18 changes: 9 additions & 9 deletions lib/lol/match_request.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Lol
# Bindings for the Match API.
#
# See: https://developer.riotgames.com/api-methods/#match-v3
# See: https://developer.riotgames.com/api-methods/#match-v4
class MatchRequest < Request
# @!visibility private
def api_base_path
Expand Down Expand Up @@ -39,8 +39,8 @@ def find_by_tournament match_id, tournament_code
DynamicModel.new perform_request api_url "matches/#{match_id}/by-tournament-code/#{tournament_code}"
end

# Get matchlist for ranked games played on given account ID and platform ID and filtered using given filter parameters, if any.
# @param [Integer] account_id Account ID
# Get matchlist for ranked games played on given encrypted account ID and platform ID and filtered using given filter parameters, if any.
# @param [Integer] encrypted_account_id Encrypted Account ID
# @param [Hash] options the options to pass to the call
# @option options [Array<Integer>] queue Set of queue IDs for which to filtering matchlist.
# @option options [Integer] beginTime The begin time to use for filtering matchlist specified as epoch milliseconds.
Expand All @@ -50,15 +50,15 @@ def find_by_tournament match_id, tournament_code
# @option options [Array<Integer>] season Set of season IDs for which to filtering matchlist.
# @option options [Array<Integer>] champion Set of champion IDs for which to filtering matchlist.
# @return [DynamicModel] MatchList represantion
def all options={}, account_id:
DynamicModel.new perform_request api_url "matchlists/by-account/#{account_id}", options
def all options={}, encrypted_account_id:
DynamicModel.new perform_request api_url "matchlists/by-account/#{encrypted_account_id}", options
end

# Get matchlist for last 20 matches played on given account ID and platform ID.
# @param [Integer] account_id Account ID
# Get matchlist for last 20 matches played on given encrypted account ID and platform ID.
# @param [Integer] encrypted_account_id Encrypted Account ID
# @return [DynamicModel] MatchList represantion
def recent account_id:
DynamicModel.new perform_request api_url "matchlists/by-account/#{account_id}/recent"
def recent encrypted_account_id:
DynamicModel.new perform_request api_url "matchlists/by-account/#{encrypted_account_id}/recent"
end
end
end
4 changes: 2 additions & 2 deletions lib/lol/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ class Request
attr_reader :rate_limiter

# Returns the supported API Version.
# @return [String] v3
# @return [String] v4
def self.api_version
"v3"
"v4"
end

def self.platforms
Expand Down
14 changes: 0 additions & 14 deletions lib/lol/runes_request.rb

This file was deleted.

12 changes: 6 additions & 6 deletions lib/lol/spectator_request.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
module Lol
# Bindings for the Match API.
# Bindings for the Spectator API.
#
# See: https://developer.riotgames.com/api-methods/#match-v3
# See: https://developer.riotgames.com/api-methods/#spectator-v4
class SpectatorRequest < Request
# @!visibility private
def api_base_path
"/lol/spectator/#{self.class.api_version}"
end

# Get current game information for the given summoner ID.
# @param [Integer] summoner_id Summoner ID
# Get current game information for the given encrypted summoner ID.
# @param [Integer] summoner_id Encrypted Summoner ID
# @return [DynamicModel] Current game representation
def current_game summoner_id:
DynamicModel.new perform_request api_url "active-games/by-summoner/#{summoner_id}"
def current_game encrypted_summoner_id:
DynamicModel.new perform_request api_url "active-games/by-summoner/#{encrypted_summoner_id}"
end

# Get list of featured games.
Expand Down
90 changes: 0 additions & 90 deletions lib/lol/static_request.rb

This file was deleted.

25 changes: 16 additions & 9 deletions lib/lol/summoner_request.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
module Lol
# Bindings for the Summoner API.
#
# See: https://developer.riotgames.com/api-methods/#summoner-v3
# See: https://developer.riotgames.com/api-methods/#summoner-v4
class SummonerRequest < Request
# @!visibility private
def api_base_path
"/lol/summoner/#{self.class.api_version}"
end

# Get a summoner by summoner ID.
# @param [Integer] id Summoner ID
# Get a summoner by encrypted summoner ID.
# @param [String] encrypted id Summoner ID
# @return [DynamicModel] Summoner representation
def find id
DynamicModel.new perform_request api_url "summoners/#{id}"
def find encrypted_id
DynamicModel.new perform_request api_url "summoners/#{encrypted_id}"
end

# Get a summoner by summoner name.
Expand All @@ -23,11 +23,18 @@ def find_by_name name
DynamicModel.new perform_request api_url "summoners/by-name/#{name}"
end

# Get a summoner by account ID.
# @param [Integer] account_id Account ID
# Get a summoner by encrypted account ID.
# @param [String] account_id encrypted Account ID
# @return [DynamicModel] Summoner representation
def find_by_account_id account_id
DynamicModel.new perform_request api_url "summoners/by-account/#{account_id}"
def find_by_account_id encrypted_account_id
DynamicModel.new perform_request api_url "summoners/by-account/#{encrypted_account_id}"
end

# Get a summoner by encrypted PUUID.
# @param [String] account_id encrypted PUUID
# @return [DynamicModel] Summoner representation
def find_by_puuid encrypted_puuid
DynamicModel.new perform_request api_url "summoners/by-puuid/#{encrypted_puuid}"
end
end
end
13 changes: 5 additions & 8 deletions spec/api_version_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,10 @@ def check_api_version(klass, version)

describe "API Versions" do
check_api_version(ChampionRequest, "v3")
check_api_version(ChampionMasteryRequest, "v3")
check_api_version(LeagueRequest, "v3")
check_api_version(StaticRequest, "v3")
check_api_version(ChampionMasteryRequest, "v4")
check_api_version(LeagueRequest, "v4")
check_api_version(LolStatusRequest, "v3")
check_api_version(MatchRequest, "v3")
check_api_version(SummonerRequest, "v3")
check_api_version(RunesRequest, "v3")
check_api_version(MasteriesRequest, "v3")
check_api_version(SpectatorRequest, "v3")
check_api_version(MatchRequest, "v4")
check_api_version(SummonerRequest, "v4")
check_api_version(SpectatorRequest, "v4")
end
8 changes: 0 additions & 8 deletions spec/fixtures/v3/get-champion-266.json

This file was deleted.

Loading