lol_api 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +22 -0
  3. data/.guardfile +11 -0
  4. data/.travis.yml +6 -0
  5. data/Gemfile +10 -0
  6. data/LICENSE.txt +22 -0
  7. data/README.md +29 -0
  8. data/Rakefile +10 -0
  9. data/lib/lol_api/client.rb +105 -0
  10. data/lib/lol_api/configuration.rb +15 -0
  11. data/lib/lol_api/connection.rb +32 -0
  12. data/lib/lol_api/types/champion.rb +95 -0
  13. data/lib/lol_api/types/dtos/image.rb +33 -0
  14. data/lib/lol_api/types/dtos/info.rb +25 -0
  15. data/lib/lol_api/types/dtos/participant.rb +419 -0
  16. data/lib/lol_api/types/dtos/participant_identity.rb +19 -0
  17. data/lib/lol_api/types/dtos/passive.rb +27 -0
  18. data/lib/lol_api/types/dtos/player.rb +22 -0
  19. data/lib/lol_api/types/dtos/recommended.rb +38 -0
  20. data/lib/lol_api/types/dtos/skin.rb +20 -0
  21. data/lib/lol_api/types/dtos/spell.rb +98 -0
  22. data/lib/lol_api/types/dtos/stat.rb +19 -0
  23. data/lib/lol_api/types/dtos/team.rb +57 -0
  24. data/lib/lol_api/types/dtos/timeline.rb +180 -0
  25. data/lib/lol_api/types/history_match.rb +61 -0
  26. data/lib/lol_api/types/item.rb +126 -0
  27. data/lib/lol_api/types/mastery.rb +39 -0
  28. data/lib/lol_api/types/match.rb +43 -0
  29. data/lib/lol_api/types/summoner.rb +26 -0
  30. data/lib/lol_api/types/summoner_masteries.rb +66 -0
  31. data/lib/lol_api/types/summoner_runes.rb +69 -0
  32. data/lib/lol_api/utils/inspectable.rb +10 -0
  33. data/lib/lol_api/version.rb +3 -0
  34. data/lib/lol_api.rb +12 -0
  35. data/lol_api.gemspec +29 -0
  36. data/spec/champion_spec.rb +48 -0
  37. data/spec/client_spec.rb +67 -0
  38. data/spec/delegation_spec.rb +5 -0
  39. data/spec/factories.rb +43 -0
  40. data/spec/fixtures/champion.json +843 -0
  41. data/spec/fixtures/history.json +127 -0
  42. data/spec/fixtures/item.json +62 -0
  43. data/spec/fixtures/mastery.json +25 -0
  44. data/spec/fixtures/match.json +12167 -0
  45. data/spec/fixtures/match_details.json +13548 -0
  46. data/spec/fixtures/summoner.json +7 -0
  47. data/spec/fixtures/summoner_masteries.json +143 -0
  48. data/spec/fixtures/summoner_runes.json +132 -0
  49. data/spec/history_spec.rb +280 -0
  50. data/spec/item_spec.rb +96 -0
  51. data/spec/mastery_spec.rb +27 -0
  52. data/spec/match_details_spec.rb +72 -0
  53. data/spec/participant_spec.rb +153 -0
  54. data/spec/participant_timeline_spec.rb +80 -0
  55. data/spec/spec_helper.rb +22 -0
  56. data/spec/summoner_spec.rb +120 -0
  57. data/spec/team_spec.rb +38 -0
  58. data/spec/timeline_spec.rb +101 -0
  59. metadata +236 -0
