ruby-lol 0.11.6 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d4b9a87dc12b623d51f0e9462d06954303232ecd
4
- data.tar.gz: 0f23a33f44b023d85d1af3338f9281b7f52d45a5
3
+ metadata.gz: f3f90de48b27bc6621f85b1d22e0d3b76443d2a6
4
+ data.tar.gz: 4372731e8a8f706870f5852f4b9e94b468bc5d4a
5
5
  SHA512:
6
- metadata.gz: d35f8a5413e29da1766d57cc8d51d9218b3347521ffba0701105bc5432908daa6c3fd6f3b1e2ef4bcdcf14c3fa4f8db2ad8b2d60aa9a96c79cacf4cc9a2317f4
7
- data.tar.gz: d545f853c78164b3b04bfa8c03b6e8b875f53e01429df886dbcb20fd675ae0367548f023690af236f4980fcfeaa1a5dc8f8f3f1f9e35f7d002623aadbf1067f8
6
+ metadata.gz: e20b94b2266e1b74836686aead53f86ebb64b2d16501b370c08cd6dd7872f71ba78edad8ee9fd180328d489d0f8204a4f329ddcee5ccbc008acdafc7aa043493
7
+ data.tar.gz: 4a6a5799ec1e3ee1ebe66818290cd80731608ed9476c8ff809b638f3120a55a74be0ffd9220afc782a58e2c25fd7afdcb9a05bedef4d859dda6ecbb9504ec30f
@@ -1,4 +1,4 @@
1
- rvm: 2.0.0
1
+ rvm: 2.2.3
2
2
  services: redis-server
3
3
  addons:
4
4
  code_climate:
@@ -0,0 +1,50 @@
1
+ module Lol
2
+ class ChampionMastery < Lol::Model
3
+ # @!attribute [r] champion_id
4
+ # @return [Fixnum] id of Champion
5
+ attr_reader :champion_id
6
+
7
+ # @!attribute [r] champion_level
8
+ # @return [Fixnum] Level of mastery for this champion
9
+ attr_reader :champion_level
10
+
11
+ # @!attribute [r] champion_points
12
+ # @return [Fixnum] Number of mastery points for this champion
13
+ attr_reader :champion_points
14
+
15
+ # @!attribute [r] champion_points_since_last_level
16
+ # @return [Fixnum] Number of mastery points since the last level for this champion
17
+ attr_reader :champion_points_since_last_level
18
+
19
+ # @!attribute [r] champion_points_until_next_level
20
+ # @return [Fixnum] Number of mastery points until the next level for this champion
21
+ attr_reader :champion_points_until_next_level
22
+
23
+ # @!attribute [r] chest_granted
24
+ # @return [true] if the chest for this champion has been granted
25
+ # @return [false] if the chest for this champion has been granted or not in current season
26
+ attr_reader :chest_granted
27
+
28
+ # @!attribute [r] highest_grade
29
+ # @return [String] The highest grade of this champion of current season
30
+ attr_reader :highest_grade
31
+
32
+ # @!attribute [r] last_play_time
33
+ # @return [Fixnum] Last time this champion was played by this player - in Unix milliseconds time format
34
+ attr_reader :last_play_time
35
+
36
+ # @!attribute [r] player_id
37
+ # @return [Fixnum] Player ID for this entry
38
+ attr_reader :player_id
39
+
40
+ # @!attribute [r] player_id
41
+ # @return [Fixnum] Number of tokens earned
42
+ attr_reader :tokens_earned
43
+
44
+ private
45
+
46
+ attr_writer :champion_id, :champion_level, :champion_points, :champion_points_since_last_level,
47
+ :champion_points_until_next_level, :chest_granted, :highest_grade, :last_play_time, :player_id,
48
+ :tokens_earned
49
+ end
50
+ end
@@ -0,0 +1,68 @@
1
+ module Lol
2
+ class ChampionMasteryRequest < Request
3
+ # Returns the supported API Version. ChampionMastery end point is not
4
+ # versioned, so just return v1.0 anyway
5
+ # @return [String] v1.0 (ChampionMastery end point is not versioned)
6
+ def self.api_version
7
+ 'v1.0'
8
+ end
9
+
10
+ # Retrieve champion mastery information for a specific champion
11
+ # @param [FixNum] player_id id of player
12
+ # @param [FixNum] champion_id id of champion
13
+ # @return [ChampionMastery] champion mastery information
14
+ def champion player_id, champion_id
15
+ url = "player/#{player_id}/champion/#{champion_id}"
16
+ result = perform_request(api_url(url))
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) }
50
+ end
51
+
52
+ # Returns a full url for an API call
53
+ # @param path [String] API path to call
54
+ # @return [String] full fledged url
55
+ def api_url path, params = {}
56
+ url = "#{api_base_url}/championmastery/location/#{region_to_platform(region)}/#{path}"
57
+ "#{url}?#{api_query_string params}"
58
+ end
59
+
60
+ private
61
+
62
+ #A hash mapping a region to the platform, since the ChampionMastery endpoint uses a platform and not a region
63
+ def region_to_platform(region)
64
+ { br: 'BR1', eune: 'EUN1', euw: 'EUW1', jp: 'JP1', kr: 'KR1', lan: 'LA1', las: 'LA2',
65
+ na: 'NA1', oce: 'OC1', ru: 'RU', tr: 'TR1' }[region.to_sym]
66
+ end
67
+ end
68
+ end
@@ -18,6 +18,11 @@ module Lol
18
18
  @champion_request ||= ChampionRequest.new(api_key, region, cache_store)
