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,21 @@
|
|
|
1
|
+
module Lolxin
|
|
2
|
+
module Region
|
|
3
|
+
REGIONS = {
|
|
4
|
+
ru: 'ru',
|
|
5
|
+
kr: 'kr',
|
|
6
|
+
br1: 'br1',
|
|
7
|
+
oc1: 'oc1',
|
|
8
|
+
jp1: 'jp1',
|
|
9
|
+
na1: 'na1',
|
|
10
|
+
eun1: 'eun1',
|
|
11
|
+
euw1: 'euw1',
|
|
12
|
+
tr1: 'tr1',
|
|
13
|
+
la1: 'la1',
|
|
14
|
+
la2: 'la2'
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
def self.valid?(region)
|
|
18
|
+
REGIONS[region] || REGIONS.values.include?(region)
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
data/lolxin.gemspec
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# coding: utf-8
|
|
2
2
|
lib = File.expand_path('../lib', __FILE__)
|
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
-
require 'lolxin/version'
|
|
4
|
+
require 'lolxin/helpers/version'
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |spec|
|
|
7
7
|
spec.name = "lolxin"
|
|
@@ -22,11 +22,14 @@ Gem::Specification.new do |spec|
|
|
|
22
22
|
spec.add_development_dependency 'bundler', '~> 1.10'
|
|
23
23
|
spec.add_development_dependency 'rake', '~> 10.0'
|
|
24
24
|
spec.add_development_dependency 'rspec'
|
|
25
|
-
spec.add_development_dependency 'dotenv'
|
|
25
|
+
spec.add_development_dependency 'dotenv'
|
|
26
26
|
spec.add_development_dependency 'factory_girl', '~> 4.0'
|
|
27
27
|
spec.add_development_dependency 'pry'
|
|
28
|
+
spec.add_development_dependency 'pry-byebug'
|
|
29
|
+
spec.add_development_dependency 'byebug'
|
|
28
30
|
spec.add_development_dependency 'codeclimate-test-reporter'
|
|
29
31
|
spec.add_development_dependency 'simplecov'
|
|
30
32
|
|
|
31
33
|
spec.add_runtime_dependency 'faraday'
|
|
34
|
+
spec.add_runtime_dependency 'json'
|
|
32
35
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: lolxin
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.13.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jon Ho
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2018-03-06 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -56,16 +56,16 @@ dependencies:
|
|
|
56
56
|
name: dotenv
|
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
|
58
58
|
requirements:
|
|
59
|
-
- - "
|
|
59
|
+
- - ">="
|
|
60
60
|
- !ruby/object:Gem::Version
|
|
61
|
-
version:
|
|
61
|
+
version: '0'
|
|
62
62
|
type: :development
|
|
63
63
|
prerelease: false
|
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
65
|
requirements:
|
|
66
|
-
- - "
|
|
66
|
+
- - ">="
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
|
-
version:
|
|
68
|
+
version: '0'
|
|
69
69
|
- !ruby/object:Gem::Dependency
|
|
70
70
|
name: factory_girl
|
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -94,6 +94,34 @@ dependencies:
|
|
|
94
94
|
- - ">="
|
|
95
95
|
- !ruby/object:Gem::Version
|
|
96
96
|
version: '0'
|
|
97
|
+
- !ruby/object:Gem::Dependency
|
|
98
|
+
name: pry-byebug
|
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
|
100
|
+
requirements:
|
|
101
|
+
- - ">="
|
|
102
|
+
- !ruby/object:Gem::Version
|
|
103
|
+
version: '0'
|
|
104
|
+
type: :development
|
|
105
|
+
prerelease: false
|
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
107
|
+
requirements:
|
|
108
|
+
- - ">="
|
|
109
|
+
- !ruby/object:Gem::Version
|
|
110
|
+
version: '0'
|
|
111
|
+
- !ruby/object:Gem::Dependency
|
|
112
|
+
name: byebug
|
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
|
114
|
+
requirements:
|
|
115
|
+
- - ">="
|
|
116
|
+
- !ruby/object:Gem::Version
|
|
117
|
+
version: '0'
|
|
118
|
+
type: :development
|
|
119
|
+
prerelease: false
|
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
121
|
+
requirements:
|
|
122
|
+
- - ">="
|
|
123
|
+
- !ruby/object:Gem::Version
|
|
124
|
+
version: '0'
|
|
97
125
|
- !ruby/object:Gem::Dependency
|
|
98
126
|
name: codeclimate-test-reporter
|
|
99
127
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -136,6 +164,20 @@ dependencies:
|
|
|
136
164
|
- - ">="
|
|
137
165
|
- !ruby/object:Gem::Version
|
|
138
166
|
version: '0'
|
|
167
|
+
- !ruby/object:Gem::Dependency
|
|
168
|
+
name: json
|
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
|
170
|
+
requirements:
|
|
171
|
+
- - ">="
|
|
172
|
+
- !ruby/object:Gem::Version
|
|
173
|
+
version: '0'
|
|
174
|
+
type: :runtime
|
|
175
|
+
prerelease: false
|
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
177
|
+
requirements:
|
|
178
|
+
- - ">="
|
|
179
|
+
- !ruby/object:Gem::Version
|
|
180
|
+
version: '0'
|
|
139
181
|
description: Savage memes can't melt playoff dreams
|
|
140
182
|
email:
|
|
141
183
|
- jonwho.contact@gmail.com
|
|
@@ -153,7 +195,9 @@ files:
|
|
|
153
195
|
- LICENSE.txt
|
|
154
196
|
- README.md
|
|
155
197
|
- Rakefile
|
|
198
|
+
- bin/bundle
|
|
156
199
|
- bin/bundler
|
|
200
|
+
- bin/byebug
|
|
157
201
|
- bin/cc-tddium-post-worker
|
|
158
202
|
- bin/codeclimate-test-reporter
|
|
159
203
|
- bin/coderay
|
|
@@ -166,22 +210,28 @@ files:
|
|
|
166
210
|
- bin/rspec
|
|
167
211
|
- bin/setup
|
|
168
212
|
- lib/lolxin.rb
|
|
169
|
-
- lib/lolxin/
|
|
170
|
-
- lib/lolxin/
|
|
171
|
-
- lib/lolxin/
|
|
213
|
+
- lib/lolxin/api/champion.rb
|
|
214
|
+
- lib/lolxin/api/champion_mastery.rb
|
|
215
|
+
- lib/lolxin/api/league.rb
|
|
216
|
+
- lib/lolxin/api/lol_static_data.rb
|
|
217
|
+
- lib/lolxin/api/lol_status.rb
|
|
218
|
+
- lib/lolxin/api/match.rb
|
|
219
|
+
- lib/lolxin/api/spectator.rb
|
|
220
|
+
- lib/lolxin/api/summoner.rb
|
|
221
|
+
- lib/lolxin/api/third_party_code.rb
|
|
172
222
|
- lib/lolxin/client.rb
|
|
173
|
-
- lib/lolxin/
|
|
174
|
-
- lib/lolxin/
|
|
175
|
-
- lib/lolxin/
|
|
176
|
-
- lib/lolxin/
|
|
177
|
-
- lib/lolxin/
|
|
178
|
-
- lib/lolxin/
|
|
179
|
-
- lib/lolxin/
|
|
180
|
-
- lib/lolxin/
|
|
181
|
-
- lib/lolxin/
|
|
182
|
-
- lib/lolxin/
|
|
183
|
-
- lib/lolxin/
|
|
184
|
-
- lib/lolxin/version.rb
|
|
223
|
+
- lib/lolxin/dto/champion_dto.rb
|
|
224
|
+
- lib/lolxin/dto/champion_mastery_dto.rb
|
|
225
|
+
- lib/lolxin/dto/dto.rb
|
|
226
|
+
- lib/lolxin/dto/game_info_dto.rb
|
|
227
|
+
- lib/lolxin/dto/league_item_dto.rb
|
|
228
|
+
- lib/lolxin/dto/league_list_dto.rb
|
|
229
|
+
- lib/lolxin/dto/league_position_dto.rb
|
|
230
|
+
- lib/lolxin/dto/mini_series_dto.rb
|
|
231
|
+
- lib/lolxin/helpers/api.rb
|
|
232
|
+
- lib/lolxin/helpers/api_version.rb
|
|
233
|
+
- lib/lolxin/helpers/region.rb
|
|
234
|
+
- lib/lolxin/helpers/version.rb
|
|
185
235
|
- lolxin.gemspec
|
|
186
236
|
homepage: https://github.com/jonwho/lolxin
|
|
187
237
|
licenses:
|
|
@@ -203,7 +253,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
203
253
|
version: '0'
|
|
204
254
|
requirements: []
|
|
205
255
|
rubyforge_project:
|
|
206
|
-
rubygems_version: 2.
|
|
256
|
+
rubygems_version: 2.7.4
|
|
207
257
|
signing_key:
|
|
208
258
|
specification_version: 4
|
|
209
259
|
summary: Smooth API wrapper for League of Legends
|
data/lib/lolxin/api_version.rb
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
module Lolxin
|
|
2
|
-
module ApiVersion
|
|
3
|
-
CHAMPION = 'v1.2'
|
|
4
|
-
CHAMPION_MASTERY = 'Riot Games has not specified a version'
|
|
5
|
-
CURRENT_GAME = 'v1.0'
|
|
6
|
-
FEATURED_GAMES = 'v1.0'
|
|
7
|
-
GAME = 'v1.3'
|
|
8
|
-
LEAGUE = 'v2.5'
|
|
9
|
-
LOL_STATIC_DATA = 'v1.2'
|
|
10
|
-
LOL_STATUS = 'v1.0'
|
|
11
|
-
MATCH = 'v2.2'
|
|
12
|
-
MATCH_LIST = 'v2.2'
|
|
13
|
-
STATS = 'v1.3'
|
|
14
|
-
SUMMONER = 'v1.4'
|
|
15
|
-
end
|
|
16
|
-
end
|
data/lib/lolxin/champion.rb
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
module Lolxin
|
|
2
|
-
class Champion
|
|
3
|
-
BASE_ENDPOINT = "https://%s.api.pvp.net/api/lol/%s/%s/champion"
|
|
4
|
-
|
|
5
|
-
attr_accessor :conn
|
|
6
|
-
|
|
7
|
-
def initialize(options = {})
|
|
8
|
-
region = options[:region]
|
|
9
|
-
version = options[:version]
|
|
10
|
-
api_key = options[:api_key]
|
|
11
|
-
endpoint = BASE_ENDPOINT % [region, region, version]
|
|
12
|
-
@conn = Faraday.new(endpoint, options[:conn_options]) do |faraday|
|
|
13
|
-
faraday.request(:url_encoded)
|
|
14
|
-
faraday.response(:logger)
|
|
15
|
-
faraday.adapter(Faraday.default_adapter)
|
|
16
|
-
faraday.params[:api_key] = api_key
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def champion(params = {}, &block)
|
|
21
|
-
id = params.delete(:id).to_s
|
|
22
|
-
conn.get(id, params, &block)
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
module Lolxin
|
|
2
|
-
class ChampionMasteryError < StandardError; end
|
|
3
|
-
|
|
4
|
-
class ChampionMastery
|
|
5
|
-
BASE_ENDPOINT = "https://%s.api.pvp.net/championmastery/location"
|
|
6
|
-
|
|
7
|
-
REGIONS = %w[
|
|
8
|
-
BR1
|
|
9
|
-
EUN1
|
|
10
|
-
EUW1
|
|
11
|
-
JP1
|
|
12
|
-
KR
|
|
13
|
-
LA1
|
|
14
|
-
LA2
|
|
15
|
-
NA1
|
|
16
|
-
OC1
|
|
17
|
-
PBE1
|
|
18
|
-
RU
|
|
19
|
-
TR1
|
|
20
|
-
]
|
|
21
|
-
|
|
22
|
-
attr_accessor :conn
|
|
23
|
-
|
|
24
|
-
def initialize(options = {})
|
|
25
|
-
region = options[:region]
|
|
26
|
-
api_key = options[:api_key]
|
|
27
|
-
endpoint = BASE_ENDPOINT % [region]
|
|
28
|
-
@conn = Faraday.new(endpoint, options[:conn_options]) do |faraday|
|
|
29
|
-
faraday.request(:url_encoded)
|
|
30
|
-
faraday.response(:logger)
|
|
31
|
-
faraday.adapter(Faraday.default_adapter)
|
|
32
|
-
faraday.params[:api_key] = api_key
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def player_champion(params = {}, &block)
|
|
37
|
-
player_id = params.delete(:playerId)
|
|
38
|
-
champion_id = params.delete(:championId)
|
|
39
|
-
region = params.delete(:region)
|
|
40
|
-
raise(ChampionMasteryError, "Region given not in acceptable regions #{REGIONS}") unless REGIONS.include? region
|
|
41
|
-
endpoint = [region, 'player', player_id, 'champion', champion_id].join('/')
|
|
42
|
-
conn.get(endpoint, params, &block)
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def player_champions(params = {}, &block)
|
|
46
|
-
player_id = params.delete(:playerId)
|
|
47
|
-
region = params.delete(:region)
|
|
48
|
-
raise(ChampionMasteryError, "Region given not in acceptable regions #{REGIONS}") unless REGIONS.include? region
|
|
49
|
-
endpoint = [region, 'player', player_id, 'champions'].join('/')
|
|
50
|
-
conn.get(endpoint, params, &block)
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def player_score(params = {}, &block)
|
|
54
|
-
player_id = params.delete(:playerId)
|
|
55
|
-
region = params.delete(:region)
|
|
56
|
-
raise(ChampionMasteryError, "Region given not in acceptable regions #{REGIONS}") unless REGIONS.include? region
|
|
57
|
-
endpoint = [region, 'player', player_id, 'score'].join('/')
|
|
58
|
-
conn.get(endpoint, params, &block)
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
def player_top_champions(params = {}, &block)
|
|
62
|
-
player_id = params.delete(:playerId)
|
|
63
|
-
region = params.delete(:region)
|
|
64
|
-
raise(ChampionMasteryError, "Region given not in acceptable regions #{REGIONS}") unless REGIONS.include? region
|
|
65
|
-
endpoint = [region, 'player', player_id, 'topchampions'].join('/')
|
|
66
|
-
conn.get(endpoint, params, &block)
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
end
|
data/lib/lolxin/current_game.rb
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
module Lolxin
|
|
2
|
-
class CurrentGameError < StandardError; end
|
|
3
|
-
|
|
4
|
-
class CurrentGame
|
|
5
|
-
BASE_ENDPOINT = "https://%s.api.pvp.net/observer-mode/rest/consumer/getSpectatorGameInfo"
|
|
6
|
-
|
|
7
|
-
REGIONS = %w[
|
|
8
|
-
BR1
|
|
9
|
-
EUN1
|
|
10
|
-
EUW1
|
|
11
|
-
JP1
|
|
12
|
-
KR
|
|
13
|
-
LA1
|
|
14
|
-
LA2
|
|
15
|
-
NA1
|
|
16
|
-
OC1
|
|
17
|
-
PBE1
|
|
18
|
-
RU
|
|
19
|
-
TR1
|
|
20
|
-
]
|
|
21
|
-
|
|
22
|
-
attr_accessor :conn
|
|
23
|
-
|
|
24
|
-
def initialize(options = {})
|
|
25
|
-
region = options[:region]
|
|
26
|
-
api_key = options[:api_key]
|
|
27
|
-
endpoint = BASE_ENDPOINT % [region]
|
|
28
|
-
@conn = Faraday.new(endpoint, options[:conn_options]) do |faraday|
|
|
29
|
-
faraday.request(:url_encoded)
|
|
30
|
-
faraday.response(:logger)
|
|
31
|
-
faraday.adapter(Faraday.default_adapter)
|
|
32
|
-
faraday.params[:api_key] = api_key
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def observe(params = {}, &block)
|
|
37
|
-
region = params.delete(:region).to_s
|
|
38
|
-
raise(CurrentGameError, "Region given not in acceptable regions #{REGIONS}") unless REGIONS.include? region
|
|
39
|
-
summ_id = params.delete(:summonerId).to_s
|
|
40
|
-
endpoint = [region, summ_id].join('/')
|
|
41
|
-
conn.get(endpoint, params, &block)
|
|
42
|
-
end
|
|
43
|
-
end
|
|
44
|
-
end
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
module Lolxin
|
|
2
|
-
class FeaturedGames
|
|
3
|
-
BASE_ENDPOINT = "https://%s.api.pvp.net/observer-mode/rest/featured"
|
|
4
|
-
|
|
5
|
-
attr_accessor :conn
|
|
6
|
-
|
|
7
|
-
def initialize(options = {})
|
|
8
|
-
region = options[:region]
|
|
9
|
-
api_key = options[:api_key]
|
|
10
|
-
endpoint = BASE_ENDPOINT % [region]
|
|
11
|
-
@conn = Faraday.new(endpoint, options[:conn_options]) do |faraday|
|
|
12
|
-
faraday.request(:url_encoded)
|
|
13
|
-
faraday.response(:logger)
|
|
14
|
-
faraday.adapter(Faraday.default_adapter)
|
|
15
|
-
faraday.params[:api_key] = api_key
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def observe(params = {}, &block)
|
|
20
|
-
conn.get("", params, &block)
|
|
21
|
-
end
|
|
22
|
-
end
|
|
23
|
-
end
|
data/lib/lolxin/game.rb
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
module Lolxin
|
|
2
|
-
class Game
|
|
3
|
-
BASE_ENDPOINT = "https://%s.api.pvp.net/api/lol/%s/%s/game/by-summoner"
|
|
4
|
-
|
|
5
|
-
attr_accessor :conn
|
|
6
|
-
|
|
7
|
-
def initialize(options = {})
|
|
8
|
-
region = options[:region]
|
|
9
|
-
version = options[:version]
|
|
10
|
-
api_key = options[:api_key]
|
|
11
|
-
endpoint = BASE_ENDPOINT % [region, region, version]
|
|
12
|
-
@conn = Faraday.new(endpoint, options[:conn_options]) do |faraday|
|
|
13
|
-
faraday.request(:url_encoded)
|
|
14
|
-
faraday.response(:logger)
|
|
15
|
-
faraday.adapter(Faraday.default_adapter)
|
|
16
|
-
faraday.params[:api_key] = api_key
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
def observe(params = {}, &block)
|
|
21
|
-
summ_id = params.delete(:summonerId).to_s
|
|
22
|
-
conn.get("#{summ_id}/recent", params, &block)
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
end
|
data/lib/lolxin/league.rb
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
module Lolxin
|
|
2
|
-
class LeagueError < StandardError; end
|
|
3
|
-
|
|
4
|
-
class League
|
|
5
|
-
BASE_ENDPOINT = "https://%s.api.pvp.net/api/lol/%s/%s/league"
|
|
6
|
-
|
|
7
|
-
QUEUE_TYPES = %w[
|
|
8
|
-
RANKED_FLEX_SR
|
|
9
|
-
RANKED_FLEX_TT
|
|
10
|
-
RANKED_SOLO_5x5
|
|
11
|
-
RANKED_TEAM_3x3
|
|
12
|
-
RANKED_TEAM_5x5
|
|
13
|
-
]
|
|
14
|
-
|
|
15
|
-
attr_accessor :conn
|
|
16
|
-
|
|
17
|
-
def initialize(options = {})
|
|
18
|
-
region = options[:region]
|
|
19
|
-
version = options[:version]
|
|
20
|
-
api_key = options[:api_key]
|
|
21
|
-
endpoint = BASE_ENDPOINT % [region, region, version]
|
|
22
|
-
@conn = Faraday.new(endpoint, options[:conn_options]) do |faraday|
|
|
23
|
-
faraday.request(:url_encoded)
|
|
24
|
-
faraday.response(:logger)
|
|
25
|
-
faraday.adapter(Faraday.default_adapter)
|
|
26
|
-
faraday.params[:api_key] = api_key
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
def by_summoner(params = {}, &block)
|
|
31
|
-
summ_ids = params.delete(:summonerIds)
|
|
32
|
-
if summ_ids.is_a? Array
|
|
33
|
-
# Riot limits to 10 ids at a time
|
|
34
|
-
summ_ids = summ_ids[0...10].join(',')
|
|
35
|
-
end
|
|
36
|
-
conn.get("by-summoner/#{summ_ids}", params, &block)
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
def by_summoner_entry(params = {}, &block)
|
|
40
|
-
summ_ids = params.delete(:summonerIds)
|
|
41
|
-
if summ_ids.is_a? Array
|
|
42
|
-
# Riot limits to 10 ids at a time
|
|
43
|
-
summ_ids = summ_ids[0...10].join(',')
|
|
44
|
-
end
|
|
45
|
-
conn.get("by-summoner/#{summ_ids}/entry", params, &block)
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
def challenger(params = {}, &block)
|
|
49
|
-
raise(LeagueError, "Queue type given not in acceptable queue types #{QUEUE_TYPES}") unless QUEUE_TYPES.include? params[:type]
|
|
50
|
-
conn.get('challenger', params, &block)
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
def master(params = {}, &block)
|
|
54
|
-
raise(LeagueError, "Queue type given not in acceptable queue types #{QUEUE_TYPES}") unless QUEUE_TYPES.include? params[:type]
|
|
55
|
-
conn.get('master', params, &block)
|
|
56
|
-
end
|
|
57
|
-
end
|
|
58
|
-
end
|