@@ -0,0 +1,419 @@
1
+ module LolApi
2
+ class Participant
3
+ attr_reader :raw_participant
4
+
5
+ def initialize(raw_participant)
6
+ @raw_participant = raw_participant
7
+ end
8
+
9
+ def masteries
10
+ raw_participant['masteries']
11
+ end
12
+
13
+ def champion_id
14
+ raw_participant['championId']
15
+ end
16
+
17
+ def runes
18
+ raw_participant['runes']
19
+ end
20
+
21
+ def participant_id
22
+ raw_participant['participantId']
23
+ end
24
+
25
+ def spell_1
26
+ raw_participant['spell1Id']
27
+ end
28
+
29
+ def spell_2
30
+ raw_participant['spell2Id']
31
+ end
32
+
33
+ def stats
34
+ ParticipantStats.new(raw_participant['stats'])
35
+ end
36
+
37
+ def team_id
38
+ raw_participant['teamId']
39
+ end
40
+
41
+ def timeline
42
+ ParticipantTimeline.new(raw_participant['timeline'])
43
+ end
44
+ end
45
+
46
+ class ParticipantStats
47
+ attr_reader :raw_stats
48
+
49
+ def initialize(raw_stats)
50
+ @raw_stats = raw_stats
51
+ end
52
+
53
+ def assists
54
+ raw_stats['assists']
55
+ end
56
+ def champ_level
57
+ raw_stats['champLevel']
58
+ end
59
+
60
+ def combat_player_score
61
+ raw_stats['combatPlayerScore'] || 0
62
+ end
63
+
64
+ def deaths
65
+ raw_stats['deaths']
66
+ end
67
+
68
+ def double_kills
69
+ raw_stats['doubleKills']
70
+ end
71
+
72
+ def first_blood_assist
73
+ raw_stats['firstBloodAssist']
74
+ end
75
+
76
+ def first_blood_kill
77
+ raw_stats['firstBloodKill']
78
+ end
79
+
80
+ def first_inhibitor_assist
81
+ raw_stats['firstInhibitorAssist']
82
+ end
83
+
84
+ def first_inhibitor_kill
85
+ raw_stats['firstInhibitorKill']
86
+ end
87
+
88
+ def first_tower_assist
89
+ raw_stats['firstTowerAssist']
90
+ end
91
+
92
+ def first_tower_kill
93
+ raw_stats['firstTowerKill']
94
+ end
95
+
96
+ def gold_earned
97
+ raw_stats['goldEarned']
98
+ end
99
+
100
+ def gold_spent
101
+ raw_stats['goldSpent']
102
+ end
103
+
104
+ def inhibitor_kills
105
+ raw_stats['inhibitorKills']
106
+ end
107
+
108
+ def inventory
109
+ items = [
110
+ raw_stats['item0'],
111
+ raw_stats['item1'],
112
+ raw_stats['item2'],
113
+ raw_stats['item3'],
114
+ raw_stats['item4'],
115
+ raw_stats['item5'],
116
+ raw_stats['item6'],
117
+ ]
118
+ Inventory.new(items)
119
+ end
120
+
121
+ def killing_sprees
122
+ raw_stats['killingSprees']
123
+ end
124
+
125
+ def kills
126
+ raw_stats['kills']
127
+ end
128
+
129
+ def largest_crit
130
+ raw_stats['largestCriticalStrike']
131
+ end
132
+
133
+ def largest_killing_spree
134
+ raw_stats['largestKillingSpree']
135
+ end
136
+
137
+ def largest_multi_kill
138
+ raw_stats['largestMultiKill']
139
+ end
140
+
141
+ def magic_damage_dealt
142
+ raw_stats['magicDamageDealt']
143
+ end
144
+
145
+ def magic_damage_dealt_to_chanpions
146
+ raw_stats['magicDamageDealtToChampions']
147
+ end
148
+
149
+ def magic_damage_taken
150
+ raw_stats['magicDamageTaken']
151
+ end
152
+
153
+ def minions_killed
154
+ raw_stats['minionsKilled']
155
+ end
156
+
157
+ def neutral_minions_killed
158
+ raw_stats['neutralMinionsKilled']
159
+ end
160
+
161
+ def netural_minions_killed_enemy_jungle
162
+ raw_stats['neutralMinionsKilledEnemyJungle']
163
+ end
164
+
165
+ def netural_minions_killed_team_jungle
166
+ raw_stats['neutralMinionsKilledTeamJungle']
167
+ end
168
+
169
+ def node_capture
170
+ raw_stats['nodeCapture'] || 0
171
+ end
172
+ def node_capture_assist
173
+ raw_stats['nodeCaptureAssist'] || 0
174
+ end
175
+
176
+ def node_neutralize
177
+ raw_stats['nodeNeutralize'] || 0
178
+ end
179
+
180
+ def node_neutralize_assist
181
+ raw_stats['nodeNeutralizeAssist'] || 0
182
+ end
183
+
184
+ def objective_player_score
185
+ raw_stats['objectivePlayerScore'] || 0
186
+ end
187
+
188
+ def penta_kills
189
+ raw_stats['pentaKills']
190
+ end
191
+
192
+ def physical_damage_dealt
193
+ raw_stats['physicalDamageDealt']
194
+ end
195
+
196
+ def physical_damage_dealt_to_champions
197
+ raw_stats['physicalDamageDealtToChampions']
198
+ end
199
+
200
+ def physical_damage_taken
201
+ raw_stats['physicalDamageTaken']
202
+ end
203
+
204
+ def quadra_kills
205
+ raw_stats['quadraKills']
206
+ end
207
+
208
+ def sight_wards_bought
209
+ raw_stats['sightWardsBoughtInGame']
210
+ end
211
+
212
+ def team_objective
213
+ raw_stats['teamObjectives'] || 0
214
+ end
215
+
216
+ def total_damage_dealt
217
+ raw_stats['totalDamageDealt']
218
+ end
219
+
220
+ def total_damage_dealt_to_champions
221
+ raw_stats['totalDamageDealtToChampions']
222
+ end
223
+
224
+ def total_damage_taken
225
+ raw_stats['totalDamageTaken']
226
+ end
227
+
228
+ def total_heal
229
+ raw_stats['totalHeal']
230
+ end
231
+
232
+ def total_player_score
233
+ raw_stats['totalPlayerScore'] || 0
234
+ end
235
+
236
+ def total_score_rank
237
+ raw_stats['totalScoreRank'] || 0
238
+ end
239
+
240
+ def total_time_crowd_control_dealt
241
+ raw_stats['totalTimeCrowdControlDealt']
242
+ end
243
+
244
+ def total_units_healed
245
+ raw_stats['totalUnitsHealed']
246
+ end
247
+
248
+ def tower_kills
249
+ raw_stats['towerKills']
250
+ end
251
+
252
+ def triple_kills
253
+ raw_stats['tripleKills']
254
+ end
255
+
256
+ def true_damage_dealt
257
+ raw_stats['trueDamageDealt']
258
+ end
259
+
260
+ def true_damage_dealt_to_champions
261
+ raw_stats['trueDamageDealtToChampions']
262
+ end
263
+
264
+ def true_damage_taken
265
+ raw_stats['trueDamageTaken']
266
+ end
267
+
268
+ def unreal_kills
269
+ raw_stats['unrealKills']
270
+ end
271
+
272
+ def vision_wards_bought
273
+ raw_stats['visionWardsBoughtInGame']
274
+ end
275
+
276
+ def wards_killed
277
+ raw_stats['wardsKilled']
278
+ end
279
+
280
+ def wards_placed
281
+ raw_stats['wardsPlaced']
282
+ end
283
+
284
+ def winner
285
+ raw_stats['winner']
286
+ end
287
+ end
288
+ class ParticipantTimeline
289
+ attr_reader :raw_timeline
290
+
291
+ def initialize(raw_timeline)
292
+ @raw_timeline = raw_timeline
293
+ end
294
+
295
+ def ancient_golem_assists
296
+ TimelineData.new(raw_timeline['ancientGolemAssistsPerMinCounts'])
297
+ end
298
+ def ancient_golem_kills
299
+ TimelineData.new(raw_timeline['ancientGolemKillsPerMinCounts'])
300
+ end
301
+ def assisted_lane_deaths_delta
302
+ TimelineData.new(raw_timeline['assistedLaneDeathsPerMinDeltas'])
303
+ end
304
+ def assisted_lane_kills_delta
305
+ TimelineData.new(raw_timeline['assistedLaneKillsPerMinDeltas'])
306
+ end
307
+ def baron_assists
308
+ TimelineData.new(raw_timeline['baronAssistsPerMinCounts'])
309
+ end
310
+ def barron_kills
311
+ TimelineData.new(raw_timeline['baronKillsPerMinCounts'])
312
+ end
313
+ def creeps_delta
314
+ TimelineData.new(raw_timeline['creepsPerMinDeltas'])
315
+ end
316
+ def creep_diff_delta
317
+ TimelineData.new(raw_timeline['csDiffPerMinDeltas'])
318
+ end
319
+ def damage_taken_diff_delta
320
+ TimelineData.new(raw_timeline['damageTakenDiffPerMinDeltas'])
321
+ end
322
+ def damage_take_delta
323
+ TimelineData.new(raw_timeline['damageTakenPerMinDeltas'])
324
+ end
325
+ def dragon_assists
326
+ TimelineData.new(raw_timeline['dragonAssistsPerMinCounts'])
327
+ end
328
+ def dragon_kills
329
+ TimelineData.new(raw_timeline['dragonKillsPerMinCounts'])
330
+ end
331
+ def elder_lizard_assists
332
+ TimelineData.new(raw_timeline['elderLizardAssistsPerMinCounts'])
333
+ end
334
+ def eler_lizard_kills
335
+ TimelineData.new(raw_timeline['elderLizardKillsPerMinCounts'])
336
+ end
337
+ def gpm_delta
338
+ TimelineData.new(raw_timeline['goldPerMinDeltas'])
339
+ end
340
+ def inhibitor_assists
341
+ TimelineData.new(raw_timeline['inhibitorAssistsPerMinCounts'])
342
+ end
343
+ def inhibitor_kills
344
+ TimelineData.new(raw_timeline['inhibitorKillsPerMinCounts'])
345
+ end
346
+ def lane
347
+ raw_timeline['lane']
348
+ end
349
+ def role
350
+ raw_timeline['role']
351
+ end
352
+ def tower_assists
353
+ TimelineData.new(raw_timeline['towerAssistsPerMinCounts'])
354
+ end
355
+ def tower_kills
356
+ TimelineData.new(raw_timeline['towerKillsPerMinCounts'])
357
+ end
358
+ def vilemaw_assists
359
+ TimelineData.new(raw_timeline['vilemawAssistsPerMinCounts'])
360
+ end
361
+ def vilemaw_kills
362
+ TimelineData.new(raw_timeline['vilemawKillsPerMinCounts'])
363
+ end
364
+ def wards_delta
365
+ TimelineData.new(raw_timeline['wardsPerMinDeltas'])
366
+ end
367
+ def xp_diff_delta
368
+ TimelineData.new(raw_timeline['xpDiffPerMinDeltas'])
369
+ end
370
+ def xp_delta
371
+ TimelineData.new(raw_timeline['xpPerMinDeltas'])
372
+ end
373
+ end
374
+ class Inventory
375
+ attr_reader :item0, :item1, :item2, :item3, :item4, :item5, :item6
376
+ def initialize(items)
377
+ @item0 = items[0]
378
+ @item1 = items[1]
379
+ @item2 = items[2]
380
+ @item3 = items[3]
381
+ @item4 = items[4]
382
+ @item5 = items[5]
383
+ @item6 = items[6]
384
+ end
385
+ end
386
+ class TimelineData
387
+ attr_reader :raw_data
388
+
389
+ def initialize(raw_data)
390
+ @raw_data = raw_data
391
+ end
392
+
393
+ def ten_to_twenty
394
+ raw_data['tenToTwenty'].round(2)
395
+ end
396
+
397
+ def thirty_to_end
398
+ raw_data['thirtyToEnd'].round(2)
399
+ end
400
+
401
+ def twenty_to_thirty
402
+ raw_data['twentyToThirty'].round(2)
403
+ end
404
+
405
+ def zero_to_ten
406
+ raw_data['zeroToTen'].round(2)
407
+ end
408
+
409
+ def chart
410
+ [
411
+ :zero_to_ten => zero_to_ten,
412
+ :ten_to_twenty => ten_to_twenty,
413
+ :twenty_to_thirty => twenty_to_thirty,
414
+ :thirty_to_end => thirty_to_end
415
+ ]
416
+ end
417
+ end
418
+
419
+ end
@@ -0,0 +1,19 @@
1
+ require 'lol_api/types/dtos/player'
2
+
3
+ module LolApi
4
+ class ParticipantIdentity
5
+ attr_reader :raw_identity
6
+
7
+ def initialize(raw_identity)
8
+ @raw_identity = raw_identity
9
+ end
10
+
11
+ def participant_id
12
+ raw_identity['participantId']
13
+ end
14
+
15
+ def player
16
+ Player.new(raw_identity['player']) if raw_identity['player']
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,27 @@
1
+ require 'lol_api/types/dtos/image'
2
+ module LolApi
3
+ class Passive
4
+ include Utils::Inspectable
5
+ attr_reader :raw_passive
6
+
7
+ def initialize(raw_passive)
8
+ @raw_passive = raw_passive
9
+ end
10
+
11
+ def description
12
+ raw_passive['description']
13
+ end
14
+
15
+ def image
16
+ Image.new(raw_passive['image']) if raw_passive['image']
17
+ end
18
+
19
+ def name
20
+ raw_passive['name']
21
+ end
22
+
23
+ def sanitizedDescription
24
+ raw_passive['sanitizedDescription']
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,22 @@
1
+ module LolApi
2
+ class Player
3
+ attr_reader :raw_player
4
+
5
+ def initialize(raw_player)
6
+ @raw_player = raw_player
7
+ end
8
+
9
+ def match_history_uri
10
+ raw_player['matchHistoryUri']
11
+ end
12
+
13
+ def profile_icon
14
+ raw_player['profileIcon']
15
+ end
16
+
17
+ def summoner_name
18
+ raw_player['summonerName']
19
+ end
20
+
21
+ end
22
+ end
@@ -0,0 +1,38 @@
1
+
2
+ module LolApi
3
+ class Recommended
4
+ attr_reader :raw_recommended
5
+
6
+ def initialize(raw_recommended)
7
+ @raw_recommended = raw_recommended
8
+ end
9
+
10
+ def blocks
11
+ raw_recommended['blocks']
12
+ end
13
+
14
+ def champion
15
+ raw_recommended['champion']
16
+ end
17
+
18
+ def map
19
+ raw_recommended['map']
20
+ end
21
+
22
+ def mode
23
+ raw_recommended['mode']
24
+ end
25
+
26
+ def priority
27
+ raw_recommended['priority']
28
+ end
29
+
30
+ def title
31
+ raw_recommended['title']
32
+ end
33
+
34
+ def type
35
+ raw_recommended['type']
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,20 @@
1
+ module LolApi
2
+ class Skin
3
+ attr_reader :raw_skin
4
+
5
+ def initialize(raw_skin)
6
+ @raw_skin = raw_skin
7
+ end
8
+
9
+ def id
10
+ raw_skin['id']
11
+ end
12
+ def name
13
+ raw_skin['name']
14
+ end
15
+ def num
16
+ raw_skin['num']
17
+ end
18
+
19
+ end
20
+ end
@@ -0,0 +1,98 @@
1
+ require 'lol_api/types/dtos/image'
2
+
3
+
4
+ module LolApi
5
+ class Spell
6
+ attr_reader :raw_spell
7
+
8
+ def initialize(raw_spell)
9
+ @raw_spell = raw_spell
10
+ end
11
+
12
+ def alt_images
13
+ if images = raw_spell['altimages']
14
+ images.map do |item|
15
+ Image.new(item)
16
+ end
17
+ end
18
+ end
19
+
20
+ def cooldown
21
+ raw_spell['cooldown']
22
+ end
23
+
24
+ def cooldown_burn
25
+ raw_spell['cooldownBurn']
26
+ end
27
+
28
+ def cost
29
+ raw_spell['cost']
30
+ end
31
+
32
+ def cost_burn
33
+ raw_spell['costBurn']
34
+ end
35
+
36
+ def cost_type
37
+ raw_spell['costType']
38
+ end
39
+
40
+ def description
41
+ raw_spell['description']
42
+ end
43
+
44
+ def effect
45
+ raw_spell['effect']
46
+ end
47
+
48
+ def effect_burn
49
+ raw_spell['effectBurn']
50
+ end
51
+
52
+ def image
53
+ Image.new(raw_spell['image']) if raw_spell['image']
54
+ end
55
+
56
+ def key
57
+ raw_spell['key']
58
+ end
59
+
60
+ def level_tip
61
+ raw_spell['leveltip']
62
+ end
63
+
64
+ def max_rank
65
+ raw_spell['max_rank']
66
+ end
67
+ def name
68
+ raw_spell['name']
69
+ end
70
+
71
+ def range
72
+ raw_spell['range']
73
+ end
74
+
75
+ def range_burn
76
+ raw_spell['rangeBurn']
77
+ end
78
+ def resource
79
+ raw_spell['resource']
80
+ end
81
+
82
+ def sanitized_description
83
+ raw_spell['sanitized_description']
84
+ end
85
+
86
+ def sanitized_tooltip
87
+ raw_spell['sanitized_tooltip']
88
+ end
89
+
90
+ def tooltip
91
+ raw_spell['tooltip']
92
+ end
93
+
94
+ def vars
95
+ raw_spell['vars']
96
+ end
97
+ end
98
+ end
@@ -0,0 +1,19 @@
1
+ require 'lol_api/utils/inspectable'
2
+ module LolApi
3
+ class Stat
4
+ include Utils::Inspectable
5
+ attr_reader :raw_stat
6
+
7
+ def initialize(raw_stat)
8
+ @raw_stat = raw_stat
9
+ end
10
+
11
+ def name
12
+ raw_stat[0]
13
+ end
14
+
15
+ def value
16
+ raw_stat[1]
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,57 @@
1
+ module LolApi
2
+ class Team
3
+ attr_reader :raw_team
4
+
5
+ def initialize(raw_team)
6
+ @raw_team = raw_team
7
+ end
8
+ def bans
9
+ raw_team['bans']
10
+ end
11
+
12
+ def baron_kills
13
+ raw_team['baronKills']
14
+ end
15
+
16
+ def dragon_kills
17
+ raw_team['dragonKills']
18
+ end
19
+
20
+ def first_baron
21
+ raw_team['firstBaron']
22
+ end
23
+
24
+ def first_blood
25
+ raw_team['firstBlood']
26
+ end
27
+
28
+ def first_inhibitor
29
+ raw_team['firstInhibitor']
30
+ end
31
+
32
+ def first_tower
33
+ raw_team['firstTower']
34
+ end
35
+
36
+ def inhibitor_kills
37
+ raw_team['inhibitorKills']
38
+ end
39
+
40
+ def team_id
41
+ raw_team['teamId']
42
+ end
43
+
44
+ def tower_kills
45
+ raw_team['towerKills']
46
+ end
47
+
48
+ def vilemaw_kills
49
+ raw_team['vilemawKills']
50
+ end
51
+
52
+ def winner
53
+ raw_team['winner']
54
+ end
55
+
56
+ end
57
+ end