19
19
  end
20
20
 
21
+ # @return [ChampionMasteryRequest]
22
+ def champion_mastery
23
+ @champion_mastery_request ||= ChampionMasteryRequest.new(api_key, region, cache_store)
24
+ end
25
+
21
26
  # @return [GameRequest]
22
27
  def game
23
28
  @game_request ||= GameRequest.new(api_key, region, cache_store)
@@ -1,3 +1,3 @@
1
1
  module Lol
2
- VERSION = "0.11.6"
2
+ VERSION = "0.12.0"
3
3
  end
@@ -0,0 +1,12 @@
1
+ {
2
+ "highestGrade": "S+",
3
+ "championPoints": 34356,
4
+ "playerId": 1,
5
+ "championPointsUntilNextLevel": 0,
6
+ "chestGranted": true,
7
+ "championLevel": 5,
8
+ "tokensEarned": 2,
9
+ "championId": 40,
10
+ "championPointsSinceLastLevel": 12756,
11
+ "lastPlayTime": 1464499894000
12
+ }
@@ -0,0 +1,460 @@
1
+ [
2
+ {
3
+ "highestGrade": "S+",
4
+ "championPoints": 34356,
5
+ "playerId": 496402,
6
+ "championPointsUntilNextLevel": 0,
7
+ "chestGranted": true,
8
+ "championLevel": 5,
9
+ "tokensEarned": 2,
10
+ "championId": 40,
11
+ "championPointsSinceLastLevel": 12756,
12
+ "lastPlayTime": 1464499894000
13
+ },
14
+ {
15
+ "highestGrade": "A-",
16
+ "championPoints": 8972,
17
+ "playerId": 496402,
18
+ "championPointsUntilNextLevel": 3628,
19
+ "chestGranted": false,
20
+ "championLevel": 3,
21
+ "tokensEarned": 0,
22
+ "championId": 429,
23
+ "championPointsSinceLastLevel": 2972,
24
+ "lastPlayTime": 1463373502000
25
+ },
26
+ {
27
+ "highestGrade": "A-",
28
+ "championPoints": 7355,
29
+ "playerId": 496402,
30
+ "championPointsUntilNextLevel": 5245,
31
+ "chestGranted": false,
32
+ "championLevel": 3,
33
+ "tokensEarned": 0,
34
+ "championId": 15,
35
+ "championPointsSinceLastLevel": 1355,
36
+ "lastPlayTime": 1462509127000
37
+ },
38
+ {
39
+ "highestGrade": "A+",
40
+ "championPoints": 6581,
41
+ "playerId": 496402,
42
+ "championPointsUntilNextLevel": 6019,
43
+ "chestGranted": true,
44
+ "championLevel": 3,
45
+ "tokensEarned": 0,
46
+ "championId": 236,
47
+ "championPointsSinceLastLevel": 581,
48
+ "lastPlayTime": 1463462873000
49
+ },
50
+ {
51
+ "highestGrade": "S+",
52
+ "championPoints": 6555,
53
+ "playerId": 496402,
54
+ "championPointsUntilNextLevel": 6045,
55
+ "chestGranted": false,
56
+ "championLevel": 3,
57
+ "tokensEarned": 0,
58
+ "championId": 267,
59
+ "championPointsSinceLastLevel": 555,
60
+ "lastPlayTime": 1463983471000
61
+ },
62
+ {
63
+ "highestGrade": "A+",
64
+ "championPoints": 4478,
65
+ "playerId": 496402,
66
+ "championPointsUntilNextLevel": 1522,
67
+ "chestGranted": false,
68
+ "championLevel": 2,
69
+ "tokensEarned": 0,
70
+ "championId": 56,
71
+ "championPointsSinceLastLevel": 2678,
72
+ "lastPlayTime": 1463723059000
73
+ },
74
+ {
75
+ "highestGrade": "A+",
76
+ "championPoints": 4285,
77
+ "playerId": 496402,
78
+ "championPointsUntilNextLevel": 1715,
79
+ "chestGranted": false,
80
+ "championLevel": 2,
81
+ "tokensEarned": 0,
82
+ "championId": 245,
83
+ "championPointsSinceLastLevel": 2485,
84
+ "lastPlayTime": 1462688704000
85
+ },
86
+ {
87
+ "championPoints": 3162,
88
+ "playerId": 496402,
89
+ "championPointsUntilNextLevel": 2838,
90
+ "chestGranted": false,
91
+ "championLevel": 2,
92
+ "tokensEarned": 0,
93
+ "championId": 67,
94
+ "championPointsSinceLastLevel": 1362,
95
+ "lastPlayTime": 1437768811000
96
+ },
97
+ {
98
+ "highestGrade": "S",
99
+ "championPoints": 2686,
100
+ "playerId": 496402,
101
+ "championPointsUntilNextLevel": 3314,
102
+ "chestGranted": false,
103
+ "championLevel": 2,
104
+ "tokensEarned": 0,
105
+ "championId": 81,
106
+ "championPointsSinceLastLevel": 886,
107
+ "lastPlayTime": 1464415184000
108
+ },
109
+ {
110
+ "highestGrade": "S-",
111
+ "championPoints": 2589,
112
+ "playerId": 496402,
113
+ "championPointsUntilNextLevel": 3411,
114
+ "chestGranted": true,
115
+ "championLevel": 2,
116
+ "tokensEarned": 0,
117
+ "championId": 53,
118
+ "championPointsSinceLastLevel": 789,
119
+ "lastPlayTime": 1463114828000
120
+ },
121
+ {
122
+ "championPoints": 2567,
123
+ "playerId": 496402,
124
+ "championPointsUntilNextLevel": 3433,
125
+ "chestGranted": false,
126
+ "championLevel": 2,
127
+ "tokensEarned": 0,
128
+ "championId": 59,
129
+ "championPointsSinceLastLevel": 767,
130
+ "lastPlayTime": 1444791429000
131
+ },
132
+ {
133
+ "championPoints": 2556,
134
+ "playerId": 496402,
135
+ "championPointsUntilNextLevel": 3444,
136
+ "chestGranted": false,
137
+ "championLevel": 2,
138
+ "tokensEarned": 0,
139
+ "championId": 37,
140
+ "championPointsSinceLastLevel": 756,
141
+ "lastPlayTime": 1444277799000
142
+ },
143
+ {
144
+ "highestGrade": "S-",
145
+ "championPoints": 2332,
146
+ "playerId": 496402,
147
+ "championPointsUntilNextLevel": 3668,
148
+ "chestGranted": false,
149
+ "championLevel": 2,
150
+ "tokensEarned": 0,
151
+ "championId": 157,
152
+ "championPointsSinceLastLevel": 532,
153
+ "lastPlayTime": 1464412893000
154
+ },
155
+ {
156
+ "highestGrade": "A-",
157
+ "championPoints": 2164,
158
+ "playerId": 496402,
159
+ "championPointsUntilNextLevel": 3836,
160
+ "chestGranted": false,
161
+ "championLevel": 2,
162
+ "tokensEarned": 0,
163
+ "championId": 51,
164
+ "championPointsSinceLastLevel": 364,
165
+ "lastPlayTime": 1463375891000
166
+ },
167
+ {
168
+ "championPoints": 1561,
169
+ "playerId": 496402,
170
+ "championPointsUntilNextLevel": 239,
171
+ "chestGranted": false,
172
+ "championLevel": 1,
173
+ "tokensEarned": 0,
174
+ "championId": 22,
175
+ "championPointsSinceLastLevel": 1561,
176
+ "lastPlayTime": 1433019816000
177
+ },
178
+ {
179
+ "highestGrade": "A-",
180
+ "championPoints": 1435,
181
+ "playerId": 496402,
182
+ "championPointsUntilNextLevel": 365,
183
+ "chestGranted": false,
184
+ "championLevel": 1,
185
+ "tokensEarned": 0,
186
+ "championId": 82,
187
+ "championPointsSinceLastLevel": 1435,
188
+ "lastPlayTime": 1462607727000
189
+ },
190
+ {
191
+ "highestGrade": "S",
192
+ "championPoints": 1226,
193
+ "playerId": 496402,
194
+ "championPointsUntilNextLevel": 574,
195
+ "chestGranted": true,
196
+ "championLevel": 1,
197
+ "tokensEarned": 0,
198
+ "championId": 103,
199
+ "championPointsSinceLastLevel": 1226,
200
+ "lastPlayTime": 1464327096000
201
+ },
202
+ {
203
+ "highestGrade": "A-",
204
+ "championPoints": 1198,
205
+ "playerId": 496402,
206
+ "championPointsUntilNextLevel": 602,
207
+ "chestGranted": false,
208
+ "championLevel": 1,
209
+ "tokensEarned": 0,
210
+ "championId": 203,
211
+ "championPointsSinceLastLevel": 1198,
212
+ "lastPlayTime": 1462164785000
213
+ },
214
+ {
215
+ "highestGrade": "A+",
216
+ "championPoints": 1159,
217
+ "playerId": 496402,
218
+ "championPointsUntilNextLevel": 641,
219
+ "chestGranted": false,
220
+ "championLevel": 1,
221
+ "tokensEarned": 0,
222
+ "championId": 127,
223
+ "championPointsSinceLastLevel": 1159,
224
+ "lastPlayTime": 1463981860000
225
+ },
226
+ {
227
+ "highestGrade": "S-",
228
+ "championPoints": 1143,
229
+ "playerId": 496402,
230
+ "championPointsUntilNextLevel": 657,
231
+ "chestGranted": true,
232
+ "championLevel": 1,
233
+ "tokensEarned": 0,
234
+ "championId": 412,
235
+ "championPointsSinceLastLevel": 1143,
236
+ "lastPlayTime": 1462335465000
237
+ },
238
+ {
239
+ "highestGrade": "A+",
240
+ "championPoints": 1136,
241
+ "playerId": 496402,
242
+ "championPointsUntilNextLevel": 664,
243
+ "chestGranted": true,
244
+ "championLevel": 1,
245
+ "tokensEarned": 0,
246
+ "championId": 143,
247
+ "championPointsSinceLastLevel": 1136,
248
+ "lastPlayTime": 1462601925000
249
+ },
250
+ {
251
+ "highestGrade": "A-",
252
+ "championPoints": 1055,
253
+ "playerId": 496402,
254
+ "championPointsUntilNextLevel": 745,
255
+ "chestGranted": false,
256
+ "championLevel": 1,
257
+ "tokensEarned": 0,
258
+ "championId": 136,
259
+ "championPointsSinceLastLevel": 1055,
260
+ "lastPlayTime": 1462600100000
261
+ },
262
+ {
263
+ "highestGrade": "B",
264
+ "championPoints": 1012,
265
+ "playerId": 496402,
266
+ "championPointsUntilNextLevel": 788,
267
+ "chestGranted": false,
268
+ "championLevel": 1,
269
+ "tokensEarned": 0,
270
+ "championId": 3,
271
+ "championPointsSinceLastLevel": 1012,
272
+ "lastPlayTime": 1463976232000
273
+ },
274
+ {
275
+ "championPoints": 942,
276
+ "playerId": 496402,
277
+ "championPointsUntilNextLevel": 858,
278
+ "chestGranted": false,
279
+ "championLevel": 1,
280
+ "tokensEarned": 0,
281
+ "championId": 60,
282
+ "championPointsSinceLastLevel": 942,
283
+ "lastPlayTime": 1444367620000
284
+ },
285
+ {
286
+ "highestGrade": "A+",
287
+ "championPoints": 933,
288
+ "playerId": 496402,
289
+ "championPointsUntilNextLevel": 867,
290
+ "chestGranted": false,
291
+ "championLevel": 1,
292
+ "tokensEarned": 0,
293
+ "championId": 64,
294
+ "championPointsSinceLastLevel": 933,
295
+ "lastPlayTime": 1464414045000
296
+ },
297
+ {
298
+ "championPoints": 930,
299
+ "playerId": 496402,
300
+ "championPointsUntilNextLevel": 870,
301
+ "chestGranted": false,
302
+ "championLevel": 1,
303
+ "tokensEarned": 0,
304
+ "championId": 42,
305
+ "championPointsSinceLastLevel": 930,
306
+ "lastPlayTime": 1437273197000
307
+ },
308
+ {
309
+ "highestGrade": "C-",
310
+ "championPoints": 353,
311
+ "playerId": 496402,
312
+ "championPointsUntilNextLevel": 1447,
313
+ "chestGranted": false,
314
+ "championLevel": 1,
315
+ "tokensEarned": 0,
316
+ "championId": 89,
317
+ "championPointsSinceLastLevel": 353,
318
+ "lastPlayTime": 1463110408000
319
+ },
320
+ {
321
+ "highestGrade": "S-",
322
+ "championPoints": 284,
323
+ "playerId": 496402,
324
+ "championPointsUntilNextLevel": 1516,
325
+ "chestGranted": true,
326
+ "championLevel": 1,
327
+ "tokensEarned": 0,
328
+ "championId": 83,
329
+ "championPointsSinceLastLevel": 284,
330
+ "lastPlayTime": 1462686606000
331
+ },
332
+ {
333
+ "highestGrade": "B",
334
+ "championPoints": 229,
335
+ "playerId": 496402,
336
+ "championPointsUntilNextLevel": 1571,
337
+ "chestGranted": false,
338
+ "championLevel": 1,
339
+ "tokensEarned": 0,
340
+ "championId": 238,
341
+ "championPointsSinceLastLevel": 229,
342
+ "lastPlayTime": 1462691429000
343
+ },
344
+ {
345
+ "highestGrade": "B",
346
+ "championPoints": 219,
347
+ "playerId": 496402,
348
+ "championPointsUntilNextLevel": 1581,
349
+ "chestGranted": false,
350
+ "championLevel": 1,
351
+ "tokensEarned": 0,
352
+ "championId": 21,
353
+ "championPointsSinceLastLevel": 219,
354
+ "lastPlayTime": 1462515262000
355
+ },
356
+ {
357
+ "highestGrade": "A-",
358
+ "championPoints": 204,
359
+ "playerId": 496402,
360
+ "championPointsUntilNextLevel": 1596,
361
+ "chestGranted": false,
362
+ "championLevel": 1,
363
+ "tokensEarned": 0,
364
+ "championId": 420,
365
+ "championPointsSinceLastLevel": 204,
366
+ "lastPlayTime": 1462166929000
367
+ },
368
+ {
369
+ "championPoints": 199,
370
+ "playerId": 496402,
371
+ "championPointsUntilNextLevel": 1601,
372
+ "chestGranted": false,
373
+ "championLevel": 1,
374
+ "tokensEarned": 0,
375
+ "championId": 133,
376
+ "championPointsSinceLastLevel": 199,
377
+ "lastPlayTime": 1436418634000
378
+ },
379
+ {
380
+ "highestGrade": "A",
381
+ "championPoints": 181,
382
+ "playerId": 496402,
383
+ "championPointsUntilNextLevel": 1619,
384
+ "chestGranted": false,
385
+ "championLevel": 1,
386
+ "tokensEarned": 0,
387
+ "championId": 99,
388
+ "championPointsSinceLastLevel": 181,
389
+ "lastPlayTime": 1463978449000
390
+ },
391
+ {
392
+ "championPoints": 176,
393
+ "playerId": 496402,
394
+ "championPointsUntilNextLevel": 1624,
395
+ "chestGranted": false,
396
+ "championLevel": 1,
397
+ "tokensEarned": 0,
398
+ "championId": 76,
399
+ "championPointsSinceLastLevel": 176,
400
+ "lastPlayTime": 1444598939000
401
+ },
402
+ {
403
+ "highestGrade": "B-",
404
+ "championPoints": 174,
405
+ "playerId": 496402,
406
+ "championPointsUntilNextLevel": 1626,
407
+ "chestGranted": false,
408
+ "championLevel": 1,
409
+ "tokensEarned": 0,
410
+ "championId": 122,
411
+ "championPointsSinceLastLevel": 174,
412
+ "lastPlayTime": 1462162936000
413
+ },
414
+ {
415
+ "championPoints": 161,
416
+ "playerId": 496402,
417
+ "championPointsUntilNextLevel": 1639,
418
+ "chestGranted": false,
419
+ "championLevel": 1,
420
+ "tokensEarned": 0,
421
+ "championId": 18,
422
+ "championPointsSinceLastLevel": 161,
423
+ "lastPlayTime": 1437161890000
424
+ },
425
+ {
426
+ "highestGrade": "C",
427
+ "championPoints": 159,
428
+ "playerId": 496402,
429
+ "championPointsUntilNextLevel": 1641,
430
+ "chestGranted": false,
431
+ "championLevel": 1,
432
+ "tokensEarned": 0,
433
+ "championId": 202,
434
+ "championPointsSinceLastLevel": 159,
435
+ "lastPlayTime": 1462603951000
436
+ },
437
+ {
438
+ "championPoints": 158,
439
+ "playerId": 496402,
440
+ "championPointsUntilNextLevel": 1642,
441
+ "chestGranted": false,
442
+ "championLevel": 1,
443
+ "tokensEarned": 0,
444
+ "championId": 222,
445
+ "championPointsSinceLastLevel": 158,
446
+ "lastPlayTime": 1431475624000
447
+ },
448
+ {
449
+ "highestGrade": "B-",
450
+ "championPoints": 124,
451
+ "playerId": 496402,
452
+ "championPointsUntilNextLevel": 1676,
453
+ "chestGranted": false,
454
+ "championLevel": 1,
455
+ "tokensEarned": 0,
456
+ "championId": 5,
457
+ "championPointsSinceLastLevel": 124,
458
+ "lastPlayTime": 1464547676000
459
+ }
460
+ ]
@@ -0,0 +1,121 @@
1
+ [
2
+ {
3
+ "highestGrade": "S+",
4
+ "championPoints": 34356,
5
+ "playerId": 496402,
6
+ "championPointsUntilNextLevel": 0,
7
+ "chestGranted": true,
8
+ "championLevel": 5,
9
+ "tokensEarned": 2,
10
+ "championId": 40,
11
+ "championPointsSinceLastLevel": 12756,
12
+ "lastPlayTime": 1464499894000
13
+ },
14
+ {
15
+ "highestGrade": "A-",
16
+ "championPoints": 8972,
17
+ "playerId": 496402,
18
+ "championPointsUntilNextLevel": 3628,
19
+ "chestGranted": false,
20
+ "championLevel": 3,
21
+ "tokensEarned": 0,
22
+ "championId": 429,
23
+ "championPointsSinceLastLevel": 2972,
24
+ "lastPlayTime": 1463373502000
25
+ },
26
+ {
27
+ "highestGrade": "A-",
28
+ "championPoints": 7355,
29
+ "playerId": 496402,
30
+ "championPointsUntilNextLevel": 5245,
31
+ "chestGranted": false,
32
+ "championLevel": 3,
33
+ "tokensEarned": 0,
34
+ "championId": 15,
35
+ "championPointsSinceLastLevel": 1355,
36
+ "lastPlayTime": 1462509127000
37
+ },
38
+ {
39
+ "highestGrade": "A+",
40
+ "championPoints": 6581,
41
+ "playerId": 496402,
42
+ "championPointsUntilNextLevel": 6019,
43
+ "chestGranted": true,
44
+ "championLevel": 3,
45
+ "tokensEarned": 0,
46
+ "championId": 236,
47
+ "championPointsSinceLastLevel": 581,
48
+ "lastPlayTime": 1463462873000
49
+ },
50
+ {
51
+ "highestGrade": "S+",
52
+ "championPoints": 6555,
53
+ "playerId": 496402,
54
+ "championPointsUntilNextLevel": 6045,
55
+ "chestGranted": false,
56
+ "championLevel": 3,
57
+ "tokensEarned": 0,
58
+ "championId": 267,
59
+ "championPointsSinceLastLevel": 555,
60
+ "lastPlayTime": 1463983471000
61
+ },
62
+ {
63
+ "highestGrade": "A+",
64
+ "championPoints": 4478,
65
+ "playerId": 496402,
66
+ "championPointsUntilNextLevel": 1522,
67
+ "chestGranted": false,
68
+ "championLevel": 2,
69
+ "tokensEarned": 0,
70
+ "championId": 56,
71
+ "championPointsSinceLastLevel": 2678,
72
+ "lastPlayTime": 1463723059000
73
+ },
74
+ {
75
+ "highestGrade": "A+",
76
+ "championPoints": 4285,
77
+ "playerId": 496402,
78
+ "championPointsUntilNextLevel": 1715,
79
+ "chestGranted": false,
80
+ "championLevel": 2,
81
+ "tokensEarned": 0,
82
+ "championId": 245,
83
+ "championPointsSinceLastLevel": 2485,
84
+ "lastPlayTime": 1462688704000
85
+ },
86
+ {
87
+ "championPoints": 3162,
88
+ "playerId": 496402,
89
+ "championPointsUntilNextLevel": 2838,
90
+ "chestGranted": false,
91
+ "championLevel": 2,
92
+ "tokensEarned": 0,
93
+ "championId": 67,
94
+ "championPointsSinceLastLevel": 1362,
95
+ "lastPlayTime": 1437768811000
96
+ },
97
+ {
98
+ "highestGrade": "S",
99
+ "championPoints": 2686,
100
+ "playerId": 496402,
101
+ "championPointsUntilNextLevel": 3314,
102
+ "chestGranted": false,
103
+ "championLevel": 2,
104
+ "tokensEarned": 0,
105
+ "championId": 81,
106
+ "championPointsSinceLastLevel": 886,
107
+ "lastPlayTime": 1464415184000
108
+ },
109
+ {
110
+ "highestGrade": "S-",
111
+ "championPoints": 2589,
112
+ "playerId": 496402,
113
+ "championPointsUntilNextLevel": 3411,
114
+ "chestGranted": true,
115
+ "championLevel": 2,
116
+ "tokensEarned": 0,
117
+ "championId": 53,
118
+ "championPointsSinceLastLevel": 789,
119
+ "lastPlayTime": 1463114828000
120
+ }
121
+ ]
@@ -0,0 +1,38 @@
1
+ [
2
+ {
3
+ "highestGrade": "S+",
4
+ "championPoints": 34356,
5
+ "playerId": 496402,
6
+ "championPointsUntilNextLevel": 0,
7
+ "chestGranted": true,
8
+ "championLevel": 5,
9
+ "tokensEarned": 2,
10
+ "championId": 40,
11
+ "championPointsSinceLastLevel": 12756,
12
+ "lastPlayTime": 1464499894000
13
+ },
14
+ {
15
+ "highestGrade": "A-",
16
+ "championPoints": 8972,
17
+ "playerId": 496402,
18
+ "championPointsUntilNextLevel": 3628,
19
+ "chestGranted": false,
20
+ "championLevel": 3,
21
+ "tokensEarned": 0,
22
+ "championId": 429,
23
+ "championPointsSinceLastLevel": 2972,
24
+ "lastPlayTime": 1463373502000
25
+ },
26
+ {
27
+ "highestGrade": "A-",
28
+ "championPoints": 7355,
29
+ "playerId": 496402,
30
+ "championPointsUntilNextLevel": 5245,
31
+ "chestGranted": false,
32
+ "championLevel": 3,
33
+ "tokensEarned": 0,
34
+ "championId": 15,
35
+ "championPointsSinceLastLevel": 1355,
36
+ "lastPlayTime": 1462509127000
37
+ }
38
+ ]
@@ -0,0 +1,154 @@
1
+ require "spec_helper"
2
+ require "lol"
3
+ include Lol
4
+
5
+ describe ChampionMasteryRequest do
6
+ let(:request) { ChampionMasteryRequest.new("api_key", "euw") }
7
+
8
+ it "inherits from Request" do
9
+ expect(ChampionMasteryRequest.ancestors[1]).to eq(Request)
10
+ end
11
+
12
+ describe "#champion" do
13
+ it 'requires a player_id' do
14
+ expect { request.champion }.to raise_error ArgumentError
15
+ end
16
+
17
+ it 'requires a champion_id' do
18
+ expect { request.champion }.to raise_error ArgumentError
19
+ end
20
+
21
+ it 'raises an error when unexpected parameter is received' do
22
+ expect { request.champion '1', '1', asd: 'foo' }.to raise_error ArgumentError
23
+ end
24
+
25
+ context 'with summoner and champion' do
26
+ subject { request.champion(1, 40) }
27
+
28
+ let(:fixture) { load_fixture('champion-mastery-champion', ChampionMasteryRequest.api_version) }
29
+
30
+ before(:each) { stub_request(request, 'champion-mastery-champion', 'player/1/champion/40') }
31
+
32
+ it 'returns a ChampionMastery' do
33
+ expect(subject).to be_a ChampionMastery
34
+ end
35
+
36
+ it 'fetches ChampionStatistics from the API' do
37
+ expect(subject.highest_grade).to eq('S+')
38
+ expect(subject.champion_points).to eq(34356)
39
+ expect(subject.player_id).to eq(1)
40
+ expect(subject.champion_points_until_next_level).to eq(0)
41
+ expect(subject.chest_granted).to be(true)
42
+ expect(subject.champion_level).to eq(5)
43
+ expect(subject.tokens_earned).to eq(2)
44
+ expect(subject.champion_id).to eq(40)
45
+ expect(subject.champion_points_since_last_level).to eq(12756)
46
+ end
47
+ end
48
+ end
49
+
50
+ describe "#champions" do
51
+
52
+ it 'requires a player_id' do
53
+ expect { request.champion }.to raise_error ArgumentError
54
+ end
55
+
56
+ it 'raises an error when unexpected parameter is received' do
57
+ expect { request.champion '1', '1', asd: 'foo' }.to raise_error ArgumentError
58
+ end
59
+
60
+ context 'with summoner' do
61
+ subject { request.champions(1) }
62
+
63
+ let(:fixture) { load_fixture('champion-mastery-champions', ChampionMasteryRequest.api_version) }
64
+
65
+ before(:each) { stub_request(request, 'champion-mastery-champions', 'player/1/champions') }
66
+
67
+ it 'returns an Array' do
68
+ expect(subject).to be_a Array
69
+ end
70
+
71
+ it 'returns an array of ChampionMastery' do
72
+ expect(subject.map(&:class).uniq).to eq [ChampionMastery]
73
+ end
74
+
75
+ it 'fetches PlayerStatistics from the API' do
76
+ expect(subject.size).to eq(fixture.size)
77
+ end
78
+ end
79
+ end
80
+
81
+ describe "#score" do
82
+
83
+ it 'requires a player_id' do
84
+ expect { request.champion }.to raise_error ArgumentError
85
+ end
86
+
87
+ it 'raises an error when unexpected parameter is received' do
88
+ expect { request.champion '1', '1', asd: 'foo' }.to raise_error ArgumentError
89
+ end
90
+
91
+ context 'with summoner' do
92
+ subject { request.score(1) }
93
+
94
+ before(:each) { stub_request_raw(request, '60', 'player/1/score') }
95
+
96
+ it 'returns the score' do
97
+ expect(subject).to eq(60)
98
+ end
99
+ end
100
+ end
101
+
102
+ describe "#top_champions" do
103
+
104
+ it 'requires a player_id' do
105
+ expect { request.champion }.to raise_error ArgumentError
106
+ end
107
+
108
+ it 'raises an error when unexpected parameter is received' do
109
+ expect { request.champion '1', '1', asd: 'foo' }.to raise_error ArgumentError
110
+ end
111
+
112
+ context 'with summoner' do
113
+ context 'with count' do
114
+ subject { request.top_champions(1, count: 10) }
115
+
116
+ let(:fixture) { load_fixture('champion-mastery-top-champions-10', ChampionMasteryRequest.api_version) }
117
+
118
+ before(:each) { stub_request(request, 'champion-mastery-top-champions-10', 'player/1/topchampions', count: 10) }
119
+
120
+ it 'returns an Array' do
121
+ expect(subject).to be_a Array
122
+ end
123
+
124
+ it 'returns an array of ChampionMastery' do
125
+ expect(subject.map(&:class).uniq).to eq [ChampionMastery]
126
+ end
127
+
128
+ it 'fetches PlayerStatistics from the API' do
129
+ expect(subject.size).to eq(fixture.size)
130
+ end
131
+ end
132
+
133
+ context 'without count' do
134
+ subject { request.top_champions(1) }
135
+
136
+ let(:fixture) { load_fixture('champion-mastery-top-champions', ChampionMasteryRequest.api_version) }
137
+
138
+ before(:each) { stub_request(request, 'champion-mastery-top-champions', 'player/1/topchampions') }
139
+
140
+ it 'returns an Array' do
141
+ expect(subject).to be_a Array
142
+ end
143
+
144
+ it 'returns an array of ChampionMastery' do
145
+ expect(subject.map(&:class).uniq).to eq [ChampionMastery]
146
+ end
147
+
148
+ it 'fetches PlayerStatistics from the API' do
149
+ expect(subject.size).to eq(fixture.size)
150
+ end
151
+ end
152
+ end
153
+ end
154
+ end
@@ -0,0 +1,20 @@
1
+ require "spec_helper"
2
+ require "lol"
3
+
4
+ include Lol
5
+
6
+ describe ChampionMastery do
7
+ it_behaves_like 'Lol model' do
8
+ let(:valid_attributes) { { champion_id: 1 } }
9
+ end
10
+
11
+ %w(champion_id champion_level champion_points champion_points_since_last_level champion_points_until_next_level
12
+ chest_granted highest_grade last_play_time player_id tokens_earned).each do |attribute|
13
+ describe "#{attribute} attribute" do
14
+ it_behaves_like 'plain attribute' do
15
+ let(:attribute) { attribute }
16
+ let(:attribute_value) { 'asd' }
17
+ end
18
+ end
19
+ end
20
+ end
@@ -7,7 +7,7 @@ describe StatsRequest do
7
7
  let(:request) { StatsRequest.new("api_key", "euw") }
