kindred-api
Advanced tools
Comparing version 1.1.7 to 1.1.8
@@ -80,2 +80,7 @@ (function (global, factory) { | ||
var limits = { | ||
'DEV': [[10, 10], [500, 600]], | ||
'PROD': [[3000, 10], [180000, 600]] | ||
}; | ||
var platformIds = { | ||
@@ -185,3 +190,3 @@ BRAZIL: 'BR1', | ||
debug = _ref$debug === undefined ? false : _ref$debug, | ||
limits = _ref.limits; | ||
limits$$1 = _ref.limits; | ||
@@ -231,4 +236,4 @@ _classCallCheck(this, Kindred$1); | ||
if (limits) { | ||
var invalid = (Array.isArray(limits) && limits.length !== 2 || !checkAll.int(limits[0]) || limits[0].length !== 2 || !checkAll.int(limits[1]) || limits[1].length !== 2) && limits !== 'dev' && limits !== 'prod'; | ||
if (limits$$1) { | ||
var invalid = (Array.isArray(limits$$1) && limits$$1.length !== 2 || !checkAll.int(limits$$1[0]) || limits$$1[0].length !== 2 || !checkAll.int(limits$$1[1]) || limits$$1[1].length !== 2) && limits$$1 !== 'dev' && limits$$1 !== 'prod'; | ||
@@ -244,4 +249,4 @@ if (invalid) { | ||
if (limits === 'dev') limits = [[10, 10], [500, 600]]; | ||
if (limits === 'prod') limits = [[3000, 10], [180000, 600]]; | ||
if (limits$$1 === 'dev') limits$$1 = limits.DEV; | ||
if (limits$$1 === 'prod') limits$$1 = limits.PROD; | ||
@@ -256,3 +261,3 @@ var _iteratorNormalCompletion2 = true; | ||
this.limits[regions[region]] = [new RateLimit(limits[0][0], limits[0][1]), new RateLimit(limits[1][0], limits[1][1])]; | ||
this.limits[regions[region]] = [new RateLimit(limits$$1[0][0], limits$$1[0][1]), new RateLimit(limits$$1[1][0], limits$$1[1][1])]; | ||
} | ||
@@ -274,2 +279,7 @@ } catch (err) { | ||
} | ||
this.champion = { | ||
getChampions: this.getChamps.bind(this), | ||
getChampion: this.getChamp.bind(this) | ||
}; | ||
} | ||
@@ -485,3 +495,3 @@ | ||
return this._baseRequest({ | ||
endUrl: 'championmastery/location/' + endUrl, options: options, | ||
endUrl: 'championmastery/location/' + endUrl, region: region, options: options, | ||
championMastery: true | ||
@@ -614,6 +624,9 @@ }, cb); | ||
key: 'getChamps', | ||
value: function getChamps(_ref16, cb) { | ||
var region = _ref16.region, | ||
value: function getChamps() { | ||
var _ref16 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, | ||
region = _ref16.region, | ||
options = _ref16.options; | ||
var cb = arguments[1]; | ||
return this._championRequest({ | ||
@@ -625,7 +638,10 @@ endUrl: 'champion', region: region, options: options | ||
key: 'getChamp', | ||
value: function getChamp(_ref17, cb) { | ||
var region = _ref17.region, | ||
value: function getChamp() { | ||
var _ref17 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, | ||
region = _ref17.region, | ||
id = _ref17.id, | ||
championID = _ref17.championID; | ||
var cb = arguments[1]; | ||
if (Number.isInteger(id) || Number.isInteger(championID)) { | ||
@@ -1625,3 +1641,4 @@ return this._championRequest({ | ||
Kindred: Kindred$1, | ||
REGIONS: regions | ||
REGIONS: regions, | ||
LIMITS: limits | ||
}; | ||
@@ -1628,0 +1645,0 @@ |
@@ -1,1 +0,1 @@ | ||
!function(e,r){if("function"==typeof define&&define.amd)define("kindred-api",["module","double-ended-queue","request","chalk","xregexp","query-string"],r);else if("undefined"!=typeof exports)r(module,require("double-ended-queue"),require("request"),require("chalk"),require("xregexp"),require("query-string"));else{var t={exports:{}};r(t,e.doubleEndedQueue,e.request,e.chalk,e.xregexp,e.queryString),e.kindredApi=t.exports}}(this,function(e,r,t,n,i,o){"use strict";function s(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}var a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},u=function(){function e(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(r,t,n){return t&&e(r.prototype,t),n&&e(r,n),r}}(),l=function(){function e(t,n){s(this,e),this.allowedRequests=t,this.seconds=n,this.madeRequests=new r}return u(e,[{key:"__reload",value:function(){for(var e=(new Date).getTime();this.madeRequests.length>0&&e-this.madeRequests.peekFront()>=1e3*this.seconds;)this.madeRequests.shift()}},{key:"addRequest",value:function(){this.madeRequests.push((new Date).getTime()+1e3*this.seconds)}},{key:"requestAvailable",value:function(){return this.__reload(),this.madeRequests.length<this.allowedRequests}}]),e}(),m={BRAZIL:"BR1",EUROPE:"EUN1",EUROPE_WEST:"EUW1",KOREA:"KR",LATIN_AMERICA_NORTH:"LA1",LATIN_AMERICA_SOUTH:"LA2",NORTH_AMERICA:"NA1",OCEANIA:"OC1",RUSSIA:"RU",TURKEY:"TR1",JAPAN:"JP1"},g={BRAZIL:"br",EUROPE:"eune",EUROPE_WEST:"euw",KOREA:"kr",LATIN_AMERICA_NORTH:"lan",LATIN_AMERICA_SOUTH:"las",NORTH_AMERICA:"na",OCEANIA:"oce",RUSSIA:"ru",TURKEY:"tr",JAPAN:"jp"},d={br:"BRAZIL",eune:"EUROPE",euw:"EUROPE_WEST",kr:"KOREA",lan:"LATIN_AMERICA_NORTH",las:"LATIN_AMERICA_SOUTH",na:"NORTH_AMERICA",oce:"OCEANIA",ru:"RUSSIA",tr:"TURKEY",jp:"JAPAN"},h={CHAMPION:1.2,CURRENT_GAME:1,FEATURED_GAMES:1,GAME:1.3,LEAGUE:2.5,STATIC_DATA:1.2,STATUS:1,MATCH:2.2,MATCH_LIST:2.2,RUNES_MASTERIES:1.4,STATS:1.3,SUMMONER:1.4},p={int:function(e){return e.every(function(e){return Number.isInteger(e)})},string:function(e){return e.every(function(e){return"string"==typeof e})}},y={int:function(e){return e&&Array.isArray(e)&&p.int(e)&&e.length>0},string:function(e){return e&&Array.isArray(e)&&p.string(e)&&e.length>0}},c={400:"Bad Request",403:"Forbidden",404:"Not Found",415:"Unsupported Media Type",429:"Rate Limit Exceeded",500:"Internal Service Error",503:"Service Unavailable"},v=function(e){var r=c[e];if(r)return r},f=i("^[0-9\\p{L} _\\.]+$"),I=function(){function e(r){var t=r.key,i=r.defaultRegion,o=void 0===i?g.NORTH_AMERICA:i,a=r.debug,u=void 0!==a&&a,m=r.limits;s(this,e),this.key=t;var d=void 0,h=!0,p=!1,c=void 0;try{for(var v,f=Object.keys(g)[Symbol.iterator]();!(h=(v=f.next()).done);h=!0){var I=v.value;g[I]===o&&(d=!0)}}catch(e){p=!0,c=e}finally{try{!h&&f.return&&f.return()}finally{if(p)throw c}}if(this.defaultRegion=d?o:void 0,this.defaultRegion||(console.log(""+n.red("Initialization of Kindred failed: "+n.yellow(o)+" is an invalid region.")),console.log(""+n.red("Try importing "+n.yellow("require('./dist/kindred-api').REGIONS")+" and using one of those values instead.")),process.exit(1)),this.debug=u,m){(Array.isArray(m)&&2!==m.length||!y.int(m[0])||2!==m[0].length||!y.int(m[1])||2!==m[1].length)&&"dev"!==m&&"prod"!==m&&(console.log(n.red("Initialization of Kindred failed: Invalid "+n.yellow("limits")+". Valid examples: "+n.yellow("[[10, 10], [500, 600]]"))+"."),console.log(n.red("You can also pass in one of these two strings:")+" dev/prod "),console.log(""+n.red("and Kindred will set the limits appropriately.")),process.exit(1)),this.limits={},"dev"===m&&(m=[[10,10],[500,600]]),"prod"===m&&(m=[[3e3,10],[18e4,600]]);var R=!0,_=!1,q=void 0;try{for(var U,D=Object.keys(g)[Symbol.iterator]();!(R=(U=D.next()).done);R=!0){var b=U.value;this.limits[g[b]]=[new l(m[0][0],m[0][1]),new l(m[1][0],m[1][1])]}}catch(e){_=!0,q=e}finally{try{!R&&D.return&&D.return()}finally{if(_)throw q}}}}return u(e,[{key:"canMakeRequest",value:function(e){return!(!this.limits[e][0].requestAvailable()||!this.limits[e][1].requestAvailable())}},{key:"_sanitizeName",value:function(e){if(this._validName(e))return e.replace(/\s/g,"").toLowerCase();this._logError(this._validName.name,"Name "+n.yellow(e)+" is not valid. Request failed."),process.exit(1)}},{key:"_validName",value:function(e){return f.test(e)}},{key:"_makeUrl",value:function(e,r,t,n,i,o){var s=t?"":r+"/",a=n||i||o?"":"api/lol/"+s,u="https://"+r+".api.riotgames.com/"+a+encodeURI(e);return u+=u.lastIndexOf("?")===-1?"?":"&",u+="api_key="+this.key}},{key:"_baseRequest",value:function(e,r){var i=this,s=e.endUrl,a=e.region,u=void 0===a?this.defaultRegion:a,l=e.status,m=void 0!==l&&l,g=e.observerMode,d=void 0!==g&&g,h=e.staticReq,p=void 0!==h&&h,y=e.championMastery,c=void 0!==y&&y,f=e.options,I=void 0===f?{}:f,R=function(){return new Promise(function(e,a){var l=p?"global":u,g=o.stringify(I),h=g?"?"+g:"",y=i._makeUrl(s+h,l,p,m,d,c);if(i.limits){var f=i;!function r(i){f.canMakeRequest(u)?(p||(f.limits[u][0].addRequest(),f.limits[u][1].addRequest()),t({url:y},function(t,o,s){if(o&&s){var u=void 0,l=o.statusCode;if(l>=200&&l<300?u=n.green(l):l>=400&&l<500?u=n.red(l+" "+v(l)):l>=500&&(u=n.bold.red(l+" "+v(l))),f.debug&&(console.log(u,y),console.log({"x-app-rate-limit-count":o.headers["x-app-rate-limit-count"],"x-method-rate-limit-count":o.headers["x-method-rate-limit-count"],"x-rate-limit-count":o.headers["x-rate-limit-count"],"retry-after":o.headers["retry-after"]}),console.log()),i)return l>=500&&(f.debug&&console.log("!!! resending request !!!"),setTimeout(function(){r.bind(f)(i)},1e3)),429===l&&(f.debug&&console.log("!!! resending request !!!"),setTimeout(function(){r.bind(f)(i)},1e3*o.headers["retry-after"]+50)),l>=400?i(u+" : "+n.yellow(y)):i(t,JSON.parse(s));if(500===l)f.debug&&console.log("!!! resending promise request !!!"),setTimeout(function(){return a("retry")},1e3);else{if(429!==l)return t||l>=400?a("err:",t,l):e(JSON.parse(s));f.debug&&console.log("!!! resending promise request !!!"),setTimeout(function(){return a("retry")},1e3*o.headers["retry-after"]+50)}}else console.log(t,y)})):setTimeout(function(){r.bind(f)(i)},1e3)}(r)}else t({url:y},function(t,o,s){if(o){var u=void 0,l=o.statusCode;return l>=200&&l<300?u=n.green(l):l>=400&&l<500?u=n.red(l+" "+v(l)):l>=500&&(u=n.bold.red(l+" "+v(l))),i.debug&&(console.log(o&&u,y),console.log({"x-app-rate-limit-count":o.headers["x-app-rate-limit-count"],"x-method-rate-limit-count":o.headers["x-method-rate-limit-count"],"x-rate-limit-count":o.headers["x-rate-limit-count"],"retry-after":o.headers["retry-after"]})),r?l>=400?r(u+" : "+n.yellow(y)):r(t,JSON.parse(s)):t?a("err:",t):e(JSON.parse(s))}console.log(t,y)})})};return r?R():R().catch(R).catch(R).catch(R).then(function(e){return e})}},{key:"_observerRequest",value:function(e,r){var t=e.endUrl,n=e.region;return this._baseRequest({endUrl:"observer-mode/rest/"+t,observerMode:!0,region:n},r)}},{key:"_championRequest",value:function(e,r){var t=e.endUrl,n=e.region,i=e.options;return this._baseRequest({endUrl:"v"+h.CHAMPION+"/"+t,region:n,options:i},r)}},{key:"_championMasteryRequest",value:function(e,r){var t=e.endUrl,n=(e.region,e.options);return this._baseRequest({endUrl:"championmastery/location/"+t,options:n,championMastery:!0},r)}},{key:"_currentGameRequest",value:function(e,r){var t=e.endUrl,n=e.region,i=e.platformId;return this._observerRequest({endUrl:"consumer/getSpectatorGameInfo/"+i+"/"+t,region:n},r)}},{key:"_staticRequest",value:function(e,r){var t=e.endUrl,n=e.region,i=void 0===n?this.defaultRegion:n,o=e.options;return this._baseRequest({endUrl:"static-data/"+i+"/v"+h.STATIC_DATA+"/"+t,staticReq:!0,region:i,options:o},r)}},{key:"_statusRequest",value:function(e,r){var t=e.endUrl,n=(e.region,e.options);return this._baseRequest({endUrl:"lol/status/v"+h.STATUS+"/"+t,status:!0,options:n},r)}},{key:"_gameRequest",value:function(e,r){var t=e.endUrl,n=e.region;return this._baseRequest({endUrl:"v"+h.GAME+"/game/"+t,region:n},r)}},{key:"_leagueRequest",value:function(e,r){var t=e.endUrl,n=e.region,i=e.options;return this._baseRequest({endUrl:"v"+h.LEAGUE+"/league/"+t,region:n,options:i},r)}},{key:"_matchRequest",value:function(e,r){var t=e.endUrl,n=e.region,i=e.options;return this._baseRequest({endUrl:"v"+h.MATCH+"/match/"+t,region:n,options:i},r)}},{key:"_matchListRequest",value:function(e,r){var t=e.endUrl,n=e.region,i=e.options;return this._baseRequest({endUrl:"v"+h.MATCH_LIST+"/matchlist/by-summoner/"+t,region:n,options:i},r)}},{key:"_runesMasteriesRequest",value:function(e,r){var t=e.endUrl,n=e.region;return this._summonerRequest({endUrl:t,region:n},r)}},{key:"_statsRequest",value:function(e,r){var t=e.endUrl,n=e.region,i=e.options;return this._baseRequest({endUrl:"v"+h.STATS+"/stats/by-summoner/"+t,region:n,options:i},r)}},{key:"_summonerRequest",value:function(e,r){var t=e.endUrl,n=e.region;return this._baseRequest({endUrl:"v"+h.SUMMONER+"/summoner/"+t,region:n},r)}},{key:"_logError",value:function(e,r){console.log(n.bold.yellow(e),n.red("request"),n.bold.red("FAILED")+n.red("; "+r))}},{key:"setRegion",value:function(e){this.defaultRegion=e}},{key:"getChamps",value:function(e,r){var t=e.region,n=e.options;return this._championRequest({endUrl:"champion",region:t,options:n},r=t||n?r:arguments[0])}},{key:"getChamp",value:function(e,r){var t=e.region,i=e.id,o=e.championID;return Number.isInteger(i)||Number.isInteger(o)?this._championRequest({endUrl:"champion/"+(i||o),region:t},r):this._logError(this.getChamp.name,"required params "+n.yellow("`id/championID` (int)")+" not passed in")}},{key:"getChampMastery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.region,t=void 0===r?this.defaultRegion:r,i=e.playerID,o=e.championID,s=e.options,a=arguments[1];if(Number.isInteger(i)&&Number.isInteger(o)){var u=m[d[t]];return this._championMasteryRequest({endUrl:u+"/player/"+i+"/champion/"+o,region:t,options:s},a)}return this._logError(this.getChampMastery.name,"required params "+n.yellow("`playerID` (int) AND `championID` (int)")+" not passed in")}},{key:"getChampMasteries",value:function(){var e=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=r.region,i=void 0===t?this.defaultRegion:t,o=r.id,s=r.summonerID,u=r.playerID,l=r.name,g=r.options,h=arguments[1];if(Number.isInteger(o||s||u)){var p=m[d[i]];return this._championMasteryRequest({endUrl:p+"/player/"+(o||s||u)+"/champions",region:i,options:g},h)}if("object"===a(arguments[0])&&"string"==typeof l){var y=m[d[i]];return this.getSummoner({name:l,region:i},function(r,t){return r?h(r):e._championMasteryRequest({endUrl:y+"/player/"+t[e._sanitizeName(l)].id+"/champions",region:i},h)})}return this._logError(this.getChampMasteries.name,"required params "+n.yellow("`id/summonerID/playerID` (int)")+" or "+n.yellow("`name` (str)")+" not passed in")}},{key:"getTotalChampMasteryScore",value:function(){var e=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=r.region,i=void 0===t?this.defaultRegion:t,o=r.id,s=r.summonerID,u=r.playerID,l=r.name,g=r.options,h=arguments[1];if(Number.isInteger(o||s||u)){var p=m[d[i]];return this._championMasteryRequest({endUrl:p+"/player/"+(o||s||u)+"/score",region:i,options:g},h)}if("object"===a(arguments[0])&&"string"==typeof l){var y=m[d[i]];return this.getSummoner({name:l,region:i},function(r,t){return r?h(r):e._championMasteryRequest({endUrl:y+"/player/"+t[e._sanitizeName(l)].id+"/score",region:i},h)})}return this._logError(this.getTotalChampMasteryScore.name,"required params "+n.yellow("`id/summonerID/playerID` (int)")+" or "+n.yellow("`name` (str)")+" not passed in")}},{key:"getTopChamps",value:function(){var e=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=r.region,i=void 0===t?this.defaultRegion:t,o=r.id,s=r.summonerID,u=r.playerID,l=r.name,g=r.options,h=arguments[1];if(Number.isInteger(o||s||u)){var p=m[d[i]];return this._championMasteryRequest({endUrl:p+"/player/"+(o||s||u)+"/topchampions",region:i,options:g},h)}if("object"===a(arguments[0])&&"string"==typeof l){var y=m[d[i]];return this.getSummoner({name:l,region:i},function(r,t){return r?h(r):e._championMasteryRequest({endUrl:y+"/player/"+t[e._sanitizeName(l)].id+"/topchampions",region:i},h)})}return this._logError(this.getTopChamps.name,"required params "+n.yellow("`id/summonerID/playerID` (int)")+" or "+n.yellow("`name` (str)")+" not passed in")}},{key:"getCurrentGame",value:function(){var e=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=r.region,i=void 0===t?this.defaultRegion:t,o=r.id,s=r.summonerID,u=r.playerID,l=r.name,g=arguments[1],h=m[d[i]];return Number.isInteger(o||s||u)?this._currentGameRequest({endUrl:""+(o||s||u),platformId:h,region:i},g):"object"===a(arguments[0])&&"string"==typeof l?this.getSummoner({name:l,region:i},function(r,t){return r?g(r):e._currentGameRequest({endUrl:""+t[e._sanitizeName(l)].id,platformId:h,region:i},g)}):this._logError(this.getCurrentGame.name,"required params "+n.yellow("`id/summonerID/playerID` (int)")+" or "+n.yellow("`name` (string)")+" not passed in")}},{key:"getFeaturedGames",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.region,t=arguments[1];return this._observerRequest({endUrl:"featured",region:r},t=r?t:arguments[0])}},{key:"getRecentGames",value:function(){var e=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=r.region,i=r.id,o=r.summonerID,s=r.playerID,u=r.name,l=arguments[1];return Number.isInteger(i||o||s)?this._gameRequest({endUrl:"by-summoner/"+(i||o||s)+"/recent",region:t},l):"object"===a(arguments[0])&&"string"==typeof u?this.getSummoner({name:u,region:t},function(r,n){return r?l(r):e._gameRequest({endUrl:"by-summoner/"+n[e._sanitizeName(u)].id+"/recent",region:t},l)}):this._logError(this.getRecentGames.name,"required params "+n.yellow("`id/summonerID/playerID` (int)")+" or "+n.yellow("`name` (string)")+" not passed in")}},{key:"getLeagues",value:function(){var e=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=r.region,i=r.ids,o=r.id,s=r.summonerIDs,u=r.summonerID,l=r.playerIDs,m=r.playerID,g=r.names,d=r.name,h=r.options,p=arguments[1];return y.int(i||s||l)?this._leagueRequest({endUrl:"by-summoner/"+(i||s||l).join(","),region:t,options:h},p):Number.isInteger(i||o||s||u||l||m)?this._leagueRequest({endUrl:"by-summoner/"+(i||o||s||u||l||m),region:t,options:h},p):y.string(g)?this.getSummoners({names:g,region:t},function(r,n){if(r)return p(r);var i=[],o=!0,s=!1,a=void 0;try{for(var u,l=g[Symbol.iterator]();!(o=(u=l.next()).done);o=!0){var m=u.value;i.push(n[e._sanitizeName(m)].id)}}catch(e){s=!0,a=e}finally{try{!o&&l.return&&l.return()}finally{if(s)throw a}}return e._leagueRequest({endUrl:"by-summoner/"+i.join(","),region:t,options:h},p)}):"object"!==a(arguments[0])||"string"!=typeof g&&"string"!=typeof d?this._logError(this.getLeagues.name,"required params "+n.yellow("`ids/summonerIDs/playerIDs` ([int]/int)")+", "+n.yellow("`id/summonerID/playerID` (int)")+", "+n.yellow("`names` ([str]/str)")+", or "+n.yellow("`name` (str)")+" not passed in"):this.getSummoner({name:g||d,region:t},function(r,n){return r?p(r):e._leagueRequest({endUrl:"by-summoner/"+n[e._sanitizeName(g||d)].id,region:t,options:h},p)})}},{key:"getLeagueEntries",value:function(){var e=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=r.region,i=r.ids,o=r.id,s=r.summonerIDs,u=r.summonerID,l=r.playerIDs,m=r.playerID,g=r.names,d=r.name,h=arguments[1];return y.int(i||s||l)?this._leagueRequest({endUrl:"by-summoner/"+(i||s||l).join(",")+"/entry",region:t},h):Number.isInteger(i||o||s||u||l||m)?this._leagueRequest({endUrl:"by-summoner/"+(i||o||s||u||l||m)+"/entry",region:t},h):y.string(g)?this.getSummoners({names:g,region:t},function(r,n){if(r)return h(r);var i=[],o=!0,s=!1,a=void 0;try{for(var u,l=g[Symbol.iterator]();!(o=(u=l.next()).done);o=!0){var m=u.value;i.push(n[e._sanitizeName(m)].id)}}catch(e){s=!0,a=e}finally{try{!o&&l.return&&l.return()}finally{if(s)throw a}}return e._leagueRequest({endUrl:"by-summoner/"+i.join(",")+"/entry",region:t},h)}):"object"!==a(arguments[0])||"string"!=typeof g&&"string"!=typeof d?void this._logError(this.getLeagueEntries.name,"required params "+n.yellow("`ids/summonerIDs/playerIDs` ([int]/int)")+", "+n.yellow("`id/summonerID/playerID` (int)")+", "+n.yellow("`names` ([str]/str)")+", or "+n.yellow("`name` (str)")+" not passed in"):this.getSummoner({name:g||d,region:t},function(r,n){return r?h(r):e._leagueRequest({endUrl:"by-summoner/"+n[e._sanitizeName(g||d)].id+"/entry",region:t},h)})}},{key:"getChallengers",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.region,t=e.options,n=void 0===t?{type:"RANKED_SOLO_5x5"}:t,i=arguments[1];return this._leagueRequest({endUrl:"challenger",region:r,options:n},i=r||n?i:arguments[0])}},{key:"getMasters",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.region,t=e.options,n=void 0===t?{type:"RANKED_SOLO_5x5"}:t,i=arguments[1];return this._leagueRequest({endUrl:"master",region:r,options:n},i=r||n?i:arguments[0])}},{key:"getChampionList",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.region,t=e.options,n=arguments[1];return this._staticRequest({endUrl:"champion",region:r,options:t},n=r||t?n:arguments[0])}},{key:"getChampion",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.region,t=e.id,i=e.championID,o=e.options,s=arguments[1];return Number.isInteger(t||i)?this._staticRequest({endUrl:"champion/"+(t||i),region:r,options:o},s):this._logError(this.getChampion.name,"required params "+n.yellow("`id/championID` (int)")+" not passed in")}},{key:"getItems",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.region,t=e.options,n=arguments[1];return this._staticRequest({endUrl:"item",region:r,options:t},n=r||t?n:arguments[0])}},{key:"getItem",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.region,t=e.id,i=e.itemID,o=e.options,s=arguments[1];return Number.isInteger(t||i)?this._staticRequest({endUrl:"item/"+(t||i),region:r,options:o},s):this._logError(this.getItem.name,"required params "+n.yellow("`id/itemID` (int)")+" not passed in")}},{key:"getLanguageStrings",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.region,t=e.options,n=arguments[1];return this._staticRequest({endUrl:"language-strings",region:r,options:t},n=r||t?n:arguments[0])}},{key:"getLanguages",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.region,t=arguments[1];return this._staticRequest({endUrl:"languages",region:r},t=r?t:arguments[0])}},{key:"getMap",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.region,t=e.options,n=arguments[1];return this._staticRequest({endUrl:"map",region:r,options:t},n=r||t?n:arguments[0])}},{key:"getMasteryList",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.region,t=e.options,n=arguments[1];return this._staticRequest({endUrl:"mastery",region:r,options:t},n=r||t?n:arguments[0])}},{key:"getMastery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.region,t=e.id,i=e.masteryID,o=e.options,s=arguments[1];return Number.isInteger(t||i)?this._staticRequest({endUrl:"mastery/"+(t||i),region:r,options:o},s):this._logError(this.getMastery.name,"required params "+n.yellow("`id/masteryID` (int)")+" not passed in")}},{key:"getRealmData",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.region,t=arguments[1];return this._staticRequest({endUrl:"realm",region:r},t=r?t:arguments[0])}},{key:"getRuneList",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.region,t=e.options,n=arguments[1];return this._staticRequest({endUrl:"rune",region:r,options:t},n=r||t?n:arguments[0])}},{key:"getRune",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.region,t=e.id,i=e.runeID,o=e.options,s=arguments[1];return Number.isInteger(t||i)?this._staticRequest({endUrl:"rune/"+(t||i),region:r,options:o},s):this._logError(this.getRune.name,"required params "+n.yellow("`id/runeID` (int)")+" not passed in")}},{key:"getSummonerSpells",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.region,t=e.options,n=arguments[1];return this._staticRequest({endUrl:"summoner-spell",region:r,options:t},n=r||t?n:arguments[0])}},{key:"getSummonerSpell",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.region,t=e.id,i=e.spellID,o=e.summonerSpellID,s=e.options,a=arguments[1];return Number.isInteger(t||i||o)?this._staticRequest({endUrl:"summoner-spell/"+(t||i||o),region:r,options:s},a):this._logError(this.getSummonerSpell.name,"required params "+n.yellow("`id/spellID/summonerSpellID` (int)")+" not passed in")}},{key:"getVersionData",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.region,t=e.options,n=arguments[1];return this._staticRequest({endUrl:"versions",region:r,options:t},n=r||t?n:arguments[0])}},{key:"getShardStatus",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.region,t=arguments[1];return this._statusRequest({endUrl:"shard",region:r},t=r?t:arguments[0])}},{key:"getShardList",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.region,t=arguments[1];return this._statusRequest({endUrl:"shards",region:r},t=r?t:arguments[0])}},{key:"getMatch",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.region,t=e.id,i=e.matchID,o=e.options,s=void 0===o?{includeTimeline:!0}:o,a=arguments[1];return Number.isInteger(t||i)?this._matchRequest({endUrl:""+(t||i),region:r,options:s},a):this._logError(this.getMatch.name,"required params "+n.yellow("`id/matchID` (int)")+" not passed in")}},{key:"getMatchList",value:function(){var e=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=r.region,i=r.id,o=r.summonerID,s=r.playerID,u=r.name,l=r.options,m=void 0===l?{rankedQueues:"RANKED_SOLO_5x5"}:l,g=arguments[1];return Number.isInteger(i||o||s)?this._matchListRequest({endUrl:""+(i||o||s),region:t,options:m},g):"object"===a(arguments[0])&&"string"==typeof u?this.getSummoner({name:u,region:t},function(r,n){return r?g(r):e._matchListRequest({endUrl:""+n[e._sanitizeName(u)].id,region:t,options:m},g)}):this._logError(this.getMatchList.name,"required params "+n.yellow("`id/summonerID/playerID` (int)")+" or "+n.yellow("`name` (str)")+" not passed in")}},{key:"getRunes",value:function(){var e=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=r.region,i=r.ids,o=r.id,s=r.summonerIDs,u=r.summonerID,l=r.playerIDs,m=r.playerID,g=r.names,d=r.name,h=arguments[1];return y.int(i||s||l)?this._runesMasteriesRequest({endUrl:(i||s||l).join()+"/runes",region:t},h):Number.isInteger(i||o||s||u||l||m)?this._runesMasteriesRequest({endUrl:(i||o||s||u||l||m)+"/runes",region:t},h):y.string(g)?this.getSummoners({names:g,region:t},function(r,n){if(r)return h(r);var i=[],o=!0,s=!1,a=void 0;try{for(var u,l=g[Symbol.iterator]();!(o=(u=l.next()).done);o=!0){var m=u.value;i.push(n[e._sanitizeName(m)].id)}}catch(e){s=!0,a=e}finally{try{!o&&l.return&&l.return()}finally{if(s)throw a}}return e._runesMasteriesRequest({endUrl:i.join(",")+"/runes",region:t},h)}):"object"!==a(arguments[0])||"string"!=typeof g&&"string"!=typeof d?this._logError(this.getRunes.name,"required params "+n.yellow("`ids/summonerIDs/playerIDs` ([int]/int)")+", "+n.yellow("`id/summonerID/playerID` (int)")+", "+n.yellow("`names` ([str]/str)")+", or "+n.yellow("`name` (str)")+" not passed in"):this.getSummoner({name:g||d,region:t},function(r,n){return r?h(r):e._runesMasteriesRequest({endUrl:n[e._sanitizeName(g||d)].id+"/runes",region:t},h)})}},{key:"getMasteries",value:function(){var e=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=r.region,i=r.ids,o=r.id,s=r.summonerIDs,u=r.summonerID,l=r.playerIDs,m=r.playerID,g=r.names,d=r.name,h=arguments[1];return y.int(i||s||l)?this._runesMasteriesRequest({endUrl:(i||s||l).join()+"/masteries",region:t},h):Number.isInteger(i||o||s||u||l||m)?this._runesMasteriesRequest({endUrl:(i||o||s||u||l||m)+"/masteries",region:t},h):y.string(g)?this.getSummoners({names:g,region:t},function(r,n){if(r)return h(r);var i=[],o=!0,s=!1,a=void 0;try{for(var u,l=g[Symbol.iterator]();!(o=(u=l.next()).done);o=!0){var m=u.value;i.push(n[e._sanitizeName(m)].id)}}catch(e){s=!0,a=e}finally{try{!o&&l.return&&l.return()}finally{if(s)throw a}}return e._runesMasteriesRequest({endUrl:i.join(",")+"/masteries",region:t},h)}):"object"!==a(arguments[0])||"string"!=typeof g&&"string"!=typeof d?this._logError(this.getMasteries.name,"required params "+n.yellow("`ids/summonerIDs/playerIDs` ([int]/int)")+", "+n.yellow("`id/summonerID/playerID` (int)")+", "+n.yellow("`names` ([str]/str)")+", or "+n.yellow("`name` (str)")+" not passed in"):this.getSummoner({name:g||d,region:t},function(r,n){return r?h(r):e._runesMasteriesRequest({endUrl:n[e._sanitizeName(g||d)].id+"/masteries",region:t},h)})}},{key:"getRankedStats",value:function(){var e=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=r.region,i=r.id,o=r.summonerID,s=r.playerID,u=r.name,l=r.options,m=arguments[1];return Number.isInteger(i||o||s)?this._statsRequest({endUrl:(i||o||s)+"/ranked",region:t,options:l},m):"object"===a(arguments[0])&&"string"==typeof u?this.getSummoner({name:u,region:t},function(r,n){return r?m(r):e._statsRequest({endUrl:n[e._sanitizeName(u)].id+"/ranked",region:t,options:l},m)}):void this._logError(this.getRankedStats.name,"required params "+n.yellow("`id/summonerID/playerID` (int)")+" or "+n.yellow("`name` (string)")+" not passed in")}},{key:"getStatsSummary",value:function(){var e=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=r.region,i=r.id,o=r.summonerID,s=r.playerID,u=r.name,l=r.options,m=arguments[1];return Number.isInteger(i||o||s)?this._statsRequest({endUrl:(i||o||s)+"/summary",region:t,options:l},m):"object"===a(arguments[0])&&"string"==typeof u?this.getSummoner({name:u,region:t},function(r,n){return r?m(r):e._statsRequest({endUrl:n[e._sanitizeName(u)].id+"/summary",region:t,options:l},m)}):void this._logError(this.getRankedStats.name,"required params "+n.yellow("`id/summonerID/playerID` (int)")+" or "+n.yellow("`name` (string)")+" not passed in")}},{key:"getSummoners",value:function(){var e=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=r.region,i=r.ids,o=r.id,s=r.summonerIDs,u=r.summonerID,l=r.playerIDs,m=r.playerID,g=r.names,d=r.name,h=arguments[1];return y.int(i||s||l)?this._summonerRequest({endUrl:""+(i||s||l).join(","),region:t},h):Number.isInteger(i||o||s||u||l||m)?this._summonerRequest({endUrl:""+(i||o||s||u||l||m),region:t},h):y.string(g)?this._summonerRequest({endUrl:"by-name/"+g.map(function(r){return e._sanitizeName(r)}).join(","),region:t},h):"object"!==a(arguments[0])||"string"!=typeof g&&"string"!=typeof d?void this._logError(this.getSummoners.name,"required params "+n.yellow("`ids/summonerIDs/playerIDs` ([int]/int)")+", "+n.yellow("`id/summonerID/playerID` (int)")+", "+n.yellow("`names` ([str]/str)")+", or "+n.yellow("`name` (str)")+" not passed in"):this._summonerRequest({endUrl:"by-name/"+this._sanitizeName(g||d),region:t},h)}},{key:"getSummoner",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.region,t=e.id,i=e.summonerID,o=e.playerID,s=e.name,u=arguments[1];return Number.isInteger(t||i||o)?this.getSummoners({region:r,ids:[t||i||o]},u):"object"===a(arguments[0])&&"string"==typeof s?this.getSummoners({region:r,names:[s]},u):this._logError(this.getSummoner.name,"required params "+n.yellow("`id/summonerID/playerID` (int)")+" or "+n.yellow("`name` (string)")+" not passed in")}},{key:"getSummonerNames",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.region,t=e.ids,i=e.id,o=e.summonerIDs,s=e.summonerID,a=e.playerIDs,u=e.playerID,l=arguments[1];return y.int(t||o||a)?this._summonerRequest({endUrl:(t||o||a).join(",")+"/name",region:r},l):Number.isInteger(t||i||o||s||a||u)?this._summonerRequest({endUrl:(t||i||o||s||a||u)+"/name",region:r},l):void this._logError(this.getSummonerNames.name,"required params "+n.yellow("required params `ids/summonerIDs/playerIDs` ([int]/int)")+" or "+n.yellow("`id/summonerID/playerID` (int)")+" not passed in")}},{key:"getSummonerName",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.region,t=e.id,i=e.summonerID,o=e.playerID,s=arguments[1];if(Number.isInteger(t))return this.getSummonerNames({region:r,id:t||i||o},s);this._logError(this.getSummonerName.name,"required params "+n.yellow("`id/summonerID/playerID` (int)")+" not passed in")}}]),e}(),R={Kindred:I,REGIONS:g};e.exports=R}); | ||
!function(e,r){if("function"==typeof define&&define.amd)define("kindred-api",["module","double-ended-queue","request","chalk","xregexp","query-string"],r);else if("undefined"!=typeof exports)r(module,require("double-ended-queue"),require("request"),require("chalk"),require("xregexp"),require("query-string"));else{var t={exports:{}};r(t,e.doubleEndedQueue,e.request,e.chalk,e.xregexp,e.queryString),e.kindredApi=t.exports}}(this,function(e,r,t,n,i,o){"use strict";function s(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}var a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},u=function(){function e(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(r,t,n){return t&&e(r.prototype,t),n&&e(r,n),r}}(),l=function(){function e(t,n){s(this,e),this.allowedRequests=t,this.seconds=n,this.madeRequests=new r}return u(e,[{key:"__reload",value:function(){for(var e=(new Date).getTime();this.madeRequests.length>0&&e-this.madeRequests.peekFront()>=1e3*this.seconds;)this.madeRequests.shift()}},{key:"addRequest",value:function(){this.madeRequests.push((new Date).getTime()+1e3*this.seconds)}},{key:"requestAvailable",value:function(){return this.__reload(),this.madeRequests.length<this.allowedRequests}}]),e}(),m={DEV:[[10,10],[500,600]],PROD:[[3e3,10],[18e4,600]]},g={BRAZIL:"BR1",EUROPE:"EUN1",EUROPE_WEST:"EUW1",KOREA:"KR",LATIN_AMERICA_NORTH:"LA1",LATIN_AMERICA_SOUTH:"LA2",NORTH_AMERICA:"NA1",OCEANIA:"OC1",RUSSIA:"RU",TURKEY:"TR1",JAPAN:"JP1"},d={BRAZIL:"br",EUROPE:"eune",EUROPE_WEST:"euw",KOREA:"kr",LATIN_AMERICA_NORTH:"lan",LATIN_AMERICA_SOUTH:"las",NORTH_AMERICA:"na",OCEANIA:"oce",RUSSIA:"ru",TURKEY:"tr",JAPAN:"jp"},h={br:"BRAZIL",eune:"EUROPE",euw:"EUROPE_WEST",kr:"KOREA",lan:"LATIN_AMERICA_NORTH",las:"LATIN_AMERICA_SOUTH",na:"NORTH_AMERICA",oce:"OCEANIA",ru:"RUSSIA",tr:"TURKEY",jp:"JAPAN"},p={CHAMPION:1.2,CURRENT_GAME:1,FEATURED_GAMES:1,GAME:1.3,LEAGUE:2.5,STATIC_DATA:1.2,STATUS:1,MATCH:2.2,MATCH_LIST:2.2,RUNES_MASTERIES:1.4,STATS:1.3,SUMMONER:1.4},y={int:function(e){return e.every(function(e){return Number.isInteger(e)})},string:function(e){return e.every(function(e){return"string"==typeof e})}},c={int:function(e){return e&&Array.isArray(e)&&y.int(e)&&e.length>0},string:function(e){return e&&Array.isArray(e)&&y.string(e)&&e.length>0}},v={400:"Bad Request",403:"Forbidden",404:"Not Found",415:"Unsupported Media Type",429:"Rate Limit Exceeded",500:"Internal Service Error",503:"Service Unavailable"},f=function(e){var r=v[e];if(r)return r},I=i("^[0-9\\p{L} _\\.]+$"),R=function(){function e(r){var t=r.key,i=r.defaultRegion,o=void 0===i?d.NORTH_AMERICA:i,a=r.debug,u=void 0!==a&&a,g=r.limits;s(this,e),this.key=t;var h=void 0,p=!0,y=!1,v=void 0;try{for(var f,I=Object.keys(d)[Symbol.iterator]();!(p=(f=I.next()).done);p=!0){var R=f.value;d[R]===o&&(h=!0)}}catch(e){y=!0,v=e}finally{try{!p&&I.return&&I.return()}finally{if(y)throw v}}if(this.defaultRegion=h?o:void 0,this.defaultRegion||(console.log(""+n.red("Initialization of Kindred failed: "+n.yellow(o)+" is an invalid region.")),console.log(""+n.red("Try importing "+n.yellow("require('./dist/kindred-api').REGIONS")+" and using one of those values instead.")),process.exit(1)),this.debug=u,g){(Array.isArray(g)&&2!==g.length||!c.int(g[0])||2!==g[0].length||!c.int(g[1])||2!==g[1].length)&&"dev"!==g&&"prod"!==g&&(console.log(n.red("Initialization of Kindred failed: Invalid "+n.yellow("limits")+". Valid examples: "+n.yellow("[[10, 10], [500, 600]]"))+"."),console.log(n.red("You can also pass in one of these two strings:")+" dev/prod "),console.log(""+n.red("and Kindred will set the limits appropriately.")),process.exit(1)),this.limits={},"dev"===g&&(g=m.DEV),"prod"===g&&(g=m.PROD);var _=!0,q=!1,D=void 0;try{for(var b,U=Object.keys(d)[Symbol.iterator]();!(_=(b=U.next()).done);_=!0){var S=b.value;this.limits[d[S]]=[new l(g[0][0],g[0][1]),new l(g[1][0],g[1][1])]}}catch(e){q=!0,D=e}finally{try{!_&&U.return&&U.return()}finally{if(q)throw D}}}this.champion={getChampions:this.getChamps.bind(this),getChampion:this.getChamp.bind(this)}}return u(e,[{key:"canMakeRequest",value:function(e){return!(!this.limits[e][0].requestAvailable()||!this.limits[e][1].requestAvailable())}},{key:"_sanitizeName",value:function(e){if(this._validName(e))return e.replace(/\s/g,"").toLowerCase();this._logError(this._validName.name,"Name "+n.yellow(e)+" is not valid. Request failed."),process.exit(1)}},{key:"_validName",value:function(e){return I.test(e)}},{key:"_makeUrl",value:function(e,r,t,n,i,o){var s=t?"":r+"/",a=n||i||o?"":"api/lol/"+s,u="https://"+r+".api.riotgames.com/"+a+encodeURI(e);return u+=u.lastIndexOf("?")===-1?"?":"&",u+="api_key="+this.key}},{key:"_baseRequest",value:function(e,r){var i=this,s=e.endUrl,a=e.region,u=void 0===a?this.defaultRegion:a,l=e.status,m=void 0!==l&&l,g=e.observerMode,d=void 0!==g&&g,h=e.staticReq,p=void 0!==h&&h,y=e.championMastery,c=void 0!==y&&y,v=e.options,I=void 0===v?{}:v,R=function(){return new Promise(function(e,a){var l=p?"global":u,g=o.stringify(I),h=g?"?"+g:"",y=i._makeUrl(s+h,l,p,m,d,c);if(i.limits){var v=i;!function r(i){v.canMakeRequest(u)?(p||(v.limits[u][0].addRequest(),v.limits[u][1].addRequest()),t({url:y},function(t,o,s){if(o&&s){var u=void 0,l=o.statusCode;if(l>=200&&l<300?u=n.green(l):l>=400&&l<500?u=n.red(l+" "+f(l)):l>=500&&(u=n.bold.red(l+" "+f(l))),v.debug&&(console.log(u,y),console.log({"x-app-rate-limit-count":o.headers["x-app-rate-limit-count"],"x-method-rate-limit-count":o.headers["x-method-rate-limit-count"],"x-rate-limit-count":o.headers["x-rate-limit-count"],"retry-after":o.headers["retry-after"]}),console.log()),i)return l>=500&&(v.debug&&console.log("!!! resending request !!!"),setTimeout(function(){r.bind(v)(i)},1e3)),429===l&&(v.debug&&console.log("!!! resending request !!!"),setTimeout(function(){r.bind(v)(i)},1e3*o.headers["retry-after"]+50)),l>=400?i(u+" : "+n.yellow(y)):i(t,JSON.parse(s));if(500===l)v.debug&&console.log("!!! resending promise request !!!"),setTimeout(function(){return a("retry")},1e3);else{if(429!==l)return t||l>=400?a("err:",t,l):e(JSON.parse(s));v.debug&&console.log("!!! resending promise request !!!"),setTimeout(function(){return a("retry")},1e3*o.headers["retry-after"]+50)}}else console.log(t,y)})):setTimeout(function(){r.bind(v)(i)},1e3)}(r)}else t({url:y},function(t,o,s){if(o){var u=void 0,l=o.statusCode;return l>=200&&l<300?u=n.green(l):l>=400&&l<500?u=n.red(l+" "+f(l)):l>=500&&(u=n.bold.red(l+" "+f(l))),i.debug&&(console.log(o&&u,y),console.log({"x-app-rate-limit-count":o.headers["x-app-rate-limit-count"],"x-method-rate-limit-count":o.headers["x-method-rate-limit-count"],"x-rate-limit-count":o.headers["x-rate-limit-count"],"retry-after":o.headers["retry-after"]})),r?l>=400?r(u+" : "+n.yellow(y)):r(t,JSON.parse(s)):t?a("err:",t):e(JSON.parse(s))}console.log(t,y)})})};return r?R():R().catch(R).catch(R).catch(R).then(function(e){return e})}},{key:"_observerRequest",value:function(e,r){var t=e.endUrl,n=e.region;return this._baseRequest({endUrl:"observer-mode/rest/"+t,observerMode:!0,region:n},r)}},{key:"_championRequest",value:function(e,r){var t=e.endUrl,n=e.region,i=e.options;return this._baseRequest({endUrl:"v"+p.CHAMPION+"/"+t,region:n,options:i},r)}},{key:"_championMasteryRequest",value:function(e,r){var t=e.endUrl,n=e.region,i=e.options;return this._baseRequest({endUrl:"championmastery/location/"+t,region:n,options:i,championMastery:!0},r)}},{key:"_currentGameRequest",value:function(e,r){var t=e.endUrl,n=e.region,i=e.platformId;return this._observerRequest({endUrl:"consumer/getSpectatorGameInfo/"+i+"/"+t,region:n},r)}},{key:"_staticRequest",value:function(e,r){var t=e.endUrl,n=e.region,i=void 0===n?this.defaultRegion:n,o=e.options;return this._baseRequest({endUrl:"static-data/"+i+"/v"+p.STATIC_DATA+"/"+t,staticReq:!0,region:i,options:o},r)}},{key:"_statusRequest",value:function(e,r){var t=e.endUrl,n=(e.region,e.options);return this._baseRequest({endUrl:"lol/status/v"+p.STATUS+"/"+t,status:!0,options:n},r)}},{key:"_gameRequest",value:function(e,r){var t=e.endUrl,n=e.region;return this._baseRequest({endUrl:"v"+p.GAME+"/game/"+t,region:n},r)}},{key:"_leagueRequest",value:function(e,r){var t=e.endUrl,n=e.region,i=e.options;return this._baseRequest({endUrl:"v"+p.LEAGUE+"/league/"+t,region:n,options:i},r)}},{key:"_matchRequest",value:function(e,r){var t=e.endUrl,n=e.region,i=e.options;return this._baseRequest({endUrl:"v"+p.MATCH+"/match/"+t,region:n,options:i},r)}},{key:"_matchListRequest",value:function(e,r){var t=e.endUrl,n=e.region,i=e.options;return this._baseRequest({endUrl:"v"+p.MATCH_LIST+"/matchlist/by-summoner/"+t,region:n,options:i},r)}},{key:"_runesMasteriesRequest",value:function(e,r){var t=e.endUrl,n=e.region;return this._summonerRequest({endUrl:t,region:n},r)}},{key:"_statsRequest",value:function(e,r){var t=e.endUrl,n=e.region,i=e.options;return this._baseRequest({endUrl:"v"+p.STATS+"/stats/by-summoner/"+t,region:n,options:i},r)}},{key:"_summonerRequest",value:function(e,r){var t=e.endUrl,n=e.region;return this._baseRequest({endUrl:"v"+p.SUMMONER+"/summoner/"+t,region:n},r)}},{key:"_logError",value:function(e,r){console.log(n.bold.yellow(e),n.red("request"),n.bold.red("FAILED")+n.red("; "+r))}},{key:"setRegion",value:function(e){this.defaultRegion=e}},{key:"getChamps",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.region,t=e.options,n=arguments[1];return this._championRequest({endUrl:"champion",region:r,options:t},n=r||t?n:arguments[0])}},{key:"getChamp",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.region,t=e.id,i=e.championID,o=arguments[1];return Number.isInteger(t)||Number.isInteger(i)?this._championRequest({endUrl:"champion/"+(t||i),region:r},o):this._logError(this.getChamp.name,"required params "+n.yellow("`id/championID` (int)")+" not passed in")}},{key:"getChampMastery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.region,t=void 0===r?this.defaultRegion:r,i=e.playerID,o=e.championID,s=e.options,a=arguments[1];if(Number.isInteger(i)&&Number.isInteger(o)){var u=g[h[t]];return this._championMasteryRequest({endUrl:u+"/player/"+i+"/champion/"+o,region:t,options:s},a)}return this._logError(this.getChampMastery.name,"required params "+n.yellow("`playerID` (int) AND `championID` (int)")+" not passed in")}},{key:"getChampMasteries",value:function(){var e=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=r.region,i=void 0===t?this.defaultRegion:t,o=r.id,s=r.summonerID,u=r.playerID,l=r.name,m=r.options,d=arguments[1];if(Number.isInteger(o||s||u)){var p=g[h[i]];return this._championMasteryRequest({endUrl:p+"/player/"+(o||s||u)+"/champions",region:i,options:m},d)}if("object"===a(arguments[0])&&"string"==typeof l){var y=g[h[i]];return this.getSummoner({name:l,region:i},function(r,t){return r?d(r):e._championMasteryRequest({endUrl:y+"/player/"+t[e._sanitizeName(l)].id+"/champions",region:i},d)})}return this._logError(this.getChampMasteries.name,"required params "+n.yellow("`id/summonerID/playerID` (int)")+" or "+n.yellow("`name` (str)")+" not passed in")}},{key:"getTotalChampMasteryScore",value:function(){var e=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=r.region,i=void 0===t?this.defaultRegion:t,o=r.id,s=r.summonerID,u=r.playerID,l=r.name,m=r.options,d=arguments[1];if(Number.isInteger(o||s||u)){var p=g[h[i]];return this._championMasteryRequest({endUrl:p+"/player/"+(o||s||u)+"/score",region:i,options:m},d)}if("object"===a(arguments[0])&&"string"==typeof l){var y=g[h[i]];return this.getSummoner({name:l,region:i},function(r,t){return r?d(r):e._championMasteryRequest({endUrl:y+"/player/"+t[e._sanitizeName(l)].id+"/score",region:i},d)})}return this._logError(this.getTotalChampMasteryScore.name,"required params "+n.yellow("`id/summonerID/playerID` (int)")+" or "+n.yellow("`name` (str)")+" not passed in")}},{key:"getTopChamps",value:function(){var e=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=r.region,i=void 0===t?this.defaultRegion:t,o=r.id,s=r.summonerID,u=r.playerID,l=r.name,m=r.options,d=arguments[1];if(Number.isInteger(o||s||u)){var p=g[h[i]];return this._championMasteryRequest({endUrl:p+"/player/"+(o||s||u)+"/topchampions",region:i,options:m},d)}if("object"===a(arguments[0])&&"string"==typeof l){var y=g[h[i]];return this.getSummoner({name:l,region:i},function(r,t){return r?d(r):e._championMasteryRequest({endUrl:y+"/player/"+t[e._sanitizeName(l)].id+"/topchampions",region:i},d)})}return this._logError(this.getTopChamps.name,"required params "+n.yellow("`id/summonerID/playerID` (int)")+" or "+n.yellow("`name` (str)")+" not passed in")}},{key:"getCurrentGame",value:function(){var e=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=r.region,i=void 0===t?this.defaultRegion:t,o=r.id,s=r.summonerID,u=r.playerID,l=r.name,m=arguments[1],d=g[h[i]];return Number.isInteger(o||s||u)?this._currentGameRequest({endUrl:""+(o||s||u),platformId:d,region:i},m):"object"===a(arguments[0])&&"string"==typeof l?this.getSummoner({name:l,region:i},function(r,t){return r?m(r):e._currentGameRequest({endUrl:""+t[e._sanitizeName(l)].id,platformId:d,region:i},m)}):this._logError(this.getCurrentGame.name,"required params "+n.yellow("`id/summonerID/playerID` (int)")+" or "+n.yellow("`name` (string)")+" not passed in")}},{key:"getFeaturedGames",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.region,t=arguments[1];return this._observerRequest({endUrl:"featured",region:r},t=r?t:arguments[0])}},{key:"getRecentGames",value:function(){var e=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=r.region,i=r.id,o=r.summonerID,s=r.playerID,u=r.name,l=arguments[1];return Number.isInteger(i||o||s)?this._gameRequest({endUrl:"by-summoner/"+(i||o||s)+"/recent",region:t},l):"object"===a(arguments[0])&&"string"==typeof u?this.getSummoner({name:u,region:t},function(r,n){return r?l(r):e._gameRequest({endUrl:"by-summoner/"+n[e._sanitizeName(u)].id+"/recent",region:t},l)}):this._logError(this.getRecentGames.name,"required params "+n.yellow("`id/summonerID/playerID` (int)")+" or "+n.yellow("`name` (string)")+" not passed in")}},{key:"getLeagues",value:function(){var e=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=r.region,i=r.ids,o=r.id,s=r.summonerIDs,u=r.summonerID,l=r.playerIDs,m=r.playerID,g=r.names,d=r.name,h=r.options,p=arguments[1];return c.int(i||s||l)?this._leagueRequest({endUrl:"by-summoner/"+(i||s||l).join(","),region:t,options:h},p):Number.isInteger(i||o||s||u||l||m)?this._leagueRequest({endUrl:"by-summoner/"+(i||o||s||u||l||m),region:t,options:h},p):c.string(g)?this.getSummoners({names:g,region:t},function(r,n){if(r)return p(r);var i=[],o=!0,s=!1,a=void 0;try{for(var u,l=g[Symbol.iterator]();!(o=(u=l.next()).done);o=!0){var m=u.value;i.push(n[e._sanitizeName(m)].id)}}catch(e){s=!0,a=e}finally{try{!o&&l.return&&l.return()}finally{if(s)throw a}}return e._leagueRequest({endUrl:"by-summoner/"+i.join(","),region:t,options:h},p)}):"object"!==a(arguments[0])||"string"!=typeof g&&"string"!=typeof d?this._logError(this.getLeagues.name,"required params "+n.yellow("`ids/summonerIDs/playerIDs` ([int]/int)")+", "+n.yellow("`id/summonerID/playerID` (int)")+", "+n.yellow("`names` ([str]/str)")+", or "+n.yellow("`name` (str)")+" not passed in"):this.getSummoner({name:g||d,region:t},function(r,n){return r?p(r):e._leagueRequest({endUrl:"by-summoner/"+n[e._sanitizeName(g||d)].id,region:t,options:h},p)})}},{key:"getLeagueEntries",value:function(){var e=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=r.region,i=r.ids,o=r.id,s=r.summonerIDs,u=r.summonerID,l=r.playerIDs,m=r.playerID,g=r.names,d=r.name,h=arguments[1];return c.int(i||s||l)?this._leagueRequest({endUrl:"by-summoner/"+(i||s||l).join(",")+"/entry",region:t},h):Number.isInteger(i||o||s||u||l||m)?this._leagueRequest({endUrl:"by-summoner/"+(i||o||s||u||l||m)+"/entry",region:t},h):c.string(g)?this.getSummoners({names:g,region:t},function(r,n){if(r)return h(r);var i=[],o=!0,s=!1,a=void 0;try{for(var u,l=g[Symbol.iterator]();!(o=(u=l.next()).done);o=!0){var m=u.value;i.push(n[e._sanitizeName(m)].id)}}catch(e){s=!0,a=e}finally{try{!o&&l.return&&l.return()}finally{if(s)throw a}}return e._leagueRequest({endUrl:"by-summoner/"+i.join(",")+"/entry",region:t},h)}):"object"!==a(arguments[0])||"string"!=typeof g&&"string"!=typeof d?void this._logError(this.getLeagueEntries.name,"required params "+n.yellow("`ids/summonerIDs/playerIDs` ([int]/int)")+", "+n.yellow("`id/summonerID/playerID` (int)")+", "+n.yellow("`names` ([str]/str)")+", or "+n.yellow("`name` (str)")+" not passed in"):this.getSummoner({name:g||d,region:t},function(r,n){return r?h(r):e._leagueRequest({endUrl:"by-summoner/"+n[e._sanitizeName(g||d)].id+"/entry",region:t},h)})}},{key:"getChallengers",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.region,t=e.options,n=void 0===t?{type:"RANKED_SOLO_5x5"}:t,i=arguments[1];return this._leagueRequest({endUrl:"challenger",region:r,options:n},i=r||n?i:arguments[0])}},{key:"getMasters",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.region,t=e.options,n=void 0===t?{type:"RANKED_SOLO_5x5"}:t,i=arguments[1];return this._leagueRequest({endUrl:"master",region:r,options:n},i=r||n?i:arguments[0])}},{key:"getChampionList",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.region,t=e.options,n=arguments[1];return this._staticRequest({endUrl:"champion",region:r,options:t},n=r||t?n:arguments[0])}},{key:"getChampion",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.region,t=e.id,i=e.championID,o=e.options,s=arguments[1];return Number.isInteger(t||i)?this._staticRequest({endUrl:"champion/"+(t||i),region:r,options:o},s):this._logError(this.getChampion.name,"required params "+n.yellow("`id/championID` (int)")+" not passed in")}},{key:"getItems",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.region,t=e.options,n=arguments[1];return this._staticRequest({endUrl:"item",region:r,options:t},n=r||t?n:arguments[0])}},{key:"getItem",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.region,t=e.id,i=e.itemID,o=e.options,s=arguments[1];return Number.isInteger(t||i)?this._staticRequest({endUrl:"item/"+(t||i),region:r,options:o},s):this._logError(this.getItem.name,"required params "+n.yellow("`id/itemID` (int)")+" not passed in")}},{key:"getLanguageStrings",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.region,t=e.options,n=arguments[1];return this._staticRequest({endUrl:"language-strings",region:r,options:t},n=r||t?n:arguments[0])}},{key:"getLanguages",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.region,t=arguments[1];return this._staticRequest({endUrl:"languages",region:r},t=r?t:arguments[0])}},{key:"getMap",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.region,t=e.options,n=arguments[1];return this._staticRequest({endUrl:"map",region:r,options:t},n=r||t?n:arguments[0])}},{key:"getMasteryList",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.region,t=e.options,n=arguments[1];return this._staticRequest({endUrl:"mastery",region:r,options:t},n=r||t?n:arguments[0])}},{key:"getMastery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.region,t=e.id,i=e.masteryID,o=e.options,s=arguments[1];return Number.isInteger(t||i)?this._staticRequest({endUrl:"mastery/"+(t||i),region:r,options:o},s):this._logError(this.getMastery.name,"required params "+n.yellow("`id/masteryID` (int)")+" not passed in")}},{key:"getRealmData",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.region,t=arguments[1];return this._staticRequest({endUrl:"realm",region:r},t=r?t:arguments[0])}},{key:"getRuneList",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.region,t=e.options,n=arguments[1];return this._staticRequest({endUrl:"rune",region:r,options:t},n=r||t?n:arguments[0])}},{key:"getRune",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.region,t=e.id,i=e.runeID,o=e.options,s=arguments[1];return Number.isInteger(t||i)?this._staticRequest({endUrl:"rune/"+(t||i),region:r,options:o},s):this._logError(this.getRune.name,"required params "+n.yellow("`id/runeID` (int)")+" not passed in")}},{key:"getSummonerSpells",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.region,t=e.options,n=arguments[1];return this._staticRequest({endUrl:"summoner-spell",region:r,options:t},n=r||t?n:arguments[0])}},{key:"getSummonerSpell",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.region,t=e.id,i=e.spellID,o=e.summonerSpellID,s=e.options,a=arguments[1];return Number.isInteger(t||i||o)?this._staticRequest({endUrl:"summoner-spell/"+(t||i||o),region:r,options:s},a):this._logError(this.getSummonerSpell.name,"required params "+n.yellow("`id/spellID/summonerSpellID` (int)")+" not passed in")}},{key:"getVersionData",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.region,t=e.options,n=arguments[1];return this._staticRequest({endUrl:"versions",region:r,options:t},n=r||t?n:arguments[0])}},{key:"getShardStatus",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.region,t=arguments[1];return this._statusRequest({endUrl:"shard",region:r},t=r?t:arguments[0])}},{key:"getShardList",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.region,t=arguments[1];return this._statusRequest({endUrl:"shards",region:r},t=r?t:arguments[0])}},{key:"getMatch",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.region,t=e.id,i=e.matchID,o=e.options,s=void 0===o?{includeTimeline:!0}:o,a=arguments[1];return Number.isInteger(t||i)?this._matchRequest({endUrl:""+(t||i),region:r,options:s},a):this._logError(this.getMatch.name,"required params "+n.yellow("`id/matchID` (int)")+" not passed in")}},{key:"getMatchList",value:function(){var e=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=r.region,i=r.id,o=r.summonerID,s=r.playerID,u=r.name,l=r.options,m=void 0===l?{rankedQueues:"RANKED_SOLO_5x5"}:l,g=arguments[1];return Number.isInteger(i||o||s)?this._matchListRequest({endUrl:""+(i||o||s),region:t,options:m},g):"object"===a(arguments[0])&&"string"==typeof u?this.getSummoner({name:u,region:t},function(r,n){return r?g(r):e._matchListRequest({endUrl:""+n[e._sanitizeName(u)].id,region:t,options:m},g)}):this._logError(this.getMatchList.name,"required params "+n.yellow("`id/summonerID/playerID` (int)")+" or "+n.yellow("`name` (str)")+" not passed in")}},{key:"getRunes",value:function(){var e=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=r.region,i=r.ids,o=r.id,s=r.summonerIDs,u=r.summonerID,l=r.playerIDs,m=r.playerID,g=r.names,d=r.name,h=arguments[1];return c.int(i||s||l)?this._runesMasteriesRequest({endUrl:(i||s||l).join()+"/runes",region:t},h):Number.isInteger(i||o||s||u||l||m)?this._runesMasteriesRequest({endUrl:(i||o||s||u||l||m)+"/runes",region:t},h):c.string(g)?this.getSummoners({names:g,region:t},function(r,n){if(r)return h(r);var i=[],o=!0,s=!1,a=void 0;try{for(var u,l=g[Symbol.iterator]();!(o=(u=l.next()).done);o=!0){var m=u.value;i.push(n[e._sanitizeName(m)].id)}}catch(e){s=!0,a=e}finally{try{!o&&l.return&&l.return()}finally{if(s)throw a}}return e._runesMasteriesRequest({endUrl:i.join(",")+"/runes",region:t},h)}):"object"!==a(arguments[0])||"string"!=typeof g&&"string"!=typeof d?this._logError(this.getRunes.name,"required params "+n.yellow("`ids/summonerIDs/playerIDs` ([int]/int)")+", "+n.yellow("`id/summonerID/playerID` (int)")+", "+n.yellow("`names` ([str]/str)")+", or "+n.yellow("`name` (str)")+" not passed in"):this.getSummoner({name:g||d,region:t},function(r,n){return r?h(r):e._runesMasteriesRequest({endUrl:n[e._sanitizeName(g||d)].id+"/runes",region:t},h)})}},{key:"getMasteries",value:function(){var e=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=r.region,i=r.ids,o=r.id,s=r.summonerIDs,u=r.summonerID,l=r.playerIDs,m=r.playerID,g=r.names,d=r.name,h=arguments[1];return c.int(i||s||l)?this._runesMasteriesRequest({endUrl:(i||s||l).join()+"/masteries",region:t},h):Number.isInteger(i||o||s||u||l||m)?this._runesMasteriesRequest({endUrl:(i||o||s||u||l||m)+"/masteries",region:t},h):c.string(g)?this.getSummoners({names:g,region:t},function(r,n){if(r)return h(r);var i=[],o=!0,s=!1,a=void 0;try{for(var u,l=g[Symbol.iterator]();!(o=(u=l.next()).done);o=!0){var m=u.value;i.push(n[e._sanitizeName(m)].id)}}catch(e){s=!0,a=e}finally{try{!o&&l.return&&l.return()}finally{if(s)throw a}}return e._runesMasteriesRequest({endUrl:i.join(",")+"/masteries",region:t},h)}):"object"!==a(arguments[0])||"string"!=typeof g&&"string"!=typeof d?this._logError(this.getMasteries.name,"required params "+n.yellow("`ids/summonerIDs/playerIDs` ([int]/int)")+", "+n.yellow("`id/summonerID/playerID` (int)")+", "+n.yellow("`names` ([str]/str)")+", or "+n.yellow("`name` (str)")+" not passed in"):this.getSummoner({name:g||d,region:t},function(r,n){return r?h(r):e._runesMasteriesRequest({endUrl:n[e._sanitizeName(g||d)].id+"/masteries",region:t},h)})}},{key:"getRankedStats",value:function(){var e=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=r.region,i=r.id,o=r.summonerID,s=r.playerID,u=r.name,l=r.options,m=arguments[1];return Number.isInteger(i||o||s)?this._statsRequest({endUrl:(i||o||s)+"/ranked",region:t,options:l},m):"object"===a(arguments[0])&&"string"==typeof u?this.getSummoner({name:u,region:t},function(r,n){return r?m(r):e._statsRequest({endUrl:n[e._sanitizeName(u)].id+"/ranked",region:t,options:l},m)}):void this._logError(this.getRankedStats.name,"required params "+n.yellow("`id/summonerID/playerID` (int)")+" or "+n.yellow("`name` (string)")+" not passed in")}},{key:"getStatsSummary",value:function(){var e=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=r.region,i=r.id,o=r.summonerID,s=r.playerID,u=r.name,l=r.options,m=arguments[1];return Number.isInteger(i||o||s)?this._statsRequest({endUrl:(i||o||s)+"/summary",region:t,options:l},m):"object"===a(arguments[0])&&"string"==typeof u?this.getSummoner({name:u,region:t},function(r,n){return r?m(r):e._statsRequest({endUrl:n[e._sanitizeName(u)].id+"/summary",region:t,options:l},m)}):void this._logError(this.getRankedStats.name,"required params "+n.yellow("`id/summonerID/playerID` (int)")+" or "+n.yellow("`name` (string)")+" not passed in")}},{key:"getSummoners",value:function(){var e=this,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=r.region,i=r.ids,o=r.id,s=r.summonerIDs,u=r.summonerID,l=r.playerIDs,m=r.playerID,g=r.names,d=r.name,h=arguments[1];return c.int(i||s||l)?this._summonerRequest({endUrl:""+(i||s||l).join(","),region:t},h):Number.isInteger(i||o||s||u||l||m)?this._summonerRequest({endUrl:""+(i||o||s||u||l||m),region:t},h):c.string(g)?this._summonerRequest({endUrl:"by-name/"+g.map(function(r){return e._sanitizeName(r)}).join(","),region:t},h):"object"!==a(arguments[0])||"string"!=typeof g&&"string"!=typeof d?void this._logError(this.getSummoners.name,"required params "+n.yellow("`ids/summonerIDs/playerIDs` ([int]/int)")+", "+n.yellow("`id/summonerID/playerID` (int)")+", "+n.yellow("`names` ([str]/str)")+", or "+n.yellow("`name` (str)")+" not passed in"):this._summonerRequest({endUrl:"by-name/"+this._sanitizeName(g||d),region:t},h)}},{key:"getSummoner",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.region,t=e.id,i=e.summonerID,o=e.playerID,s=e.name,u=arguments[1];return Number.isInteger(t||i||o)?this.getSummoners({region:r,ids:[t||i||o]},u):"object"===a(arguments[0])&&"string"==typeof s?this.getSummoners({region:r,names:[s]},u):this._logError(this.getSummoner.name,"required params "+n.yellow("`id/summonerID/playerID` (int)")+" or "+n.yellow("`name` (string)")+" not passed in")}},{key:"getSummonerNames",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.region,t=e.ids,i=e.id,o=e.summonerIDs,s=e.summonerID,a=e.playerIDs,u=e.playerID,l=arguments[1];return c.int(t||o||a)?this._summonerRequest({endUrl:(t||o||a).join(",")+"/name",region:r},l):Number.isInteger(t||i||o||s||a||u)?this._summonerRequest({endUrl:(t||i||o||s||a||u)+"/name",region:r},l):void this._logError(this.getSummonerNames.name,"required params "+n.yellow("required params `ids/summonerIDs/playerIDs` ([int]/int)")+" or "+n.yellow("`id/summonerID/playerID` (int)")+" not passed in")}},{key:"getSummonerName",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},r=e.region,t=e.id,i=e.summonerID,o=e.playerID,s=arguments[1];if(Number.isInteger(t))return this.getSummonerNames({region:r,id:t||i||o},s);this._logError(this.getSummonerName.name,"required params "+n.yellow("`id/summonerID/playerID` (int)")+" not passed in")}}]),e}(),_={Kindred:R,REGIONS:d,LIMITS:m};e.exports=_}); |
{ | ||
"name": "kindred-api", | ||
"version": "1.1.7", | ||
"version": "1.1.8", | ||
"description": "Kindred is a thin Node.js wrapper on top of Riot Games API for League of Legends", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -8,2 +8,3 @@ const request = require('request') | ||
import LIMITS from './constants/limits' | ||
import PLATFORM_IDS from './constants/platform-ids' | ||
@@ -53,4 +54,4 @@ import REGIONS from './constants/regions' | ||
if (limits === 'dev') limits = [[10, 10], [500, 600]] | ||
if (limits === 'prod') limits = [[3000, 10], [180000, 600]] | ||
if (limits === 'dev') limits = LIMITS.DEV | ||
if (limits === 'prod') limits = LIMITS.PROD | ||
@@ -64,2 +65,8 @@ for (const region of Object.keys(REGIONS)) { | ||
} | ||
this.champion = { | ||
getChampions: this.getChamps.bind(this), | ||
getChampion: this.getChamp.bind(this) | ||
} | ||
} | ||
@@ -244,3 +251,3 @@ | ||
return this._baseRequest({ | ||
endUrl: `championmastery/location/${endUrl}`, options, | ||
endUrl: `championmastery/location/${endUrl}`, region, options, | ||
championMastery: true | ||
@@ -325,3 +332,3 @@ }, cb) | ||
/* CHAMPION-V1.2 */ | ||
getChamps({ region, options }, cb) { | ||
getChamps({ region, options } = {}, cb) { | ||
return this._championRequest({ | ||
@@ -332,3 +339,3 @@ endUrl: `champion`, region, options | ||
getChamp({ region, id, championID }, cb) { | ||
getChamp({ region, id, championID } = {}, cb) { | ||
if (Number.isInteger(id) || Number.isInteger(championID)) { | ||
@@ -932,3 +939,4 @@ return this._championRequest({ | ||
Kindred, | ||
REGIONS | ||
REGIONS, | ||
LIMITS | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
319806
34
2749