lolxin 0.12.1 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/LICENSE.txt +1 -1
- data/README.md +34 -3
- data/Rakefile +1 -1
- data/bin/bundle +105 -0
- data/bin/byebug +29 -0
- data/bin/cc-tddium-post-worker +12 -0
- data/bin/codeclimate-test-reporter +12 -0
- data/bin/coderay +12 -0
- data/bin/console +1 -1
- data/bin/dotenv +12 -0
- data/bin/htmldiff +12 -0
- data/bin/ldiff +12 -0
- data/bin/pry +12 -0
- data/bin/rake +12 -0
- data/bin/rspec +12 -0
- data/lib/lolxin.rb +29 -18
- data/lib/lolxin/api/champion.rb +24 -0
- data/lib/lolxin/api/champion_mastery.rb +38 -0
- data/lib/lolxin/api/league.rb +39 -0
- data/lib/lolxin/api/lol_static_data.rb +116 -0
- data/lib/lolxin/api/lol_status.rb +7 -0
- data/lib/lolxin/api/match.rb +41 -0
- data/lib/lolxin/api/spectator.rb +180 -0
- data/lib/lolxin/api/summoner.rb +25 -0
- data/lib/lolxin/api/third_party_code.rb +15 -0
- data/lib/lolxin/client.rb +26 -78
- data/lib/lolxin/dto/champion_dto.rb +29 -0
- data/lib/lolxin/dto/champion_mastery_dto.rb +33 -0
- data/lib/lolxin/dto/dto.rb +10 -0
- data/lib/lolxin/dto/game_info_dto.rb +31 -0
- data/lib/lolxin/dto/league_item_dto.rb +38 -0
- data/lib/lolxin/dto/league_list_dto.rb +27 -0
- data/lib/lolxin/dto/league_position_dto.rb +45 -0
- data/lib/lolxin/dto/mini_series_dto.rb +27 -0
- data/lib/lolxin/helpers/api.rb +20 -0
- data/lib/lolxin/helpers/api_version.rb +15 -0
- data/lib/lolxin/helpers/region.rb +21 -0
- data/lib/lolxin/helpers/version.rb +3 -0
- data/lolxin.gemspec +5 -2
- metadata +72 -22
- data/lib/lolxin/api_version.rb +0 -16
- data/lib/lolxin/champion.rb +0 -25
- data/lib/lolxin/champion_mastery.rb +0 -69
- data/lib/lolxin/current_game.rb +0 -44
- data/lib/lolxin/featured_games.rb +0 -23
- data/lib/lolxin/game.rb +0 -25
- data/lib/lolxin/league.rb +0 -58
- data/lib/lolxin/lol_static_data.rb +0 -41
- data/lib/lolxin/lol_status.rb +0 -21
- data/lib/lolxin/match.rb +0 -25
- data/lib/lolxin/match_list.rb +0 -40
- data/lib/lolxin/region.rb +0 -22
- data/lib/lolxin/stats.rb +0 -30
- data/lib/lolxin/summoner.rb +0 -55
- data/lib/lolxin/version.rb +0 -3
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module Lolxin
|
|
2
|
+
class Summoner < Api
|
|
3
|
+
attr_accessor :endpoint
|
|
4
|
+
|
|
5
|
+
def initialize(options = {})
|
|
6
|
+
super
|
|
7
|
+
@endpoint = "summoner/%{version}" % {version: @version}
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def by_account(account_id)
|
|
11
|
+
url = "#{endpoint}/summoners/by-account/#{account_id}"
|
|
12
|
+
conn.get(url)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def by_name(summoner_name)
|
|
16
|
+
url = "#{endpoint}/summoners/by-name/#{summoner_name}"
|
|
17
|
+
conn.get(url)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def summoners(summoner_id)
|
|
21
|
+
url = "#{endpoint}/summoners/#{summoner_id}"
|
|
22
|
+
conn.get(url)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module Lolxin
|
|
2
|
+
class ThirdPartyCode < Api
|
|
3
|
+
attr_accessor :endpoint
|
|
4
|
+
|
|
5
|
+
def initialize(options = {})
|
|
6
|
+
super
|
|
7
|
+
@endpoint = "platform/%{version}" % {version: @version}
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def by_summoner(summoner_id)
|
|
11
|
+
url = "#{endpoint}/by-summoner/#{summoner_id}"
|
|
12
|
+
conn.get(url)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
data/lib/lolxin/client.rb
CHANGED
|
@@ -3,90 +3,38 @@ module Lolxin
|
|
|
3
3
|
|
|
4
4
|
# Client create connection clients for specific endpoints
|
|
5
5
|
class Client
|
|
6
|
-
|
|
6
|
+
ENDPOINTS = [
|
|
7
|
+
:champion_mastery,
|
|
8
|
+
:champion,
|
|
9
|
+
:league,
|
|
10
|
+
:lol_static_data,
|
|
11
|
+
:lol_status,
|
|
12
|
+
:match,
|
|
13
|
+
:spectator,
|
|
14
|
+
:summoner,
|
|
15
|
+
:third_party_code
|
|
16
|
+
#tournament_stub
|
|
17
|
+
#tournament
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
attr_reader :region, :api_key, :options
|
|
7
21
|
|
|
8
22
|
def initialize(api_key, options = {})
|
|
9
23
|
@api_key = api_key
|
|
10
|
-
@region
|
|
11
|
-
|
|
24
|
+
@region = options[:region] if Region.valid?(options[:region])
|
|
25
|
+
@options = { api_key: @api_key, region: @region }
|
|
26
|
+
raise ClientError, "Invalid API key" if @api_key.nil? || @api_key.empty?
|
|
27
|
+
raise ClientError, "Invalid region" unless @region
|
|
12
28
|
end
|
|
13
29
|
|
|
14
|
-
|
|
15
|
-
options
|
|
16
|
-
|
|
17
|
-
options[:version] = ApiVersion::CHAMPION
|
|
18
|
-
Champion.new(options)
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
def lol_static_data(options = {})
|
|
22
|
-
options[:api_key] ||= api_key
|
|
23
|
-
options[:region] ||= region
|
|
24
|
-
options[:version] ||= ApiVersion::LOL_STATIC_DATA
|
|
25
|
-
LolStaticData.new(options)
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def lol_status(options = {})
|
|
29
|
-
LolStatus.new(options)
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def current_game(options = {})
|
|
33
|
-
options[:api_key] ||= api_key
|
|
34
|
-
options[:region] ||= region
|
|
35
|
-
CurrentGame.new(options)
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def featured_games(options = {})
|
|
39
|
-
options[:api_key] ||= api_key
|
|
40
|
-
options[:region] ||= region
|
|
41
|
-
FeaturedGames.new(options)
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def game(options = {})
|
|
45
|
-
options[:api_key] ||= api_key
|
|
46
|
-
options[:region] ||= region
|
|
47
|
-
options[:version] ||= ApiVersion::GAME
|
|
48
|
-
Game.new(options)
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
def champion_mastery(options = {})
|
|
52
|
-
options[:api_key] ||= api_key
|
|
53
|
-
options[:region] ||= region
|
|
54
|
-
ChampionMastery.new(options)
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
def league(options = {})
|
|
58
|
-
options[:api_key] ||= api_key
|
|
59
|
-
options[:region] ||= region
|
|
60
|
-
options[:version] ||= ApiVersion::LEAGUE
|
|
61
|
-
League.new(options)
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
def match(options = {})
|
|
65
|
-
options[:api_key] ||= api_key
|
|
66
|
-
options[:region] ||= region
|
|
67
|
-
options[:version] ||= ApiVersion::MATCH
|
|
68
|
-
Match.new(options)
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
def match_list(options = {})
|
|
72
|
-
options[:api_key] ||= api_key
|
|
73
|
-
options[:region] ||= region
|
|
74
|
-
options[:version] ||= ApiVersion::MATCH_LIST
|
|
75
|
-
MatchList.new(options)
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
def stats(options = {})
|
|
79
|
-
options[:api_key] ||= api_key
|
|
80
|
-
options[:region] ||= region
|
|
81
|
-
options[:version] ||= ApiVersion::STATS
|
|
82
|
-
Stats.new(options)
|
|
83
|
-
end
|
|
30
|
+
ENDPOINTS.each do |ep|
|
|
31
|
+
define_method(ep) do |options = @options|
|
|
32
|
+
options[:version] = ApiVersion.const_get(ep.to_s.upcase)
|
|
84
33
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
Summoner.new(options)
|
|
34
|
+
name = ep.to_s.split('_').map(&:capitalize).join
|
|
35
|
+
klass = Object.const_get(name)
|
|
36
|
+
klass.new(options)
|
|
37
|
+
end
|
|
90
38
|
end
|
|
91
39
|
end
|
|
92
40
|
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module Lolxin
|
|
2
|
+
class ChampionDto
|
|
3
|
+
attr_accessor(*%i(
|
|
4
|
+
ranked_play_enabled
|
|
5
|
+
bot_enabled
|
|
6
|
+
bot_mm_enabled
|
|
7
|
+
active
|
|
8
|
+
free_to_play
|
|
9
|
+
id
|
|
10
|
+
data
|
|
11
|
+
))
|
|
12
|
+
|
|
13
|
+
def initialize(data)
|
|
14
|
+
@data = data
|
|
15
|
+
initialize_with(data)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
private
|
|
19
|
+
|
|
20
|
+
def initialize_with(data)
|
|
21
|
+
@ranked_play_enabled = data['rankedPlayEnabled']
|
|
22
|
+
@bot_enabled = data['botEnabled']
|
|
23
|
+
@bot_mm_enabled = data['botMmEnabled']
|
|
24
|
+
@active = data['active']
|
|
25
|
+
@free_to_play = data['freeToPlay']
|
|
26
|
+
@id = data['id']
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
module Lolxin
|
|
2
|
+
class ChampionMasteryDto
|
|
3
|
+
attr_accessor(*%i(
|
|
4
|
+
chest_granted
|
|
5
|
+
champion_level
|
|
6
|
+
champion_points
|
|
7
|
+
champion_id
|
|
8
|
+
player_id
|
|
9
|
+
champion_points_until_next_level
|
|
10
|
+
champion_points_since_last_level
|
|
11
|
+
last_play_time
|
|
12
|
+
data
|
|
13
|
+
))
|
|
14
|
+
|
|
15
|
+
def initialize(data)
|
|
16
|
+
@data = data
|
|
17
|
+
initialize_with(data)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
def initialize_with(data)
|
|
23
|
+
@chest_granted = data['chestGranted']
|
|
24
|
+
@champion_level = data['championLevel']
|
|
25
|
+
@champion_points = data['championPoints']
|
|
26
|
+
@champion_id = data['championId']
|
|
27
|
+
@player_id = data['playerId']
|
|
28
|
+
@champion_points_until_next_level = data['championPointsUntilNextLevel']
|
|
29
|
+
@champion_points_since_last_level = data['championPointsSinceLastLevel']
|
|
30
|
+
@last_play_time = data['lastPlayTime']
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
module Lolxin
|
|
2
|
+
class GameInfoDto
|
|
3
|
+
attr_accessor(*%i(
|
|
4
|
+
game_id
|
|
5
|
+
game_start_time
|
|
6
|
+
platform_id
|
|
7
|
+
game_mode
|
|
8
|
+
map_id
|
|
9
|
+
game_type
|
|
10
|
+
banned_champions
|
|
11
|
+
observers
|
|
12
|
+
participants
|
|
13
|
+
game_length
|
|
14
|
+
game_queue_config_id
|
|
15
|
+
data
|
|
16
|
+
))
|
|
17
|
+
|
|
18
|
+
def initialize(data)
|
|
19
|
+
@data = data
|
|
20
|
+
initialize_with(data)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
private
|
|
24
|
+
|
|
25
|
+
# TODO: finish this
|
|
26
|
+
def initialize_with(data)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
CurrentGameInfoDto = FeaturedGameInfoDto = GameInfoDto
|
|
31
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
module Lolxin
|
|
2
|
+
class LeagueItemDto
|
|
3
|
+
attr_accessor(*%i(
|
|
4
|
+
rank
|
|
5
|
+
hot_streak
|
|
6
|
+
mini_series
|
|
7
|
+
wins
|
|
8
|
+
veteran
|
|
9
|
+
losses
|
|
10
|
+
player_or_team_name
|
|
11
|
+
player_or_team_id
|
|
12
|
+
inactive
|
|
13
|
+
fresh_blood
|
|
14
|
+
league_points
|
|
15
|
+
))
|
|
16
|
+
|
|
17
|
+
def initialize(data)
|
|
18
|
+
@data = data
|
|
19
|
+
initialize_with(data)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
private
|
|
23
|
+
|
|
24
|
+
def initialize_with(data)
|
|
25
|
+
@rank = data['rank']
|
|
26
|
+
@hot_streak = data['hotStreak']
|
|
27
|
+
@mini_series = MiniSeriesDto.new(data['miniSeries'])
|
|
28
|
+
@wins = data['wins']
|
|
29
|
+
@veteran = data['veteran']
|
|
30
|
+
@losses = data['losses']
|
|
31
|
+
@player_or_team_id = data['playerOrTeamId']
|
|
32
|
+
@player_or_team_name = data['playerOrTeamName']
|
|
33
|
+
@inactive = data['inactive']
|
|
34
|
+
@fresh_blood = data['freshBlood']
|
|
35
|
+
@league_points = data['leaguePoints']
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
module Lolxin
|
|
2
|
+
class LeagueListDto
|
|
3
|
+
attr_accessor(*%i(
|
|
4
|
+
tier
|
|
5
|
+
queue
|
|
6
|
+
name
|
|
7
|
+
entries
|
|
8
|
+
data
|
|
9
|
+
league_id
|
|
10
|
+
))
|
|
11
|
+
|
|
12
|
+
def initialize(data)
|
|
13
|
+
@data = data
|
|
14
|
+
initialize_with(data)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
private
|
|
18
|
+
|
|
19
|
+
def initialize_with(data)
|
|
20
|
+
@league_id = data['leagueId']
|
|
21
|
+
@tier = data['tier']
|
|
22
|
+
@queue = data['queue']
|
|
23
|
+
@name = data['name']
|
|
24
|
+
@entries = data['entries'].map { |entry| LeagueItemDto.new(entry) }
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
module Lolxin
|
|
2
|
+
class LeaguePositionDto
|
|
3
|
+
attr_accessor(*%i(
|
|
4
|
+
rank
|
|
5
|
+
queue_type
|
|
6
|
+
hot_streak
|
|
7
|
+
mini_series
|
|
8
|
+
wins
|
|
9
|
+
veteran
|
|
10
|
+
losses
|
|
11
|
+
player_or_team_id
|
|
12
|
+
league_name
|
|
13
|
+
player_or_team_name
|
|
14
|
+
inactive
|
|
15
|
+
fresh_blood
|
|
16
|
+
tier
|
|
17
|
+
league_points
|
|
18
|
+
data
|
|
19
|
+
))
|
|
20
|
+
|
|
21
|
+
def initialize(data)
|
|
22
|
+
@data = data
|
|
23
|
+
initialize_with(data)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
private
|
|
27
|
+
|
|
28
|
+
def initialize_with(data)
|
|
29
|
+
@rank = data['rank']
|
|
30
|
+
@queue_type = data['queueType']
|
|
31
|
+
@hot_streak = data['hotStreak']
|
|
32
|
+
@mini_series = MiniSeriesDto.new(data['miniSeries'])
|
|
33
|
+
@wins = data['wins']
|
|
34
|
+
@veteran = data['veteran']
|
|
35
|
+
@losses = data['losses']
|
|
36
|
+
@player_or_team_id = data['playerOrTeamId']
|
|
37
|
+
@league_name = data['leagueName']
|
|
38
|
+
@player_or_team_name = data['playerOrTeamName']
|
|
39
|
+
@inactive = data['inactive']
|
|
40
|
+
@fresh_blood = data['freshBlood']
|
|
41
|
+
@tier = data['tier']
|
|
42
|
+
@league_points = data['leaguePoints']
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
module Lolxin
|
|
2
|
+
class MiniSeriesDto
|
|
3
|
+
attr_accessor(*%i(
|
|
4
|
+
wins
|
|
5
|
+
losses
|
|
6
|
+
target
|
|
7
|
+
progress
|
|
8
|
+
data
|
|
9
|
+
))
|
|
10
|
+
|
|
11
|
+
def initialize(data)
|
|
12
|
+
@data = data
|
|
13
|
+
return nil if data.nil?
|
|
14
|
+
|
|
15
|
+
initialize_with(data)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
private
|
|
19
|
+
|
|
20
|
+
def initialize_with(data)
|
|
21
|
+
@wins = data['wins']
|
|
22
|
+
@losses = data['losses']
|
|
23
|
+
@target = data['target']
|
|
24
|
+
@progress = data['progress']
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module Lolxin
|
|
2
|
+
class Api
|
|
3
|
+
BASE_ENDPOINT = "https://%{region}.api.riotgames.com/lol/"
|
|
4
|
+
|
|
5
|
+
attr_accessor :api_key, :conn, :region, :version
|
|
6
|
+
|
|
7
|
+
def initialize(options = {})
|
|
8
|
+
@api_key = options[:api_key]
|
|
9
|
+
@region = options[:region]
|
|
10
|
+
@version = options[:version]
|
|
11
|
+
endpoint = BASE_ENDPOINT % {region: region}
|
|
12
|
+
|
|
13
|
+
@conn = Faraday.new(endpoint, options[:conn_options]) do |faraday|
|
|
14
|
+
faraday.request(:url_encoded)
|
|
15
|
+
faraday.adapter(Faraday.default_adapter)
|
|
16
|
+
faraday.params[:api_key] = api_key
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module Lolxin
|
|
2
|
+
module ApiVersion
|
|
3
|
+
CHAMPION_MASTERY = 'v3'
|
|
4
|
+
CHAMPION = 'v3'
|
|
5
|
+
LEAGUE = 'v3'
|
|
6
|
+
LOL_STATIC_DATA = 'v3'
|
|
7
|
+
LOL_STATUS = 'v3'
|
|
8
|
+
MATCH = 'v3'
|
|
9
|
+
SPECTATOR = 'v3'
|
|
10
|
+
SUMMONER = 'v3'
|
|
11
|
+
THIRD_PARTY_CODE = 'v3'
|
|
12
|
+
#TOURNAMENT_STUB = 'v3'
|
|
13
|
+
#TOURNAMENT = 'v3'
|
|
14
|
+
end
|
|
15
|
+
end
|