8
8
 
9
9
  it "inherits from Request" do
10
- expect(GameRequest.ancestors[1]).to eq(Request)
10
+ expect(StatsRequest.ancestors[1]).to eq(Request)
11
11
  end
12
12
 
13
13
  describe "#summary" do
@@ -53,4 +53,11 @@ module Helpers
53
53
 
54
54
  expect(request_class).to receive(:get).with(full_url).and_return(fixture_json)
55
55
  end
56
+
57
+ def stub_request_raw(request_object, raw_response, url, params={})
58
+ request_class = request_object.class
59
+ full_url = request_object.api_url(url, params)
60
+
61
+ expect(request_class).to receive(:get).with(full_url).and_return(raw_response)
62
+ end
56
63
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-lol
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.6
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Giovanni Intini
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-29 00:00:00.000000000 Z
11
+ date: 2016-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -275,6 +275,8 @@ files:
275
275
  - lib/lol.rb
276
276
  - lib/lol/autoloader.rb
277
277
  - lib/lol/champion.rb
278
+ - lib/lol/champion_mastery.rb
279
+ - lib/lol/champion_mastery_request.rb
278
280
  - lib/lol/champion_request.rb
279
281
  - lib/lol/champion_statistics_summary.rb
280
282
  - lib/lol/client.rb
