ruby-lol 0.12.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.editorconfig +16 -0
- data/.gitignore +2 -0
- data/.rspec +1 -0
- data/.rubocop.yml +1157 -0
- data/.travis.yml +1 -1
- data/lib/lol/champion_mastery_request.rb +29 -57
- data/lib/lol/champion_request.rb +19 -23
- data/lib/lol/client.rb +16 -21
- data/lib/lol/dynamic_model.rb +14 -5
- data/lib/lol/featured_game_list.rb +15 -0
- data/lib/lol/league_request.rb +28 -49
- data/lib/lol/lol_status_request.rb +9 -26
- data/lib/lol/masteries_request.rb +14 -0
- data/lib/lol/match_request.rb +51 -9
- data/lib/lol/request.rb +55 -21
- data/lib/lol/runes_request.rb +14 -0
- data/lib/lol/spectator_request.rb +24 -0
- data/lib/lol/static_request.rb +34 -23
- data/lib/lol/summoner_request.rb +22 -51
- data/lib/lol/tournament_request.rb +95 -0
- data/lib/lol/version.rb +1 -1
- data/ruby-lol.gemspec +1 -1
- data/spec/api_version_spec.rb +10 -9
- data/spec/fixtures/{v1.2 → v3}/get-champion-266.json +0 -0
- data/spec/fixtures/{v1.2/get-champion.json → v3/get-champion-all.json} +0 -0
- data/spec/fixtures/{v1.0/get-champion-mastery-champions.json → v3/get-champion-masteries.json} +0 -0
- data/spec/fixtures/{v1.0/get-champion-mastery-champion.json → v3/get-champion-mastery.json} +0 -0
- data/spec/fixtures/v3/get-current-game.json +1 -0
- data/spec/fixtures/v3/get-featured-games.json +1 -0
- data/spec/fixtures/v3/get-ids-by-tc.json +1 -0
- data/spec/fixtures/v3/get-league-challenger.json +1 -0
- data/spec/fixtures/v3/get-league-master.json +1 -0
- data/spec/fixtures/v3/get-league-positions.json +1 -0
- data/spec/fixtures/v3/get-league-summoner.json +1 -0
- data/spec/fixtures/v3/get-lol-status-shard.json +1 -0
- data/spec/fixtures/v3/get-masteries.json +1 -0
- data/spec/fixtures/v3/get-match-with-tc.json +1 -0
- data/spec/fixtures/v3/get-match.json +1 -0
- data/spec/fixtures/v3/get-matches-recent.json +1 -0
- data/spec/fixtures/v3/get-matches.json +1 -0
- data/spec/fixtures/v3/get-runes.json +1 -0
- data/spec/fixtures/v3/get-static-champions-by-id.json +1 -0
- data/spec/fixtures/v3/get-static-champions.json +1 -0
- data/spec/fixtures/v3/get-static-items-by-id.json +1 -0
- data/spec/fixtures/v3/get-static-items.json +1 -0
- data/spec/fixtures/v3/get-static-maps.json +1 -0
- data/spec/fixtures/v3/get-static-masteries-by-id.json +1 -0
- data/spec/fixtures/v3/get-static-masteries.json +1 -0
- data/spec/fixtures/v3/get-static-realms.json +1 -0
- data/spec/fixtures/v3/get-static-runes-by-id.json +1 -0
- data/spec/fixtures/v3/get-static-runes.json +1 -0
- data/spec/fixtures/v3/get-static-summoner-spells-by-id.json +1 -0
- data/spec/fixtures/v3/get-static-summoner-spells.json +1 -0
- data/spec/fixtures/v3/get-static-versions.json +1 -0
- data/spec/fixtures/v3/get-summoner-by-name.json +1 -0
- data/spec/fixtures/v3/get-summoner.json +1 -0
- data/spec/fixtures/v3/get-timeline.json +1 -0
- data/spec/fixtures/v3/get-tournament-code.json +1 -0
- data/spec/lol/champion_mastery_request_spec.rb +33 -133
- data/spec/lol/champion_request_spec.rb +17 -30
- data/spec/lol/client_spec.rb +12 -56
- data/spec/lol/league_request_spec.rb +29 -72
- data/spec/lol/lol_status_request_spec.rb +6 -34
- data/spec/lol/masteries_request_spec.rb +15 -0
- data/spec/lol/match_request_spec.rb +45 -10
- data/spec/lol/request_spec.rb +5 -5
- data/spec/lol/runes_request_spec.rb +15 -0
- data/spec/lol/spectator_request_spec.rb +23 -0
- data/spec/lol/static_request_spec.rb +44 -48
- data/spec/lol/summoner_request_spec.rb +20 -71
- data/spec/lol/tournament_request_spec.rb +36 -0
- metadata +92 -175
- data/lib/lol/champion.rb +0 -37
- data/lib/lol/champion_mastery.rb +0 -50
- data/lib/lol/champion_statistics_summary.rb +0 -25
- data/lib/lol/current_game_request.rb +0 -16
- data/lib/lol/featured_games_request.rb +0 -15
- data/lib/lol/game.rb +0 -85
- data/lib/lol/game_request.rb +0 -19
- data/lib/lol/league.rb +0 -32
- data/lib/lol/league_entry.rb +0 -74
- data/lib/lol/mastery.rb +0 -16
- data/lib/lol/mastery_page.rb +0 -28
- data/lib/lol/match_list_request.rb +0 -15
- data/lib/lol/match_summary.rb +0 -59
- data/lib/lol/mini_series.rb +0 -29
- data/lib/lol/model.rb +0 -28
- data/lib/lol/player.rb +0 -21
- data/lib/lol/player_statistic.rb +0 -46
- data/lib/lol/ranked_statistics_summary.rb +0 -35
- data/lib/lol/roster.rb +0 -23
- data/lib/lol/rune_page.rb +0 -28
- data/lib/lol/rune_slot.rb +0 -29
- data/lib/lol/stats_request.rb +0 -35
- data/lib/lol/summoner.rb +0 -36
- data/lib/lol/team.rb +0 -110
- data/lib/lol/team_member.rb +0 -33
- data/lib/lol/team_request.rb +0 -32
- data/lib/lol/team_statistic.rb +0 -53
- data/lib/lol/tournament_code.rb +0 -58
- data/lib/lol/tournament_provider_request.rb +0 -111
- data/spec/fixtures/v1.0/get-champion-mastery-top-champions-10.json +0 -121
- data/spec/fixtures/v1.0/get-champion-mastery-top-champions.json +0 -38
- data/spec/fixtures/v1.0/get-current-game.json +0 -1065
- data/spec/fixtures/v1.0/get-featured-games.json +0 -730
- data/spec/fixtures/v1.0/get-lol-status-shard-by-region.json +0 -39
- data/spec/fixtures/v1.0/get-lol-status-shards.json +0 -78
- data/spec/fixtures/v1.2/get-champion-by-id.json +0 -6
- data/spec/fixtures/v1.2/get-item-by-id.json +0 -6
- data/spec/fixtures/v1.2/get-item.json +0 -1563
- data/spec/fixtures/v1.2/get-mastery-by-id.json +0 -9
- data/spec/fixtures/v1.2/get-mastery.json +0 -389
- data/spec/fixtures/v1.2/get-realm.json +0 -1
- data/spec/fixtures/v1.2/get-rune-by-id.json +0 -26
- data/spec/fixtures/v1.2/get-rune.json +0 -2966
- data/spec/fixtures/v1.2/get-static-champion.json +0 -714
- data/spec/fixtures/v1.2/get-summoner-spell-by-id.json +0 -39
- data/spec/fixtures/v1.2/get-summoner-spell.json +0 -97
- data/spec/fixtures/v1.2/get-versions.json +0 -1
- data/spec/fixtures/v1.3/get-game.json +0 -1040
- data/spec/fixtures/v1.3/get-ranked_stats.json +0 -1
- data/spec/fixtures/v1.3/get-stats.json +0 -1
- data/spec/fixtures/v1.4/get-summoner-by-name.json +0 -1
- data/spec/fixtures/v1.4/get-summoner-masteries.json +0 -898
- data/spec/fixtures/v1.4/get-summoner-name.json +0 -1
- data/spec/fixtures/v1.4/get-summoner-runes.json +0 -2547
- data/spec/fixtures/v1.4/get-summoner.json +0 -1
- data/spec/fixtures/v2.2/get-match.json +0 -1
- data/spec/fixtures/v2.2/get-match_list.json +0 -1
- data/spec/fixtures/v2.4/get-by-summoner.json +0 -1
- data/spec/fixtures/v2.4/get-team.json +0 -1
- data/spec/fixtures/v2.5/get-league-by-team.json +0 -1
- data/spec/fixtures/v2.5/get-league-challenger.json +0 -1
- data/spec/fixtures/v2.5/get-league-entry-by-team.json +0 -1
- data/spec/fixtures/v2.5/get-league-entry.json +0 -1
- data/spec/fixtures/v2.5/get-league-master.json +0 -1
- data/spec/fixtures/v2.5/get-league.json +0 -1
- data/spec/lol/champion_mastery_spec.rb +0 -20
- data/spec/lol/champion_spec.rb +0 -19
- data/spec/lol/champion_statistics_summary_spec.rb +0 -38
- data/spec/lol/current_game_request_spec.rb +0 -47
- data/spec/lol/featured_games_request_spec.rb +0 -39
- data/spec/lol/game_request_spec.rb +0 -32
- data/spec/lol/game_spec.rb +0 -51
- data/spec/lol/league_entry_spec.rb +0 -51
- data/spec/lol/league_spec.rb +0 -31
- data/spec/lol/mastery_page_spec.rb +0 -29
- data/spec/lol/mastery_spec.rb +0 -17
- data/spec/lol/match_list_request_spec.rb +0 -39
- data/spec/lol/match_summary_spec.rb +0 -25
- data/spec/lol/mini_series_spec.rb +0 -25
- data/spec/lol/model_spec.rb +0 -13
- data/spec/lol/player_spec.rb +0 -19
- data/spec/lol/player_statistic_spec.rb +0 -44
- data/spec/lol/ranked_statistics_summary_spec.rb +0 -32
- data/spec/lol/roster_spec.rb +0 -24
- data/spec/lol/rune_page_spec.rb +0 -28
- data/spec/lol/rune_slot_spec.rb +0 -16
- data/spec/lol/stats_request_spec.rb +0 -93
- data/spec/lol/summoner_spec.rb +0 -20
- data/spec/lol/team_member_spec.rb +0 -27
- data/spec/lol/team_request_spec.rb +0 -47
- data/spec/lol/team_spec.rb +0 -54
- data/spec/lol/team_statistic_spec.rb +0 -20
- data/spec/lol/tournament_code_spec.rb +0 -20
- data/spec/lol/tournament_provider_request_spec.rb +0 -73
data/.travis.yml
CHANGED
@@ -1,68 +1,40 @@
|
|
1
1
|
module Lol
|
2
|
+
# Bindings for the Champion Mastery API.
|
3
|
+
#
|
4
|
+
# See: https://developer.riotgames.com/api-methods/#champion-mastery-v3
|
2
5
|
class ChampionMasteryRequest < Request
|
3
|
-
#
|
4
|
-
|
5
|
-
|
6
|
-
def self.api_version
|
7
|
-
'v1.0'
|
6
|
+
# @!visibility private
|
7
|
+
def api_base_path
|
8
|
+
"/lol/champion-mastery/#{api_version}"
|
8
9
|
end
|
9
10
|
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
# @
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
ChampionMastery.new(result)
|
19
|
-
end
|
20
|
-
|
21
|
-
# Retrieve champion mastery information for all champion
|
22
|
-
# @param [FixNum] player_id id of player
|
23
|
-
# @return [Array] array of champion mastery information
|
24
|
-
def champions player_id
|
25
|
-
url = "player/#{player_id}/champions"
|
26
|
-
result = perform_request(api_url(url))
|
27
|
-
result.map { |c| ChampionMastery.new(c) }
|
28
|
-
end
|
29
|
-
|
30
|
-
# Get a player's total champion mastery score, which is sum of individual champion mastery levels
|
31
|
-
# @param [FixNum] player_id id of player
|
32
|
-
# @return [FixNum] Players mastery score
|
33
|
-
def score player_id
|
34
|
-
url = "player/#{player_id}/score"
|
35
|
-
perform_request(api_url(url)).to_i
|
36
|
-
end
|
37
|
-
|
38
|
-
# Get specified number of top champion mastery entries sorted by number of champion points descending
|
39
|
-
# @param [FixNum] player_id id of player
|
40
|
-
# @option options [Fixnum] :count the number of mastery scores to get. Defaults to 3
|
41
|
-
# @return [Array] array of champion mastery information, sorted by number of champion points descending
|
42
|
-
def top_champions player_id, options = {}
|
43
|
-
if options.keys.select { |k| k.to_sym != :count }.any?
|
44
|
-
raise ArgumentError, 'Only :count is allowed as extra parameter'
|
45
|
-
end
|
46
|
-
url = "player/#{player_id}/topchampions"
|
47
|
-
url = api_url(url, options)
|
48
|
-
result = perform_request(url)
|
49
|
-
result.map { |c| ChampionMastery.new(c) }
|
11
|
+
# Get a player's total champion mastery score, which is the sum of individual champion mastery levels
|
12
|
+
#
|
13
|
+
# See: https://developer.riotgames.com/api-methods/#champion-mastery-v3/GET_getDynamicModelScore
|
14
|
+
# @param [Integer] summoner_id Summoner ID associated with the player
|
15
|
+
# @return [Integer] Player's total champion master score
|
16
|
+
def total_score summoner_id:
|
17
|
+
perform_request api_url "scores/by-summoner/#{summoner_id}"
|
50
18
|
end
|
51
19
|
|
52
|
-
#
|
53
|
-
#
|
54
|
-
#
|
55
|
-
|
56
|
-
|
57
|
-
|
20
|
+
# Get all champion mastery entries sorted by number of champion points descending
|
21
|
+
#
|
22
|
+
# See: https://developer.riotgames.com/api-methods/#champion-mastery-v3/GET_getAllChampionMasteries
|
23
|
+
# @param [Integer] summoner_id Summoner ID associated with the player
|
24
|
+
# @return [Array<Lol::DynamicModel>] Champion Masteries
|
25
|
+
def all summoner_id:
|
26
|
+
result = perform_request api_url "champion-masteries/by-summoner/#{summoner_id}"
|
27
|
+
result.map { |c| DynamicModel.new c }
|
58
28
|
end
|
59
29
|
|
60
|
-
|
61
|
-
|
62
|
-
#
|
63
|
-
|
64
|
-
|
65
|
-
|
30
|
+
# Get a champion mastery by player ID and champion ID
|
31
|
+
#
|
32
|
+
# See: https://developer.riotgames.com/api-methods/#champion-mastery-v3/GET_getDynamicModel
|
33
|
+
# @param [Integer] summoner_id Summoner ID associated with the player
|
34
|
+
# @return [Lol::DynamicModel] Champion Mastery
|
35
|
+
def find champion_id, summoner_id:
|
36
|
+
result = perform_request api_url "champion-masteries/by-summoner/#{summoner_id}/by-champion/#{champion_id}"
|
37
|
+
DynamicModel.new result
|
66
38
|
end
|
67
39
|
end
|
68
40
|
end
|
data/lib/lol/champion_request.rb
CHANGED
@@ -1,30 +1,26 @@
|
|
1
1
|
module Lol
|
2
|
+
# Bindings for the Champion API.
|
3
|
+
#
|
4
|
+
# See: https://developer.riotgames.com/api-methods/#champion-v3
|
2
5
|
class ChampionRequest < Request
|
3
|
-
# Returns the supported API Version
|
4
|
-
# @return [String] the supported api version
|
5
|
-
def self.api_version
|
6
|
-
"v1.2"
|
7
|
-
end
|
8
|
-
|
9
6
|
# Retrieve all champions
|
10
|
-
#
|
11
|
-
#
|
12
|
-
# @
|
13
|
-
# @return [Array] an array of champions
|
14
|
-
def
|
15
|
-
|
16
|
-
|
17
|
-
free_to_play = options.delete(:free_to_play) ? true : false
|
18
|
-
|
19
|
-
url = champion_id ? "champion/#{champion_id}" : "champion"
|
20
|
-
result = perform_request(api_url(url, "freeToPlay" => free_to_play))
|
21
|
-
|
22
|
-
if champion_id
|
23
|
-
Champion.new(result)
|
24
|
-
else
|
25
|
-
result["champions"].map {|c| Champion.new(c)}
|
26
|
-
end
|
7
|
+
#
|
8
|
+
# See: https://developer.riotgames.com/api-methods/#champion-v3/GET_getChampions
|
9
|
+
# @param free_to_play [Boolean] filter param to retrieve only free to play champions
|
10
|
+
# @return [Array<Lol::DynamicModel>] an array of champions
|
11
|
+
def all free_to_play: false
|
12
|
+
result = perform_request api_url("champions", "freeToPlay" => free_to_play)
|
13
|
+
result["champions"].map { |c| DynamicModel.new c }
|
27
14
|
end
|
28
15
|
|
16
|
+
# Retrieve champion by ID
|
17
|
+
#
|
18
|
+
# See: https://developer.riotgames.com/api-methods/#champion-v3/GET_getChampionsById
|
19
|
+
# @param id [Integer] id of the champion to get
|
20
|
+
# @return [Lol::DynamicModel] the found champion
|
21
|
+
def find id
|
22
|
+
result = perform_request api_url "champions/#{id}"
|
23
|
+
DynamicModel.new result
|
24
|
+
end
|
29
25
|
end
|
30
26
|
end
|
data/lib/lol/client.rb
CHANGED
@@ -10,7 +10,7 @@ module Lol
|
|
10
10
|
attr_reader :api_key
|
11
11
|
|
12
12
|
# @!attribute [r] ttl
|
13
|
-
# @return [
|
13
|
+
# @return [Integer] the ttl on cached requests
|
14
14
|
attr_reader :ttl
|
15
15
|
|
16
16
|
# @return [ChampionRequest]
|
@@ -23,34 +23,29 @@ module Lol
|
|
23
23
|
@champion_mastery_request ||= ChampionMasteryRequest.new(api_key, region, cache_store)
|
24
24
|
end
|
25
25
|
|
26
|
-
# @return [GameRequest]
|
27
|
-
def game
|
28
|
-
@game_request ||= GameRequest.new(api_key, region, cache_store)
|
29
|
-
end
|
30
|
-
|
31
26
|
# @return [MatchRequest]
|
32
27
|
def match
|
33
28
|
@match_request ||= MatchRequest.new(api_key, region, cache_store)
|
34
29
|
end
|
35
30
|
|
36
|
-
# @return [
|
37
|
-
def
|
38
|
-
@
|
31
|
+
# @return [LeagueRequest]
|
32
|
+
def league
|
33
|
+
@league_request ||= LeagueRequest.new(api_key, region, cache_store)
|
39
34
|
end
|
40
35
|
|
41
|
-
# @return [
|
42
|
-
def
|
43
|
-
@
|
36
|
+
# @return [RunesRequest]
|
37
|
+
def runes
|
38
|
+
@runes_request ||= RunesRequest.new(api_key, region, cache_store)
|
44
39
|
end
|
45
40
|
|
46
|
-
# @return [
|
47
|
-
def
|
48
|
-
@
|
41
|
+
# @return [MasteriesRequest]
|
42
|
+
def masteries
|
43
|
+
@masteries_request ||= MasteriesRequest.new(api_key, region, cache_store)
|
49
44
|
end
|
50
45
|
|
51
|
-
# @return [
|
52
|
-
def
|
53
|
-
@
|
46
|
+
# @return [SpectatorRequest]
|
47
|
+
def spectator
|
48
|
+
@spectator_request ||= SpectatorRequest.new(api_key, region, cache_store)
|
54
49
|
end
|
55
50
|
|
56
51
|
# @return [SummonerRequest]
|
@@ -65,7 +60,7 @@ module Lol
|
|
65
60
|
|
66
61
|
# @return [LolStatusRequest]
|
67
62
|
def lol_status
|
68
|
-
@lol_status ||= LolStatusRequest.new(region, cache_store)
|
63
|
+
@lol_status ||= LolStatusRequest.new(api_key, region, cache_store)
|
69
64
|
end
|
70
65
|
|
71
66
|
# @return [CurrentGameRequest]
|
@@ -80,7 +75,7 @@ module Lol
|
|
80
75
|
|
81
76
|
# @return [TournamentProviderRequest]
|
82
77
|
def tournament
|
83
|
-
@tournament ||=
|
78
|
+
@tournament ||= TournamentRequest.new(api_key, region, cache_store)
|
84
79
|
end
|
85
80
|
|
86
81
|
# Initializes a Lol::Client
|
@@ -88,7 +83,7 @@ module Lol
|
|
88
83
|
# @param options [Hash]
|
89
84
|
# @option options [String] :region ("EUW") The region on which the requests will be made
|
90
85
|
# @option options [String] :redis the redis url to use for caching
|
91
|
-
# @option options [
|
86
|
+
# @option options [Integer] :ttl (900) the cache ttl
|
92
87
|
# @return [Lol::Client]
|
93
88
|
def initialize api_key, options = {}
|
94
89
|
@api_key = api_key
|
data/lib/lol/dynamic_model.rb
CHANGED
@@ -6,8 +6,11 @@ module Lol
|
|
6
6
|
# - nested generation ({a: {}}) results in DynamicModel(a: DynamicModel)
|
7
7
|
# - parsing of date/time when property name ends with _at or _date and the value is a number
|
8
8
|
class DynamicModel < OpenStruct
|
9
|
+
attr_reader :raw
|
10
|
+
|
9
11
|
def initialize(hash={})
|
10
12
|
raise ArgumentError, 'An hash is required as parameter' unless hash.is_a? Hash
|
13
|
+
@raw = hash
|
11
14
|
@table = {}
|
12
15
|
@hash_table = {}
|
13
16
|
|
@@ -26,6 +29,12 @@ module Lol
|
|
26
29
|
@table.as_json
|
27
30
|
end
|
28
31
|
|
32
|
+
protected
|
33
|
+
|
34
|
+
def class_for_property property
|
35
|
+
self.class
|
36
|
+
end
|
37
|
+
|
29
38
|
private
|
30
39
|
|
31
40
|
def date_key? key
|
@@ -33,10 +42,10 @@ module Lol
|
|
33
42
|
end
|
34
43
|
|
35
44
|
def set_property key, v
|
36
|
-
if date_key?(key) && v.is_a?(
|
45
|
+
if date_key?(key) && v.is_a?(Integer)
|
37
46
|
@table[key.to_sym] = @hash_table[key.to_sym] = value_to_date v
|
38
47
|
else
|
39
|
-
@table[key.to_sym] = convert_object v
|
48
|
+
@table[key.to_sym] = convert_object v, property: key.to_sym
|
40
49
|
@hash_table[key.to_sym] = v
|
41
50
|
end
|
42
51
|
end
|
@@ -45,11 +54,11 @@ module Lol
|
|
45
54
|
Time.at(v / 1000)
|
46
55
|
end
|
47
56
|
|
48
|
-
def convert_object obj
|
57
|
+
def convert_object obj, property:
|
49
58
|
if obj.is_a? Hash
|
50
|
-
|
59
|
+
class_for_property(property).new obj
|
51
60
|
elsif obj.respond_to?(:map)
|
52
|
-
obj.map { |o| convert_object o }
|
61
|
+
obj.map { |o| convert_object o, property: property }
|
53
62
|
else
|
54
63
|
obj
|
55
64
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Lol
|
2
|
+
# List of featured games
|
3
|
+
#
|
4
|
+
# Each contained featured game is represented through {DynamicModel}
|
5
|
+
class FeaturedGameList < Array
|
6
|
+
# The suggested interval to wait before requesting FeaturedGames again
|
7
|
+
# @return [Integer]
|
8
|
+
attr_reader :client_refresh_interval
|
9
|
+
|
10
|
+
def initialize data
|
11
|
+
@client_refresh_interval = data['clientRefreshInterval']
|
12
|
+
super data['gameList'].map { |g| DynamicModel.new g }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/lol/league_request.rb
CHANGED
@@ -1,62 +1,41 @@
|
|
1
1
|
module Lol
|
2
|
+
# Bindings for the League API.
|
3
|
+
#
|
4
|
+
# See: https://developer.riotgames.com/api-methods/#league-v3
|
2
5
|
class LeagueRequest < Request
|
3
|
-
#
|
4
|
-
|
5
|
-
|
6
|
-
"v2.5"
|
6
|
+
# @!visibility private
|
7
|
+
def api_base_path
|
8
|
+
"/lol/league/#{api_version}"
|
7
9
|
end
|
8
10
|
|
9
|
-
#
|
10
|
-
# @param [
|
11
|
-
# @return
|
12
|
-
def
|
13
|
-
|
11
|
+
# Get the challenger league for a given queue
|
12
|
+
# @param [String] queue Queue identifier. See the list of game constants (developer.riotgames.com/game-constants.html) for the available queue identifiers
|
13
|
+
# @return [DynamicModel] Challenger league
|
14
|
+
def find_challenger queue: 'RANKED_SOLO_5x5'
|
15
|
+
DynamicModel.new perform_request api_url "challengerleagues/by-queue/#{queue}"
|
14
16
|
end
|
15
17
|
|
16
|
-
#
|
17
|
-
# @param [
|
18
|
-
# @return
|
19
|
-
|
20
|
-
|
21
|
-
perform_league_request("league/by-summoner/#{summoner_ids.join(',')}/entry")
|
18
|
+
# Get the master league for a given queue
|
19
|
+
# @param [String] queue Queue identifier. See the list of game constants (developer.riotgames.com/game-constants.html) for the available queue identifiers
|
20
|
+
# @return [DynamicModel] lMaster league
|
21
|
+
def find_master queue: 'RANKED_SOLO_5x5'
|
22
|
+
DynamicModel.new perform_request api_url "masterleagues/by-queue/#{queue}"
|
22
23
|
end
|
23
24
|
|
24
|
-
#
|
25
|
-
# @param [
|
26
|
-
# @return
|
27
|
-
def
|
28
|
-
|
25
|
+
# Get leagues in all queues for a given summoner ID
|
26
|
+
# @param [Integer] summoner_id Summoner ID associated with the player
|
27
|
+
# @return [Array<DynamicModel>] List of leagues summoner is participating in
|
28
|
+
def summoner_leagues summoner_id:
|
29
|
+
result = perform_request api_url "leagues/by-summoner/#{summoner_id}"
|
30
|
+
result.map { |c| DynamicModel.new c }
|
29
31
|
end
|
30
32
|
|
31
|
-
#
|
32
|
-
# @param [
|
33
|
-
# @return
|
34
|
-
|
35
|
-
|
36
|
-
|
33
|
+
# Get league positions in all queues for a given summoner ID
|
34
|
+
# @param [Integer] summoner_id Summoner ID associated with the player
|
35
|
+
# @return [Array<DynamicModel>] list of league positions
|
36
|
+
def summoner_positions summoner_id:
|
37
|
+
result = perform_request api_url "positions/by-summoner/#{summoner_id}"
|
38
|
+
result.map { |c| DynamicModel.new c }
|
37
39
|
end
|
38
|
-
|
39
|
-
# Retrieves challenger tier leagues
|
40
|
-
# @param [String] game queue type
|
41
|
-
# @return [League]
|
42
|
-
def challenger(game_queue_type="RANKED_SOLO_5x5")
|
43
|
-
league_json = perform_request(api_url('league/challenger', { :type => game_queue_type }))
|
44
|
-
League.new(league_json)
|
45
|
-
end
|
46
|
-
|
47
|
-
def master(game_queue_type="RANKED_SOLO_5x5")
|
48
|
-
league_json = perform_request(api_url('league/master', { :type => game_queue_type }))
|
49
|
-
League.new(league_json)
|
50
|
-
end
|
51
|
-
|
52
|
-
private
|
53
|
-
|
54
|
-
def perform_league_request(partial_url)
|
55
|
-
url = api_url(partial_url)
|
56
|
-
perform_request(url).each_with_object({}) do |(summoner_id, leagues), entries_hash|
|
57
|
-
entries_hash[summoner_id] = leagues.map(&League.method(:new))
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
40
|
end
|
62
41
|
end
|
@@ -1,34 +1,17 @@
|
|
1
1
|
module Lol
|
2
|
+
# Bindings for the Status API.
|
3
|
+
#
|
4
|
+
# See: https://developer.riotgames.com/api-methods/#lol-status-v3
|
2
5
|
class LolStatusRequest < Request
|
3
|
-
|
4
|
-
def
|
5
|
-
"
|
6
|
-
end
|
7
|
-
|
8
|
-
def initialize region = nil, cache_store = {}
|
9
|
-
super nil, region, cache_store
|
6
|
+
# @!visibility private
|
7
|
+
def api_base_path
|
8
|
+
"/lol/status/#{self.class.api_version}"
|
10
9
|
end
|
11
10
|
|
12
|
-
#
|
13
|
-
# This special call works against all regions
|
14
|
-
# @return [Array] an array of DynamicModel representing the response
|
15
|
-
def shards
|
16
|
-
perform_request(api_url('shards')).map do |shard_data|
|
17
|
-
DynamicModel.new shard_data
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
# Returns a detailed status of the current shard
|
11
|
+
# Get League of Legends status for the given shard
|
22
12
|
# @return [DynamicModel]
|
23
|
-
def
|
24
|
-
|
25
|
-
DynamicModel.new shard_data
|
26
|
-
end
|
27
|
-
|
28
|
-
def api_url path, params = {}
|
29
|
-
"http://status.leagueoflegends.com/#{path}".tap do |url|
|
30
|
-
url << "/#{params}" unless params.empty?
|
31
|
-
end
|
13
|
+
def shard_data
|
14
|
+
DynamicModel.new perform_request api_url "shard-data"
|
32
15
|
end
|
33
16
|
end
|
34
17
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Lol
|
2
|
+
# Bindings for the Masteries API.
|
3
|
+
#
|
4
|
+
# See: https://developer.riotgames.com/api-methods/#masteries-v3
|
5
|
+
class MasteriesRequest < Request
|
6
|
+
# Get mastery pages for a given summoner ID
|
7
|
+
# @param [Integer] summoner_id Summoner ID
|
8
|
+
# @return [Array<DynamicModel>] Mastery pages
|
9
|
+
def by_summoner_id summoner_id
|
10
|
+
result = perform_request api_url "masteries/by-summoner/#{summoner_id}"
|
11
|
+
result["pages"].map { |p| DynamicModel.new p }
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|