| @@ 1-71 (lines=71) @@ | ||
| 1 | "use strict"; |
|
| 2 | Object.defineProperty(exports, "__esModule", { value: true }); |
|
| 3 | var utils_1 = require("./utils"); |
|
| 4 | var SummonerMastery = /** @class */ (function () { |
|
| 5 | function SummonerMastery(APIKEY, region, summonerId) { |
|
| 6 | this.summonerId = summonerId; |
|
| 7 | this.APIKEY = APIKEY; |
|
| 8 | this.region = region; |
|
| 9 | } |
|
| 10 | SummonerMastery.prototype.level = function (callback) { |
|
| 11 | var url = utils_1.getRegion(this.region) + "/lol/champion-mastery/v3/scores/by-summoner/" |
|
| 12 | + (this.summonerId + "?api_key=" + this.APIKEY); |
|
| 13 | utils_1.getJSON(url, function (res, err) { |
|
| 14 | if (err) { |
|
| 15 | callback(null, err); |
|
| 16 | } |
|
| 17 | else { |
|
| 18 | callback(res.data); |
|
| 19 | } |
|
| 20 | }); |
|
| 21 | }; |
|
| 22 | SummonerMastery.prototype.points = function (callback) { |
|
| 23 | var url = utils_1.getRegion(this.region) + "/lol/champion-mastery/v3/champion-masteries/by-summoner/" |
|
| 24 | + (this.summonerId + "?api_key=" + this.APIKEY); |
|
| 25 | utils_1.getJSON(url, function (res) { |
|
| 26 | var points = 0; |
|
| 27 | res.data.forEach(function (champion) { |
|
| 28 | points += champion.championPoints; |
|
| 29 | }); |
|
| 30 | callback(points); |
|
| 31 | }); |
|
| 32 | }; |
|
| 33 | SummonerMastery.prototype.top = function (amount, callback) { |
|
| 34 | if (amount === void 0) { amount = 0; } |
|
| 35 | var url = utils_1.getRegion(this.region) + "/lol/champion-mastery/v3/champion-masteries/by-summoner/" |
|
| 36 | + (this.summonerId + "?api_key=" + this.APIKEY); |
|
| 37 | utils_1.getJSON(url, function (res) { |
|
| 38 | var slice = amount === 0 ? res.data.length : amount; |
|
| 39 | callback(res.data.slice(0, slice)); |
|
| 40 | }); |
|
| 41 | }; |
|
| 42 | SummonerMastery.prototype.champion = function (champion, callback) { |
|
| 43 | if (Array.isArray(champion)) { |
|
| 44 | var url = utils_1.getRegion(this.region) + "/lol/champion-mastery/v3/champion-masteries/by-summoner/" |
|
| 45 | + (this.summonerId + "?api_key=" + this.APIKEY); |
|
| 46 | var returner_1 = []; |
|
| 47 | utils_1.getJSON(url, function (res) { |
|
| 48 | res.data.forEach(function (element) { |
|
| 49 | if (champion.indexOf(element.championId) !== -1) { |
|
| 50 | returner_1.push(element); |
|
| 51 | } |
|
| 52 | }); |
|
| 53 | callback(returner_1); |
|
| 54 | }); |
|
| 55 | } |
|
| 56 | else { |
|
| 57 | var url = utils_1.getRegion(this.region) + "/lol/champion-mastery/v3/champion-masteries/by-summoner/" |
|
| 58 | + (this.summonerId + "/by-champion/" + champion + "?api_key=" + this.APIKEY); |
|
| 59 | utils_1.getJSON(url, function (res, err) { |
|
| 60 | if (err) { |
|
| 61 | callback(null, err); |
|
| 62 | } |
|
| 63 | else { |
|
| 64 | callback(res.data); |
|
| 65 | } |
|
| 66 | }); |
|
| 67 | } |
|
| 68 | }; |
|
| 69 | return SummonerMastery; |
|
| 70 | }()); |
|
| 71 | exports.SummonerMastery = SummonerMastery; |
|
| 72 | //# sourceMappingURL=mastery.js.map |
|
| @@ 1-69 (lines=69) @@ | ||
| 1 | import { getJSON, getRegion } from './utils'; |
|
| 2 | var SummonerMastery = /** @class */ (function () { |
|
| 3 | function SummonerMastery(APIKEY, region, summonerId) { |
|
| 4 | this.summonerId = summonerId; |
|
| 5 | this.APIKEY = APIKEY; |
|
| 6 | this.region = region; |
|
| 7 | } |
|
| 8 | SummonerMastery.prototype.level = function (callback) { |
|
| 9 | var url = getRegion(this.region) + "/lol/champion-mastery/v3/scores/by-summoner/" |
|
| 10 | + (this.summonerId + "?api_key=" + this.APIKEY); |
|
| 11 | getJSON(url, function (res, err) { |
|
| 12 | if (err) { |
|
| 13 | callback(null, err); |
|
| 14 | } |
|
| 15 | else { |
|
| 16 | callback(res.data); |
|
| 17 | } |
|
| 18 | }); |
|
| 19 | }; |
|
| 20 | SummonerMastery.prototype.points = function (callback) { |
|
| 21 | var url = getRegion(this.region) + "/lol/champion-mastery/v3/champion-masteries/by-summoner/" |
|
| 22 | + (this.summonerId + "?api_key=" + this.APIKEY); |
|
| 23 | getJSON(url, function (res) { |
|
| 24 | var points = 0; |
|
| 25 | res.data.forEach(function (champion) { |
|
| 26 | points += champion.championPoints; |
|
| 27 | }); |
|
| 28 | callback(points); |
|
| 29 | }); |
|
| 30 | }; |
|
| 31 | SummonerMastery.prototype.top = function (amount, callback) { |
|
| 32 | if (amount === void 0) { amount = 0; } |
|
| 33 | var url = getRegion(this.region) + "/lol/champion-mastery/v3/champion-masteries/by-summoner/" |
|
| 34 | + (this.summonerId + "?api_key=" + this.APIKEY); |
|
| 35 | getJSON(url, function (res) { |
|
| 36 | var slice = amount === 0 ? res.data.length : amount; |
|
| 37 | callback(res.data.slice(0, slice)); |
|
| 38 | }); |
|
| 39 | }; |
|
| 40 | SummonerMastery.prototype.champion = function (champion, callback) { |
|
| 41 | if (Array.isArray(champion)) { |
|
| 42 | var url = getRegion(this.region) + "/lol/champion-mastery/v3/champion-masteries/by-summoner/" |
|
| 43 | + (this.summonerId + "?api_key=" + this.APIKEY); |
|
| 44 | var returner_1 = []; |
|
| 45 | getJSON(url, function (res) { |
|
| 46 | res.data.forEach(function (element) { |
|
| 47 | if (champion.indexOf(element.championId) !== -1) { |
|
| 48 | returner_1.push(element); |
|
| 49 | } |
|
| 50 | }); |
|
| 51 | callback(returner_1); |
|
| 52 | }); |
|
| 53 | } |
|
| 54 | else { |
|
| 55 | var url = getRegion(this.region) + "/lol/champion-mastery/v3/champion-masteries/by-summoner/" |
|
| 56 | + (this.summonerId + "/by-champion/" + champion + "?api_key=" + this.APIKEY); |
|
| 57 | getJSON(url, function (res, err) { |
|
| 58 | if (err) { |
|
| 59 | callback(null, err); |
|
| 60 | } |
|
| 61 | else { |
|
| 62 | callback(res.data); |
|
| 63 | } |
|
| 64 | }); |
|
| 65 | } |
|
| 66 | }; |
|
| 67 | return SummonerMastery; |
|
| 68 | }()); |
|
| 69 | export { SummonerMastery }; |
|
| 70 | //# sourceMappingURL=mastery.js.map |
|