@@ -316,6 +318,10 @@ files:
316
318
  - ruby-lol.gemspec
317
319
  - spec/acceptance_spec.rb
318
320
  - spec/api_version_spec.rb
321
+ - spec/fixtures/v1.0/get-champion-mastery-champion.json
322
+ - spec/fixtures/v1.0/get-champion-mastery-champions.json
323
+ - spec/fixtures/v1.0/get-champion-mastery-top-champions-10.json
324
+ - spec/fixtures/v1.0/get-champion-mastery-top-champions.json
319
325
  - spec/fixtures/v1.0/get-current-game.json
320
326
  - spec/fixtures/v1.0/get-featured-games.json
321
327
  - spec/fixtures/v1.0/get-lol-status-shard-by-region.json
@@ -353,6 +359,8 @@ files:
353
359
  - spec/fixtures/v2.5/get-league-entry.json
354
360
  - spec/fixtures/v2.5/get-league-master.json
355
361
  - spec/fixtures/v2.5/get-league.json
362
+ - spec/lol/champion_mastery_request_spec.rb
363
+ - spec/lol/champion_mastery_spec.rb
356
364
  - spec/lol/champion_request_spec.rb
357
365
  - spec/lol/champion_spec.rb
358
366
  - spec/lol/champion_statistics_summary_spec.rb
@@ -421,6 +429,10 @@ summary: Ruby wrapper to Riot Games API
421
429
  test_files:
422
430
  - spec/acceptance_spec.rb
423
431
  - spec/api_version_spec.rb
432
+ - spec/fixtures/v1.0/get-champion-mastery-champion.json
433
+ - spec/fixtures/v1.0/get-champion-mastery-champions.json
434
+ - spec/fixtures/v1.0/get-champion-mastery-top-champions-10.json
435
+ - spec/fixtures/v1.0/get-champion-mastery-top-champions.json
424
436
  - spec/fixtures/v1.0/get-current-game.json
425
437
  - spec/fixtures/v1.0/get-featured-games.json
426
438
  - spec/fixtures/v1.0/get-lol-status-shard-by-region.json
@@ -458,6 +470,8 @@ test_files:
458
470
  - spec/fixtures/v2.5/get-league-entry.json
459
471
  - spec/fixtures/v2.5/get-league-master.json
460
472
  - spec/fixtures/v2.5/get-league.json
473
+ - spec/lol/champion_mastery_request_spec.rb
474
+ - spec/lol/champion_mastery_spec.rb
461
475
  - spec/lol/champion_request_spec.rb
462
476
  - spec/lol/champion_spec.rb
463
477
  - spec/lol/champion_statistics_summary_spec.rb