kindred-api
Advanced tools
Comparing version 1.2.2 to 1.2.3
@@ -1,2 +0,2 @@ | ||
!function(e,t){if("function"==typeof define&&define.amd)define("kindred-api",["module","double-ended-queue","request","chalk","xregexp","query-string"],t);else if("undefined"!=typeof exports)t(module,require("double-ended-queue"),require("request"),require("chalk"),require("xregexp"),require("query-string"));else{var i={exports:{}};t(i,e.doubleEndedQueue,e.request,e.chalk,e.xregexp,e.queryString),e.kindredApi=i.exports}}(this,function(e,t,i,n,r,s){"use strict";function o(e,t){if(!(e instanceof t))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,t){for(var i=0;i<t.length;i++){var n=t[i];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}return function(t,i,n){return i&&e(t.prototype,i),n&&e(t,n),t}}(),l=function(){function e(i,n){o(this,e),this.allowedRequests=i,this.seconds=n,this.madeRequests=new t}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"},h={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"},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 t=v[e];if(t)return t},b=r("^[0-9\\p{L} _\\.]+$"),R=function(){function e(t){var i=t.key,r=t.defaultRegion,s=void 0===r?h.NORTH_AMERICA:r,a=t.debug,u=void 0!==a&&a,g=t.limits;o(this,e),this.key=i;var d=void 0,p=!0,y=!1,v=void 0;try{for(var f,b=Object.keys(h)[Symbol.iterator]();!(p=(f=b.next()).done);p=!0){var R=f.value;h[R]===s&&(d=!0)}}catch(e){y=!0,v=e}finally{try{!p&&b.return&&b.return()}finally{if(y)throw v}}if(this.defaultRegion=d?s:void 0,this.defaultRegion||(console.log(""+n.red("Initialization of Kindred failed: "+n.yellow(s)+" 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 I=!0,_=!1,S=void 0;try{for(var q,D=Object.keys(h)[Symbol.iterator]();!(I=(q=D.next()).done);I=!0){var U=q.value;this.limits[h[U]]=[new l(g[0][0],g[0][1]),new l(g[1][0],g[1][1])]}}catch(e){_=!0,S=e}finally{try{!I&&D.return&&D.return()}finally{if(_)throw S}}}this.Champion={getChampions:this.getChamps.bind(this),getAll:this.getChamps.bind(this),all:this.getChamps.bind(this),getChampion:this.getChamp.bind(this),get:this.getChamp.bind(this)},this.ChampionMastery={getChampionMastery:this.getChampMastery.bind(this),get:this.getChampMastery.bind(this),getChampionMasteries:this.getChampMasteries.bind(this),getAll:this.getChampMasteries.bind(this),all:this.getChampMasteries.bind(this),getTotalChampionMasteryScore:this.getTotalChampMasteryScore.bind(this),getTotalScore:this.getTotalChampMasteryScore.bind(this),totalScore:this.getTotalChampMasteryScore.bind(this),total:this.getTotalChampMasteryScore.bind(this),getTopChampions:this.getTopChamps.bind(this),top:this.getTopChamps.bind(this),best:this.getTopChamps.bind(this)},this.CurrentGame={getCurrentGame:this.getCurrentGame.bind(this),get:this.getCurrentGame.bind(this)},this.FeaturedGames={getFeaturedGames:this.getFeaturedGames.bind(this),get:this.getFeaturedGames.bind(this)},this.Game={getRecentGames:this.getRecentGames.bind(this),getRecent:this.getRecentGames.bind(this),get:this.getRecentGames.bind(this)},this.League={getLeagues:this.getLeagues.bind(this),get:this.getLeagues.bind(this),getLeagueEntries:this.getLeagueEntries.bind(this),getEntries:this.getLeagueEntries.bind(this),entries:this.getLeagueEntries.bind(this),getChallengers:this.getChallengers.bind(this),challengers:this.getChallengers.bind(this),getMasters:this.getMasters.bind(this),masters:this.getMasters.bind(this)},this.Static={getChampions:this.getChampionList.bind(this),champions:this.getChampionList.bind(this),getChampion:this.getChampion.bind(this),champion:this.getChampion.bind(this),getItems:this.getItems.bind(this),items:this.getItems.bind(this),getItem:this.getItem.bind(this),item:this.getItem.bind(this),getLanguageStrings:this.getLanguageStrings.bind(this),languageStrings:this.getLanguageStrings.bind(this),getLanguages:this.getLanguages.bind(this),languages:this.getLanguages.bind(this),getMap:this.getMap.bind(this),map:this.getMap.bind(this),getMasteries:this.getMasteryList.bind(this),masteries:this.getMasteryList.bind(this),getMastery:this.getMastery.bind(this),mastery:this.getMastery.bind(this),getRealmData:this.getRealmData.bind(this),realmData:this.getRealmData.bind(this),realm:this.getRealmData.bind(this),realms:this.getRealmData.bind(this),getRunes:this.getRuneList.bind(this),runes:this.getRuneList.bind(this),getRune:this.getRune.bind(this),rune:this.getRune.bind(this),getSummonerSpells:this.getSummonerSpells.bind(this),summonerSpells:this.getSummonerSpells.bind(this),spells:this.getSummonerSpells.bind(this),getSummonerSpell:this.getSummonerSpell.bind(this),summonerSpell:this.getSummonerSpell.bind(this),spell:this.getSummonerSpell.bind(this),getVersionData:this.getVersionData.bind(this),versionData:this.getVersionData.bind(this),version:this.getVersionData.bind(this),versions:this.getVersionData.bind(this)},this.Status={getShardStatus:this.getShardStatus.bind(this),getStatus:this.getShardStatus.bind(this),get:this.getShardStatus.bind(this),getShardList:this.getShardList.bind(this),getShards:this.getShardList.bind(this),getAll:this.getShardList.bind(this),all:this.getShardList.bind(this)},this.Match={getMatch:this.getMatch.bind(this),get:this.getMatch.bind(this)},this.MatchList={getMatchList:this.getMatchList.bind(this),get:this.getMatchList.bind(this)},this.RunesMasteries={getRunes:this.getRunes.bind(this),runes:this.getRunes.bind(this),getMasteries:this.getMasteries.bind(this),masteries:this.getMasteries.bind(this)},this.Stats={getRankedStats:this.getRankedStats.bind(this),ranked:this.getRankedStats.bind(this),getStatsSummary:this.getStatsSummary.bind(this),summary:this.getStatsSummary.bind(this)},this.Summoner={getSummoners:this.getSummoners.bind(this),getAll:this.getSummoners.bind(this),all:this.getSummoners.bind(this),getSummoner:this.getSummoner.bind(this),get:this.getSummoner.bind(this),getSummonerNames:this.getSummonerNames.bind(this),getNames:this.getSummonerNames.bind(this),names:this.getSummonerNames.bind(this),getSummonerName:this.getSummonerName.bind(this),getName:this.getSummonerName.bind(this),name:this.getSummonerName.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 b.test(e)}},{key:"_makeUrl",value:function(e,t,i,n,r,s){var o=i?"":t+"/",a=n||r||s?"":"api/lol/"+o,u="https://"+t+".api.riotgames.com/"+a+encodeURI(e);return u+=u.lastIndexOf("?")===-1?"?":"&",u+="api_key="+this.key}},{key:"_baseRequest",value:function(e,t){var r=this,o=e.endUrl,a=e.region,u=void 0===a?this.defaultRegion:a,l=e.status,m=void 0!==l&&l,g=e.observerMode,h=void 0!==g&&g,d=e.staticReq,p=void 0!==d&&d,y=e.championMastery,c=void 0!==y&&y,v=e.options,b=void 0===v?{}:v,R=function(){return new Promise(function(e,a){var l=p?"global":u,g=s.stringify(b),d=g?"?"+g:"",y=r._makeUrl(o+d,l,p,m,h,c);if(r.limits){var v=r;!function t(r){v.canMakeRequest(u)?(p||(v.limits[u][0].addRequest(),v.limits[u][1].addRequest()),i({url:y},function(i,s,o){if(s&&o){var u=void 0,l=s.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":s.headers["x-app-rate-limit-count"],"x-method-rate-limit-count":s.headers["x-method-rate-limit-count"],"x-rate-limit-count":s.headers["x-rate-limit-count"],"retry-after":s.headers["retry-after"]}),console.log()),r)return l>=500&&(v.debug&&console.log("!!! resending request !!!"),setTimeout(function(){t.bind(v)(r)},1e3)),429===l&&(v.debug&&console.log("!!! resending request !!!"),setTimeout(function(){t.bind(v)(r)},1e3*s.headers["retry-after"]+50)),l>=400?r(u+" : "+n.yellow(y)):r(i,JSON.parse(o));if(500===l)v.debug&&console.log("!!! resending promise request !!!"),setTimeout(function(){return a("retry")},1e3);else{if(429!==l)return i||l>=400?a("err:",i,l):e(JSON.parse(o));v.debug&&console.log("!!! resending promise request !!!"),setTimeout(function(){return a("retry")},1e3*s.headers["retry-after"]+50)}}else console.log(i,y)})):setTimeout(function(){t.bind(v)(r)},1e3)}(t)}else i({url:y},function(i,s,o){if(s){var u=void 0,l=s.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))),r.debug&&(console.log(s&&u,y),console.log({"x-app-rate-limit-count":s.headers["x-app-rate-limit-count"],"x-method-rate-limit-count":s.headers["x-method-rate-limit-count"],"x-rate-limit-count":s.headers["x-rate-limit-count"],"retry-after":s.headers["retry-after"]})),t?l>=400?t(u+" : "+n.yellow(y)):t(i,JSON.parse(o)):i?a("err:",i):e(JSON.parse(o))}console.log(i,y)})})};return t?R():R().catch(R).catch(R).catch(R).then(function(e){return e})}},{key:"_observerRequest",value:function(e,t){var i=e.endUrl,n=e.region;return this._baseRequest({endUrl:"observer-mode/rest/"+i,observerMode:!0,region:n},t)}},{key:"_championRequest",value:function(e,t){var i=e.endUrl,n=e.region,r=e.options;return this._baseRequest({endUrl:"v"+p.CHAMPION+"/"+i,region:n,options:r},t)}},{key:"_championMasteryRequest",value:function(e,t){var i=e.endUrl,n=e.region,r=e.options;return this._baseRequest({endUrl:"championmastery/location/"+i,region:n,options:r,championMastery:!0},t)}},{key:"_currentGameRequest",value:function(e,t){var i=e.endUrl,n=e.region,r=e.platformId;return this._observerRequest({endUrl:"consumer/getSpectatorGameInfo/"+r+"/"+i,region:n},t)}},{key:"_staticRequest",value:function(e,t){var i=e.endUrl,n=e.region,r=void 0===n?this.defaultRegion:n,s=e.options;return this._baseRequest({endUrl:"static-data/"+r+"/v"+p.STATIC_DATA+"/"+i,staticReq:!0,region:r,options:s},t)}},{key:"_statusRequest",value:function(e,t){var i=e.endUrl,n=(e.region,e.options);return this._baseRequest({endUrl:"lol/status/v"+p.STATUS+"/"+i,status:!0,options:n},t)}},{key:"_gameRequest",value:function(e,t){var i=e.endUrl,n=e.region;return this._baseRequest({endUrl:"v"+p.GAME+"/game/"+i,region:n},t)}},{key:"_leagueRequest",value:function(e,t){var i=e.endUrl,n=e.region,r=e.options;return this._baseRequest({endUrl:"v"+p.LEAGUE+"/league/"+i,region:n,options:r},t)}},{key:"_matchRequest",value:function(e,t){var i=e.endUrl,n=e.region,r=e.options;return this._baseRequest({endUrl:"v"+p.MATCH+"/match/"+i,region:n,options:r},t)}},{key:"_matchListRequest",value:function(e,t){var i=e.endUrl,n=e.region,r=e.options;return this._baseRequest({endUrl:"v"+p.MATCH_LIST+"/matchlist/by-summoner/"+i,region:n,options:r},t)}},{key:"_runesMasteriesRequest",value:function(e,t){var i=e.endUrl,n=e.region;return this._summonerRequest({endUrl:i,region:n},t)}},{key:"_statsRequest",value:function(e,t){var i=e.endUrl,n=e.region,r=e.options;return this._baseRequest({endUrl:"v"+p.STATS+"/stats/by-summoner/"+i,region:n,options:r},t)}},{key:"_summonerRequest",value:function(e,t){var i=e.endUrl,n=e.region;return this._baseRequest({endUrl:"v"+p.SUMMONER+"/summoner/"+i,region:n},t)}},{key:"_logError",value:function(e,t){console.log(n.bold.yellow(e),n.red("request"),n.bold.red("FAILED")+n.red("; "+t))}},{key:"setRegion",value:function(e){this.defaultRegion=e}},{key:"getChamps",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.options,n=arguments[1];return this._championRequest({endUrl:"champion",region:t,options:i},n=t||i?n:arguments[0])}},{key:"getChamp",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.id,r=e.championID,s=arguments[1];return Number.isInteger(i)||Number.isInteger(r)?this._championRequest({endUrl:"champion/"+(i||r),region:t},s):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]:{},t=e.region,i=void 0===t?this.defaultRegion:t,r=e.playerID,s=e.championID,o=e.options,a=arguments[1];if(Number.isInteger(r)&&Number.isInteger(s)){var u=g[d[i]];return this._championMasteryRequest({endUrl:u+"/player/"+r+"/champion/"+s,region:i,options:o},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,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=t.region,r=void 0===i?this.defaultRegion:i,s=t.id,o=t.summonerID,u=t.playerID,l=t.name,m=t.options,h=arguments[1];if(Number.isInteger(s||o||u)){var p=g[d[r]];return this._championMasteryRequest({endUrl:p+"/player/"+(s||o||u)+"/champions",region:r,options:m},h)}if("object"===a(arguments[0])&&"string"==typeof l){var y=g[d[r]];return this.getSummoner({name:l,region:r},function(t,i){return t?h(t):e._championMasteryRequest({endUrl:y+"/player/"+i[e._sanitizeName(l)].id+"/champions",region:r},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,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=t.region,r=void 0===i?this.defaultRegion:i,s=t.id,o=t.summonerID,u=t.playerID,l=t.name,m=t.options,h=arguments[1];if(Number.isInteger(s||o||u)){var p=g[d[r]];return this._championMasteryRequest({endUrl:p+"/player/"+(s||o||u)+"/score",region:r,options:m},h)}if("object"===a(arguments[0])&&"string"==typeof l){var y=g[d[r]];return this.getSummoner({name:l,region:r},function(t,i){return t?h(t):e._championMasteryRequest({endUrl:y+"/player/"+i[e._sanitizeName(l)].id+"/score",region:r},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,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=t.region,r=void 0===i?this.defaultRegion:i,s=t.id,o=t.summonerID,u=t.playerID,l=t.name,m=t.options,h=arguments[1];if(Number.isInteger(s||o||u)){var p=g[d[r]];return this._championMasteryRequest({endUrl:p+"/player/"+(s||o||u)+"/topchampions",region:r,options:m},h)}if("object"===a(arguments[0])&&"string"==typeof l){var y=g[d[r]];return this.getSummoner({name:l,region:r},function(t,i){return t?h(t):e._championMasteryRequest({endUrl:y+"/player/"+i[e._sanitizeName(l)].id+"/topchampions",region:r},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,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=t.region,r=void 0===i?this.defaultRegion:i,s=t.id,o=t.summonerID,u=t.playerID,l=t.name,m=arguments[1],h=g[d[r]];return Number.isInteger(s||o||u)?this._currentGameRequest({endUrl:""+(s||o||u),platformId:h,region:r},m):"object"===a(arguments[0])&&"string"==typeof l?this.getSummoner({name:l,region:r},function(t,i){return t?m(t):e._currentGameRequest({endUrl:""+i[e._sanitizeName(l)].id,platformId:h,region:r},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]:{},t=e.region,i=arguments[1];return this._observerRequest({endUrl:"featured",region:t},i=t?i:arguments[0])}},{key:"getRecentGames",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=t.region,r=t.id,s=t.summonerID,o=t.playerID,u=t.name,l=arguments[1];return Number.isInteger(r||s||o)?this._gameRequest({endUrl:"by-summoner/"+(r||s||o)+"/recent",region:i},l):"object"===a(arguments[0])&&"string"==typeof u?this.getSummoner({name:u,region:i},function(t,n){return t?l(t):e._gameRequest({endUrl:"by-summoner/"+n[e._sanitizeName(u)].id+"/recent",region:i},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,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=t.region,r=t.ids,s=t.id,o=t.summonerIDs,u=t.summonerID,l=t.playerIDs,m=t.playerID,g=t.names,h=t.name,d=t.options,p=arguments[1];return c.int(r||o||l)?this._leagueRequest({endUrl:"by-summoner/"+(r||o||l).join(","),region:i,options:d},p):Number.isInteger(r||s||o||u||l||m)?this._leagueRequest({endUrl:"by-summoner/"+(r||s||o||u||l||m),region:i,options:d},p):c.string(g)?this.getSummoners({names:g,region:i},function(t,n){if(t)return p(t);var r=[],s=!0,o=!1,a=void 0;try{for(var u,l=g[Symbol.iterator]();!(s=(u=l.next()).done);s=!0){var m=u.value;r.push(n[e._sanitizeName(m)].id)}}catch(e){o=!0,a=e}finally{try{!s&&l.return&&l.return()}finally{if(o)throw a}}return e._leagueRequest({endUrl:"by-summoner/"+r.join(","),region:i,options:d},p)}):"object"!==a(arguments[0])||"string"!=typeof g&&"string"!=typeof h?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||h,region:i},function(t,n){return t?p(t):e._leagueRequest({endUrl:"by-summoner/"+n[e._sanitizeName(g||h)].id,region:i,options:d},p)})}},{key:"getLeagueEntries",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=t.region,r=t.ids,s=t.id,o=t.summonerIDs,u=t.summonerID,l=t.playerIDs,m=t.playerID,g=t.names,h=t.name,d=arguments[1];return c.int(r||o||l)?this._leagueRequest({endUrl:"by-summoner/"+(r||o||l).join(",")+"/entry",region:i},d):Number.isInteger(r||s||o||u||l||m)?this._leagueRequest({endUrl:"by-summoner/"+(r||s||o||u||l||m)+"/entry",region:i},d):c.string(g)?this.getSummoners({names:g,region:i},function(t,n){if(t)return d(t);var r=[],s=!0,o=!1,a=void 0;try{for(var u,l=g[Symbol.iterator]();!(s=(u=l.next()).done);s=!0){var m=u.value;r.push(n[e._sanitizeName(m)].id)}}catch(e){o=!0,a=e}finally{try{!s&&l.return&&l.return()}finally{if(o)throw a}}return e._leagueRequest({endUrl:"by-summoner/"+r.join(",")+"/entry",region:i},d)}):"object"!==a(arguments[0])||"string"!=typeof g&&"string"!=typeof h?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||h,region:i},function(t,n){return t?d(t):e._leagueRequest({endUrl:"by-summoner/"+n[e._sanitizeName(g||h)].id+"/entry",region:i},d)})}},{key:"getChallengers",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.options,n=void 0===i?{type:"RANKED_SOLO_5x5"}:i,r=arguments[1];return this._leagueRequest({endUrl:"challenger",region:t,options:n},r=t||n?r:arguments[0])}},{key:"getMasters",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.options,n=void 0===i?{type:"RANKED_SOLO_5x5"}:i,r=arguments[1];return this._leagueRequest({endUrl:"master",region:t,options:n},r=t||n?r:arguments[0])}},{key:"getChampionList",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.options,n=arguments[1];return this._staticRequest({endUrl:"champion",region:t,options:i},n=t||i?n:arguments[0])}},{key:"getChampion",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.id,r=e.championID,s=e.options,o=arguments[1];return Number.isInteger(i||r)?this._staticRequest({endUrl:"champion/"+(i||r),region:t,options:s},o):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]:{},t=e.region,i=e.options,n=arguments[1];return this._staticRequest({endUrl:"item",region:t,options:i},n=t||i?n:arguments[0])}},{key:"getItem",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.id,r=e.itemID,s=e.options,o=arguments[1];return Number.isInteger(i||r)?this._staticRequest({endUrl:"item/"+(i||r),region:t,options:s},o):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]:{},t=e.region,i=e.options,n=arguments[1];return this._staticRequest({endUrl:"language-strings",region:t,options:i},n=t||i?n:arguments[0])}},{key:"getLanguages",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=arguments[1];return this._staticRequest({endUrl:"languages",region:t},i=t?i:arguments[0])}},{key:"getMap",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.options,n=arguments[1];return this._staticRequest({endUrl:"map",region:t,options:i},n=t||i?n:arguments[0])}},{key:"getMasteryList",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.options,n=arguments[1];return this._staticRequest({endUrl:"mastery",region:t,options:i},n=t||i?n:arguments[0])}},{key:"getMastery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.id,r=e.masteryID,s=e.options,o=arguments[1];return Number.isInteger(i||r)?this._staticRequest({endUrl:"mastery/"+(i||r),region:t,options:s},o):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]:{},t=e.region,i=arguments[1];return this._staticRequest({endUrl:"realm",region:t},i=t?i:arguments[0])}},{key:"getRuneList",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.options,n=arguments[1];return this._staticRequest({endUrl:"rune",region:t,options:i},n=t||i?n:arguments[0])}},{key:"getRune",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.id,r=e.runeID,s=e.options,o=arguments[1];return Number.isInteger(i||r)?this._staticRequest({endUrl:"rune/"+(i||r),region:t,options:s},o):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]:{},t=e.region,i=e.options,n=arguments[1];return this._staticRequest({endUrl:"summoner-spell",region:t,options:i},n=t||i?n:arguments[0])}},{key:"getSummonerSpell",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.id,r=e.spellID,s=e.summonerSpellID,o=e.options,a=arguments[1];return Number.isInteger(i||r||s)?this._staticRequest({endUrl:"summoner-spell/"+(i||r||s),region:t,options:o},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]:{},t=e.region,i=e.options,n=arguments[1];return this._staticRequest({endUrl:"versions",region:t,options:i},n=t||i?n:arguments[0])}},{key:"getShardStatus",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=arguments[1];return this._statusRequest({endUrl:"shard",region:t},i=t?i:arguments[0])}},{key:"getShardList",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=arguments[1];return this._statusRequest({endUrl:"shards",region:t},i=t?i:arguments[0])}},{key:"getMatch",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.id,r=e.matchID,s=e.options,o=void 0===s?{includeTimeline:!0}:s,a=arguments[1];return Number.isInteger(i||r)?this._matchRequest({endUrl:""+(i||r),region:t,options:o},a):this._logError(this.getMatch.name,"required params "+n.yellow("`id/matchID` (int)")+" not passed in")}},{key:"getMatchList",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=t.region,r=t.id,s=t.summonerID,o=t.playerID,u=t.name,l=t.options,m=void 0===l?{rankedQueues:"RANKED_SOLO_5x5"}:l,g=arguments[1];return Number.isInteger(r||s||o)?this._matchListRequest({endUrl:""+(r||s||o),region:i,options:m},g):"object"===a(arguments[0])&&"string"==typeof u?this.getSummoner({name:u,region:i},function(t,n){return t?g(t):e._matchListRequest({endUrl:""+n[e._sanitizeName(u)].id,region:i,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,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=t.region,r=t.ids,s=t.id,o=t.summonerIDs,u=t.summonerID,l=t.playerIDs,m=t.playerID,g=t.names,h=t.name,d=arguments[1];return c.int(r||o||l)?this._runesMasteriesRequest({endUrl:(r||o||l).join()+"/runes",region:i},d):Number.isInteger(r||s||o||u||l||m)?this._runesMasteriesRequest({endUrl:(r||s||o||u||l||m)+"/runes",region:i},d):c.string(g)?this.getSummoners({names:g,region:i},function(t,n){if(t)return d(t);var r=[],s=!0,o=!1,a=void 0;try{for(var u,l=g[Symbol.iterator]();!(s=(u=l.next()).done);s=!0){var m=u.value;r.push(n[e._sanitizeName(m)].id)}}catch(e){o=!0,a=e}finally{try{!s&&l.return&&l.return()}finally{if(o)throw a}}return e._runesMasteriesRequest({endUrl:r.join(",")+"/runes",region:i},d)}):"object"!==a(arguments[0])||"string"!=typeof g&&"string"!=typeof h?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||h,region:i},function(t,n){return t?d(t):e._runesMasteriesRequest({endUrl:n[e._sanitizeName(g||h)].id+"/runes",region:i},d)})}},{key:"getMasteries",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=t.region,r=t.ids,s=t.id,o=t.summonerIDs,u=t.summonerID,l=t.playerIDs,m=t.playerID,g=t.names,h=t.name,d=arguments[1];return c.int(r||o||l)?this._runesMasteriesRequest({endUrl:(r||o||l).join()+"/masteries",region:i},d):Number.isInteger(r||s||o||u||l||m)?this._runesMasteriesRequest({endUrl:(r||s||o||u||l||m)+"/masteries",region:i},d):c.string(g)?this.getSummoners({names:g,region:i},function(t,n){if(t)return d(t);var r=[],s=!0,o=!1,a=void 0;try{for(var u,l=g[Symbol.iterator]();!(s=(u=l.next()).done);s=!0){var m=u.value;r.push(n[e._sanitizeName(m)].id)}}catch(e){o=!0,a=e}finally{try{!s&&l.return&&l.return()}finally{if(o)throw a}}return e._runesMasteriesRequest({endUrl:r.join(",")+"/masteries",region:i},d)}):"object"!==a(arguments[0])||"string"!=typeof g&&"string"!=typeof h?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||h,region:i},function(t,n){return t?d(t):e._runesMasteriesRequest({endUrl:n[e._sanitizeName(g||h)].id+"/masteries",region:i},d)})}},{key:"getRankedStats",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=t.region,r=t.id,s=t.summonerID,o=t.playerID,u=t.name,l=t.options,m=arguments[1];return Number.isInteger(r||s||o)?this._statsRequest({endUrl:(r||s||o)+"/ranked",region:i,options:l},m):"object"===a(arguments[0])&&"string"==typeof u?this.getSummoner({name:u,region:i},function(t,n){return t?m(t):e._statsRequest({endUrl:n[e._sanitizeName(u)].id+"/ranked",region:i,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,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=t.region,r=t.id,s=t.summonerID,o=t.playerID,u=t.name,l=t.options,m=arguments[1];return Number.isInteger(r||s||o)?this._statsRequest({endUrl:(r||s||o)+"/summary",region:i,options:l},m):"object"===a(arguments[0])&&"string"==typeof u?this.getSummoner({name:u,region:i},function(t,n){return t?m(t):e._statsRequest({endUrl:n[e._sanitizeName(u)].id+"/summary",region:i,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,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=t.region,r=t.ids,s=t.id,o=t.summonerIDs,u=t.summonerID,l=t.playerIDs,m=t.playerID,g=t.names,h=t.name,d=arguments[1];return c.int(r||o||l)?this._summonerRequest({endUrl:""+(r||o||l).join(","),region:i},d):Number.isInteger(r||s||o||u||l||m)?this._summonerRequest({endUrl:""+(r||s||o||u||l||m),region:i},d):c.string(g)?this._summonerRequest({endUrl:"by-name/"+g.map(function(t){return e._sanitizeName(t)}).join(","),region:i | ||
},d):"object"!==a(arguments[0])||"string"!=typeof g&&"string"!=typeof h?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||h),region:i},d)}},{key:"getSummoner",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.id,r=e.summonerID,s=e.playerID,o=e.name,u=arguments[1];return Number.isInteger(i||r||s)?this.getSummoners({region:t,ids:[i||r||s]},u):"object"===a(arguments[0])&&"string"==typeof o?this.getSummoners({region:t,names:[o]},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]:{},t=e.region,i=e.ids,r=e.id,s=e.summonerIDs,o=e.summonerID,a=e.playerIDs,u=e.playerID,l=arguments[1];return c.int(i||s||a)?this._summonerRequest({endUrl:(i||s||a).join(",")+"/name",region:t},l):Number.isInteger(i||r||s||o||a||u)?this._summonerRequest({endUrl:(i||r||s||o||a||u)+"/name",region:t},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]:{},t=e.region,i=e.id,r=e.summonerID,s=e.playerID,o=arguments[1];if(Number.isInteger(i))return this.getSummonerNames({region:t,id:i||r||s},o);this._logError(this.getSummonerName.name,"required params "+n.yellow("`id/summonerID/playerID` (int)")+" not passed in")}}]),e}(),I={Kindred:R,REGIONS:h,LIMITS:m};e.exports=I}); | ||
!function(e,t){if("function"==typeof define&&define.amd)define("kindred-api",["module","double-ended-queue","xregexp","request","chalk","xregexp","query-string"],t);else if("undefined"!=typeof exports)t(module,require("double-ended-queue"),require("xregexp"),require("request"),require("chalk"),require("xregexp"),require("query-string"));else{var n={exports:{}};t(n,e.doubleEndedQueue,e.xregexp,e.request,e.chalk,e.xregexp,e.queryString),e.kindredApi=n.exports}}(this,function(e,t,n,i,r,s,o){"use strict";function a(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}var u="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},l=function(){function e(e,t){for(var n=0;n<t.length;n++){var i=t[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(e,i.key,i)}}return function(t,n,i){return n&&e(t.prototype,n),i&&e(t,i),t}}(),m=function(){function e(n,i){a(this,e),this.allowedRequests=n,this.seconds=i,this.madeRequests=new t}return l(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}(),g={DEV:[[10,10],[500,600]],PROD:[[3e3,10],[18e4,600]]},h={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"},p={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"},y={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},c=n("^[0-9\\p{L} _\\.]+$"),v={int:function(e){return e.every(function(e){return Number.isInteger(e)})},string:function(e){return e.every(function(e){return"string"==typeof e})}},f={int:function(e){return e&&Array.isArray(e)&&v.int(e)&&e.length>0},string:function(e){return e&&Array.isArray(e)&&v.string(e)&&e.length>0}},b=function(e){var t=!0,n=!1,i=void 0;try{for(var r,s=Object.keys(d)[Symbol.iterator]();!(t=(r=s.next()).done);t=!0){var o=r.value;if(d[o]===e)return!0}}catch(e){n=!0,i=e}finally{try{!t&&s.return&&s.return()}finally{if(n)throw i}}return!1},R={400:"Bad Request",403:"Forbidden",404:"Not Found",415:"Unsupported Media Type",429:"Rate Limit Exceeded",500:"Internal Service Error",503:"Service Unavailable"},I=function(e){var t=R[e];if(t)return t},_=function(e){return(Array.isArray(e)&&2!==e.length||!f.int(e[0])||2!==e[0].length||!f.int(e[1])||2!==e[1].length)&&"dev"!==e&&"prod"!==e},S=function(){function e(t){var n=t.key,i=t.defaultRegion,s=void 0===i?d.NORTH_AMERICA:i,o=t.debug,u=void 0!==o&&o,l=t.limits;if(a(this,e),this.key=n,this.defaultRegion=b(s)?s:void 0,this.defaultRegion||(console.log(""+r.red("Initialization of Kindred failed: "+r.yellow(s)+" is an invalid region.")),console.log(""+r.red("Try importing "+r.yellow("require('./dist/kindred-api').REGIONS")+" and using one of those values instead.")),process.exit(1)),this.debug=u,l){_(l)&&(console.log(r.red("Initialization of Kindred failed: Invalid "+r.yellow("limits")+". Valid examples: "+r.yellow("[[10, 10], [500, 600]]"))+"."),console.log(r.red("You can also pass in one of these two strings:")+" dev/prod "),console.log(""+r.red("and Kindred will set the limits appropriately.")),process.exit(1)),this.limits={},"dev"===l&&(l=g.DEV),"prod"===l&&(l=g.PROD);var h=!0,p=!1,y=void 0;try{for(var c,v=Object.keys(d)[Symbol.iterator]();!(h=(c=v.next()).done);h=!0){var f=c.value;this.limits[d[f]]=[new m(l[0][0],l[0][1]),new m(l[1][0],l[1][1])]}}catch(e){p=!0,y=e}finally{try{!h&&v.return&&v.return()}finally{if(p)throw y}}}this.Champion={getChampions:this.getChamps.bind(this),getAll:this.getChamps.bind(this),all:this.getChamps.bind(this),getChampion:this.getChamp.bind(this),get:this.getChamp.bind(this)},this.ChampionMastery={getChampionMastery:this.getChampMastery.bind(this),get:this.getChampMastery.bind(this),getChampionMasteries:this.getChampMasteries.bind(this),getAll:this.getChampMasteries.bind(this),all:this.getChampMasteries.bind(this),getTotalChampionMasteryScore:this.getTotalChampMasteryScore.bind(this),getTotalScore:this.getTotalChampMasteryScore.bind(this),totalScore:this.getTotalChampMasteryScore.bind(this),total:this.getTotalChampMasteryScore.bind(this),getTopChampions:this.getTopChamps.bind(this),top:this.getTopChamps.bind(this),best:this.getTopChamps.bind(this)},this.CurrentGame={getCurrentGame:this.getCurrentGame.bind(this),get:this.getCurrentGame.bind(this)},this.FeaturedGames={getFeaturedGames:this.getFeaturedGames.bind(this),get:this.getFeaturedGames.bind(this)},this.Game={getRecentGames:this.getRecentGames.bind(this),getRecent:this.getRecentGames.bind(this),get:this.getRecentGames.bind(this)},this.League={getLeagues:this.getLeagues.bind(this),get:this.getLeagues.bind(this),getLeagueEntries:this.getLeagueEntries.bind(this),getEntries:this.getLeagueEntries.bind(this),entries:this.getLeagueEntries.bind(this),getChallengers:this.getChallengers.bind(this),challengers:this.getChallengers.bind(this),getMasters:this.getMasters.bind(this),masters:this.getMasters.bind(this)},this.Static={getChampions:this.getChampionList.bind(this),champions:this.getChampionList.bind(this),getChampion:this.getChampion.bind(this),champion:this.getChampion.bind(this),getItems:this.getItems.bind(this),items:this.getItems.bind(this),getItem:this.getItem.bind(this),item:this.getItem.bind(this),getLanguageStrings:this.getLanguageStrings.bind(this),languageStrings:this.getLanguageStrings.bind(this),getLanguages:this.getLanguages.bind(this),languages:this.getLanguages.bind(this),getMap:this.getMap.bind(this),map:this.getMap.bind(this),getMasteries:this.getMasteryList.bind(this),masteries:this.getMasteryList.bind(this),getMastery:this.getMastery.bind(this),mastery:this.getMastery.bind(this),getRealmData:this.getRealmData.bind(this),realmData:this.getRealmData.bind(this),realm:this.getRealmData.bind(this),realms:this.getRealmData.bind(this),getRunes:this.getRuneList.bind(this),runes:this.getRuneList.bind(this),getRune:this.getRune.bind(this),rune:this.getRune.bind(this),getSummonerSpells:this.getSummonerSpells.bind(this),summonerSpells:this.getSummonerSpells.bind(this),spells:this.getSummonerSpells.bind(this),getSummonerSpell:this.getSummonerSpell.bind(this),summonerSpell:this.getSummonerSpell.bind(this),spell:this.getSummonerSpell.bind(this),getVersionData:this.getVersionData.bind(this),versionData:this.getVersionData.bind(this),version:this.getVersionData.bind(this),versions:this.getVersionData.bind(this)},this.Status={getShardStatus:this.getShardStatus.bind(this),getStatus:this.getShardStatus.bind(this),get:this.getShardStatus.bind(this),getShardList:this.getShardList.bind(this),getShards:this.getShardList.bind(this),getAll:this.getShardList.bind(this),all:this.getShardList.bind(this)},this.Match={getMatch:this.getMatch.bind(this),get:this.getMatch.bind(this)},this.MatchList={getMatchList:this.getMatchList.bind(this),get:this.getMatchList.bind(this)},this.RunesMasteries={getRunes:this.getRunes.bind(this),runes:this.getRunes.bind(this),getMasteries:this.getMasteries.bind(this),masteries:this.getMasteries.bind(this)},this.Runes={get:this.getRunes.bind(this)},this.Masteries={get:this.getMasteries.bind(this)},this.Stats={getRankedStats:this.getRankedStats.bind(this),ranked:this.getRankedStats.bind(this),getStatsSummary:this.getStatsSummary.bind(this),summary:this.getStatsSummary.bind(this)},this.Summoner={getSummoners:this.getSummoners.bind(this),getAll:this.getSummoners.bind(this),all:this.getSummoners.bind(this),getSummoner:this.getSummoner.bind(this),get:this.getSummoner.bind(this),getSummonerNames:this.getSummonerNames.bind(this),getNames:this.getSummonerNames.bind(this),names:this.getSummonerNames.bind(this),getSummonerName:this.getSummonerName.bind(this),getName:this.getSummonerName.bind(this),name:this.getSummonerName.bind(this)}}return l(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 "+r.yellow(e)+" is not valid. Request failed."),process.exit(1)}},{key:"_validName",value:function(e){return c.test(e)}},{key:"_makeUrl",value:function(e,t,n,i,r,s){var o=n?"":t+"/",a=i||r||s?"":"api/lol/"+o,u="https://"+t+".api.riotgames.com/"+a+encodeURI(e);return u+(u.lastIndexOf("?")===-1?"?":"&")+"api_key="+this.key}},{key:"_baseRequest",value:function(e,t){var n=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,h=void 0!==g&&g,d=e.staticReq,p=void 0!==d&&d,y=e.championMastery,c=void 0!==y&&y,v=e.options,f=void 0===v?{}:v,b=function(){return new Promise(function(e,a){var l=p?"global":u,g=o.stringify(f),d=g?"?"+g:"",y=n._makeUrl(s+d,l,p,m,h,c);if(n.limits){var v=n;!function t(n){v.canMakeRequest(u)?(p||(v.limits[u][0].addRequest(),v.limits[u][1].addRequest()),i({url:y},function(i,s,o){if(s&&o){var u=void 0,l=s.statusCode;if(l>=200&&l<300?u=r.green(l):l>=400&&l<500?u=r.red(l+" "+I(l)):l>=500&&(u=r.bold.red(l+" "+I(l))),v.debug&&(console.log(u,y),console.log({"x-app-rate-limit-count":s.headers["x-app-rate-limit-count"],"x-method-rate-limit-count":s.headers["x-method-rate-limit-count"],"x-rate-limit-count":s.headers["x-rate-limit-count"],"retry-after":s.headers["retry-after"]}),console.log()),n)return l>=500&&(v.debug&&console.log("!!! resending request !!!"),setTimeout(function(){t.bind(v)(n)},1e3)),429===l&&(v.debug&&console.log("!!! resending request !!!"),setTimeout(function(){t.bind(v)(n)},1e3*s.headers["retry-after"]+50)),l>=400?n(u+" : "+r.yellow(y)):n(i,JSON.parse(o));if(500===l)v.debug&&console.log("!!! resending promise request !!!"),setTimeout(function(){return a("retry")},1e3);else{if(429!==l)return i||l>=400?a("err:",i,l):e(JSON.parse(o));v.debug&&console.log("!!! resending promise request !!!"),setTimeout(function(){return a("retry")},1e3*s.headers["retry-after"]+50)}}else console.log(i,y)})):setTimeout(function(){t.bind(v)(n)},1e3)}(t)}else i({url:y},function(i,s,o){if(s){var u=void 0,l=s.statusCode;return l>=200&&l<300?u=r.green(l):l>=400&&l<500?u=r.red(l+" "+I(l)):l>=500&&(u=r.bold.red(l+" "+I(l))),n.debug&&(console.log(s&&u,y),console.log({"x-app-rate-limit-count":s.headers["x-app-rate-limit-count"],"x-method-rate-limit-count":s.headers["x-method-rate-limit-count"],"x-rate-limit-count":s.headers["x-rate-limit-count"],"retry-after":s.headers["retry-after"]})),t?l>=400?t(u+" : "+r.yellow(y)):t(i,JSON.parse(o)):i?a("err:",i):e(JSON.parse(o))}console.log(i,y)})})};return t?b():b().catch(b).catch(b).catch(b).then(function(e){return e})}},{key:"_observerRequest",value:function(e,t){var n=e.endUrl,i=e.region;return this._baseRequest({endUrl:"observer-mode/rest/"+n,observerMode:!0,region:i},t)}},{key:"_championRequest",value:function(e,t){var n=e.endUrl,i=e.region,r=e.options;return this._baseRequest({endUrl:"v"+y.CHAMPION+"/"+n,region:i,options:r},t)}},{key:"_championMasteryRequest",value:function(e,t){var n=e.endUrl,i=e.region,r=e.options;return this._baseRequest({endUrl:"championmastery/location/"+n,region:i,options:r,championMastery:!0},t)}},{key:"_currentGameRequest",value:function(e,t){var n=e.endUrl,i=e.region,r=e.platformId;return this._observerRequest({endUrl:"consumer/getSpectatorGameInfo/"+r+"/"+n,region:i},t)}},{key:"_staticRequest",value:function(e,t){var n=e.endUrl,i=e.region,r=void 0===i?this.defaultRegion:i,s=e.options;return this._baseRequest({endUrl:"static-data/"+r+"/v"+y.STATIC_DATA+"/"+n,staticReq:!0,region:r,options:s},t)}},{key:"_statusRequest",value:function(e,t){var n=e.endUrl,i=(e.region,e.options);return this._baseRequest({endUrl:"lol/status/v"+y.STATUS+"/"+n,status:!0,options:i},t)}},{key:"_gameRequest",value:function(e,t){var n=e.endUrl,i=e.region;return this._baseRequest({endUrl:"v"+y.GAME+"/game/"+n,region:i},t)}},{key:"_leagueRequest",value:function(e,t){var n=e.endUrl,i=e.region,r=e.options;return this._baseRequest({endUrl:"v"+y.LEAGUE+"/league/"+n,region:i,options:r},t)}},{key:"_matchRequest",value:function(e,t){var n=e.endUrl,i=e.region,r=e.options;return this._baseRequest({endUrl:"v"+y.MATCH+"/match/"+n,region:i,options:r},t)}},{key:"_matchListRequest",value:function(e,t){var n=e.endUrl,i=e.region,r=e.options;return this._baseRequest({endUrl:"v"+y.MATCH_LIST+"/matchlist/by-summoner/"+n,region:i,options:r},t)}},{key:"_runesMasteriesRequest",value:function(e,t){var n=e.endUrl,i=e.region;return this._summonerRequest({endUrl:n,region:i},t)}},{key:"_statsRequest",value:function(e,t){var n=e.endUrl,i=e.region,r=e.options;return this._baseRequest({endUrl:"v"+y.STATS+"/stats/by-summoner/"+n,region:i,options:r},t)}},{key:"_summonerRequest",value:function(e,t){var n=e.endUrl,i=e.region;return this._baseRequest({endUrl:"v"+y.SUMMONER+"/summoner/"+n,region:i},t)}},{key:"_logError",value:function(e,t){console.log(r.bold.yellow(e),r.red("request"),r.bold.red("FAILED")+r.red("; "+t))}},{key:"setRegion",value:function(e){this.defaultRegion=e}},{key:"getChamps",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.options,i=arguments[1];return this._championRequest({endUrl:"champion",region:t,options:n},i=2===arguments.length?i:arguments[0])}},{key:"getChamp",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.id,i=e.championID,s=arguments[1];return Number.isInteger(n)||Number.isInteger(i)?this._championRequest({endUrl:"champion/"+(n||i),region:t},s):this._logError(this.getChamp.name,"required params "+r.yellow("`id/championID` (int)")+" not passed in")}},{key:"getChampMastery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=void 0===t?this.defaultRegion:t,i=e.playerID,s=e.championID,o=e.options,a=arguments[1];if(Number.isInteger(i)&&Number.isInteger(s)){var u=h[p[n]];return this._championMasteryRequest({endUrl:u+"/player/"+i+"/champion/"+s,region:n,options:o},a)}return this._logError(this.getChampMastery.name,"required params "+r.yellow("`playerID` (int) AND `championID` (int)")+" not passed in")}},{key:"getChampMasteries",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.region,i=void 0===n?this.defaultRegion:n,s=t.id,o=t.summonerID,a=t.playerID,l=t.name,m=t.options,g=arguments[1];if(Number.isInteger(s||o||a)){var d=h[p[i]];return this._championMasteryRequest({endUrl:d+"/player/"+(s||o||a)+"/champions",region:i,options:m},g)}if("object"===u(arguments[0])&&"string"==typeof l){var y=h[p[i]];return new Promise(function(t,n){return e.getSummoner({name:l,region:i},function(r,s){return r?void(g?g(r):n(r)):t(e._championMasteryRequest({endUrl:y+"/player/"+s[e._sanitizeName(l)].id+"/champions",region:i},g))})})}return this._logError(this.getChampMasteries.name,"required params "+r.yellow("`id/summonerID/playerID` (int)")+" or "+r.yellow("`name` (str)")+" not passed in")}},{key:"getTotalChampMasteryScore",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.region,i=void 0===n?this.defaultRegion:n,s=t.id,o=t.summonerID,a=t.playerID,l=t.name,m=t.options,g=arguments[1];if(Number.isInteger(s||o||a)){var d=h[p[i]];return this._championMasteryRequest({endUrl:d+"/player/"+(s||o||a)+"/score",region:i,options:m},g)}if("object"===u(arguments[0])&&"string"==typeof l){var y=h[p[i]];return new Promise(function(t,n){return e.getSummoner({name:l,region:i},function(r,s){return r?void(g?g(r):n(r)):t(e._championMasteryRequest({endUrl:y+"/player/"+s[e._sanitizeName(l)].id+"/score",region:i},g))})})}return this._logError(this.getTotalChampMasteryScore.name,"required params "+r.yellow("`id/summonerID/playerID` (int)")+" or "+r.yellow("`name` (str)")+" not passed in")}},{key:"getTopChamps",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.region,i=void 0===n?this.defaultRegion:n,s=t.id,o=t.summonerID,a=t.playerID,l=t.name,m=t.options,g=arguments[1];if(Number.isInteger(s||o||a)){var d=h[p[i]];return this._championMasteryRequest({endUrl:d+"/player/"+(s||o||a)+"/topchampions",region:i,options:m},g)}if("object"===u(arguments[0])&&"string"==typeof l){var y=h[p[i]];return new Promise(function(t,n){return e.getSummoner({name:l,region:i},function(r,s){return r?void(g?g(r):n(r)):t(e._championMasteryRequest({endUrl:y+"/player/"+s[e._sanitizeName(l)].id+"/topchampions",region:i},g))})})}return this._logError(this.getTopChamps.name,"required params "+r.yellow("`id/summonerID/playerID` (int)")+" or "+r.yellow("`name` (str)")+" not passed in")}},{key:"getCurrentGame",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.region,i=void 0===n?this.defaultRegion:n,s=t.id,o=t.summonerID,a=t.playerID,l=t.name,m=arguments[1],g=h[p[i]];return Number.isInteger(s||o||a)?this._currentGameRequest({endUrl:""+(s||o||a),platformId:g,region:i},m):"object"===u(arguments[0])&&"string"==typeof l?new Promise(function(t,n){return e.getSummoner({name:l,region:i},function(r,s){return r?void(m?m(r):n(r)):t(e._currentGameRequest({endUrl:""+s[e._sanitizeName(l)].id,platformId:g,region:i},m))})}):this._logError(this.getCurrentGame.name,"required params "+r.yellow("`id/summonerID/playerID` (int)")+" or "+r.yellow("`name` (string)")+" not passed in")}},{key:"getFeaturedGames",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=arguments[1];return this._observerRequest({endUrl:"featured",region:t},n=t?n:arguments[0])}},{key:"getRecentGames",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.region,i=t.id,s=t.summonerID,o=t.playerID,a=t.name,l=arguments[1];return Number.isInteger(i||s||o)?this._gameRequest({endUrl:"by-summoner/"+(i||s||o)+"/recent",region:n},l):"object"===u(arguments[0])&&"string"==typeof a?new Promise(function(t,i){return e.getSummoner({name:a,region:n},function(r,s){return r?void(l?l(r):i(r)):t(e._gameRequest({endUrl:"by-summoner/"+s[e._sanitizeName(a)].id+"/recent",region:n},l))})}):this._logError(this.getRecentGames.name,"required params "+r.yellow("`id/summonerID/playerID` (int)")+" or "+r.yellow("`name` (string)")+" not passed in")}},{key:"getLeagues",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.region,i=t.ids,s=t.summonerIDs,o=t.playerIDs,a=t.id,l=t.summonerID,m=t.playerID,g=t.names,h=t.name,d=t.options,p=arguments[1];return f.int(i||s||o)?this._leagueRequest({endUrl:"by-summoner/"+(i||s||o).join(","),region:n,options:d},p):Number.isInteger(i||a||s||l||o||m)?this._leagueRequest({endUrl:"by-summoner/"+(i||a||s||l||o||m),region:n,options:d},p):f.string(g)?new Promise(function(t,i){return e.getSummoners({names:g,region:n},function(r,s){if(r)return void(p?p(r):i(r));var o=[],a=!0,u=!1,l=void 0;try{for(var m,h=g[Symbol.iterator]();!(a=(m=h.next()).done);a=!0){var y=m.value;o.push(s[e._sanitizeName(y)].id)}}catch(e){u=!0,l=e}finally{try{!a&&h.return&&h.return()}finally{if(u)throw l}}return t(e._leagueRequest({endUrl:"by-summoner/"+o.join(","),region:n,options:d},p))})}):"object"!==u(arguments[0])||"string"!=typeof g&&"string"!=typeof h?this._logError(this.getLeagues.name,"required params "+r.yellow("`ids/summonerIDs/playerIDs` ([int]/int)")+", "+r.yellow("`id/summonerID/playerID` (int)")+", "+r.yellow("`names` ([str]/str)")+", or "+r.yellow("`name` (str)")+" not passed in"):new Promise(function(t,i){return e.getSummoner({name:g||h,region:n},function(r,s){return r?void(p?p(r):i(r)):t(e._leagueRequest({endUrl:"by-summoner/"+s[e._sanitizeName(g||h)].id,region:n,options:d},p))})})}},{key:"getLeagueEntries",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.region,i=t.ids,s=t.summonerIDs,o=t.playerIDs,a=t.id,l=t.summonerID,m=t.playerID,g=t.names,h=t.name,d=arguments[1];return f.int(i||s||o)?this._leagueRequest({endUrl:"by-summoner/"+(i||s||o).join(",")+"/entry",region:n},d):Number.isInteger(i||a||s||l||o||m)?this._leagueRequest({endUrl:"by-summoner/"+(i||a||s||l||o||m)+"/entry",region:n},d):f.string(g)?new Promise(function(t,i){return e.getSummoners({names:g,region:n},function(r,s){if(r)return void(d?d(r):i(r));var o=[],a=!0,u=!1,l=void 0;try{for(var m,h=g[Symbol.iterator]();!(a=(m=h.next()).done);a=!0){var p=m.value;o.push(s[e._sanitizeName(p)].id)}}catch(e){u=!0,l=e}finally{try{!a&&h.return&&h.return()}finally{if(u)throw l}}return t(e._leagueRequest({endUrl:"by-summoner/"+o.join(",")+"/entry",region:n},d))})}):"object"!==u(arguments[0])||"string"!=typeof g&&"string"!=typeof h?void this._logError(this.getLeagueEntries.name,"required params "+r.yellow("`ids/summonerIDs/playerIDs` ([int]/int)")+", "+r.yellow("`id/summonerID/playerID` (int)")+", "+r.yellow("`names` ([str]/str)")+", or "+r.yellow("`name` (str)")+" not passed in"):new Promise(function(t,i){return e.getSummoner({name:g||h,region:n},function(r,s){return r?void(d?d(r):i(r)):t(e._leagueRequest({endUrl:"by-summoner/"+s[e._sanitizeName(g||h)].id+"/entry",region:n},d))})})}},{key:"getChallengers",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.options,i=void 0===n?{type:"RANKED_SOLO_5x5"}:n,r=arguments[1];return this._leagueRequest({endUrl:"challenger",region:t,options:i},r=2===arguments.length?r:arguments[0])}},{key:"getMasters",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.options,i=void 0===n?{type:"RANKED_SOLO_5x5"}:n,r=arguments[1];return this._leagueRequest({endUrl:"master",region:t,options:i},r=2===arguments.length?r:arguments[0])}},{key:"getChampionList",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.options,i=arguments[1];return this._staticRequest({endUrl:"champion",region:t,options:n},i=2===arguments.length?i:arguments[0])}},{key:"getChampion",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.id,i=e.championID,s=e.options,o=arguments[1];return Number.isInteger(n||i)?this._staticRequest({endUrl:"champion/"+(n||i),region:t,options:s},o):this._logError(this.getChampion.name,"required params "+r.yellow("`id/championID` (int)")+" not passed in")}},{key:"getItems",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.options,i=arguments[1];return this._staticRequest({endUrl:"item",region:t,options:n},i=2===arguments.length?i:arguments[0])}},{key:"getItem",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.id,i=e.itemID,s=e.options,o=arguments[1];return Number.isInteger(n||i)?this._staticRequest({endUrl:"item/"+(n||i),region:t,options:s},o):this._logError(this.getItem.name,"required params "+r.yellow("`id/itemID` (int)")+" not passed in")}},{key:"getLanguageStrings",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.options,i=arguments[1];return this._staticRequest({endUrl:"language-strings",region:t,options:n},i=2===arguments.length?i:arguments[0])}},{key:"getLanguages",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=arguments[1];return this._staticRequest({endUrl:"languages",region:t},n=t?n:arguments[0])}},{key:"getMap",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.options,i=arguments[1];return this._staticRequest({endUrl:"map",region:t,options:n},i=2===arguments.length?i:arguments[0])}},{key:"getMasteryList",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.options,i=arguments[1];return this._staticRequest({endUrl:"mastery",region:t,options:n},i=2===arguments.length?i:arguments[0])}},{key:"getMastery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.id,i=e.masteryID,s=e.options,o=arguments[1];return Number.isInteger(n||i)?this._staticRequest({endUrl:"mastery/"+(n||i),region:t,options:s},o):this._logError(this.getMastery.name,"required params "+r.yellow("`id/masteryID` (int)")+" not passed in")}},{key:"getRealmData",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=arguments[1];return this._staticRequest({endUrl:"realm",region:t},n=t?n:arguments[0])}},{key:"getRuneList",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.options,i=arguments[1];return this._staticRequest({endUrl:"rune",region:t,options:n},i=2===arguments.length?i:arguments[0])}},{key:"getRune",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.id,i=e.runeID,s=e.options,o=arguments[1];return Number.isInteger(n||i)?this._staticRequest({endUrl:"rune/"+(n||i),region:t,options:s},o):this._logError(this.getRune.name,"required params "+r.yellow("`id/runeID` (int)")+" not passed in")}},{key:"getSummonerSpells",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.options,i=arguments[1];return this._staticRequest({endUrl:"summoner-spell",region:t,options:n},i=2===arguments.length?i:arguments[0])}},{key:"getSummonerSpell",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.id,i=e.spellID,s=e.summonerSpellID,o=e.options,a=arguments[1];return Number.isInteger(n||i||s)?this._staticRequest({endUrl:"summoner-spell/"+(n||i||s),region:t,options:o},a):this._logError(this.getSummonerSpell.name,"required params "+r.yellow("`id/spellID/summonerSpellID` (int)")+" not passed in")}},{key:"getVersionData",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.options,i=arguments[1];return this._staticRequest({endUrl:"versions",region:t,options:n},i=2===arguments.length?i:arguments[0])}},{key:"getShardStatus",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=arguments[1];return this._statusRequest({endUrl:"shard",region:t},n=t?n:arguments[0])}},{key:"getShardList",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=arguments[1];return this._statusRequest({endUrl:"shards",region:t},n=t?n:arguments[0])}},{key:"getMatch",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.id,i=e.matchID,s=e.options,o=void 0===s?{includeTimeline:!0}:s,a=arguments[1];return Number.isInteger(n||i)?this._matchRequest({endUrl:""+(n||i),region:t,options:o},a):this._logError(this.getMatch.name,"required params "+r.yellow("`id/matchID` (int)")+" not passed in")}},{key:"getMatchList",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.region,i=t.id,s=t.summonerID,o=t.playerID,a=t.name,l=t.options,m=void 0===l?{rankedQueues:"RANKED_SOLO_5x5"}:l,g=arguments[1];return Number.isInteger(i||s||o)?this._matchListRequest({endUrl:""+(i||s||o),region:n,options:m},g):"object"===u(arguments[0])&&"string"==typeof a?new Promise(function(t,i){return e.getSummoner({name:a,region:n},function(r,s){return r?void(g?g(r):i(r)):t(e._matchListRequest({endUrl:""+s[e._sanitizeName(a)].id,region:n,options:m},g))})}):this._logError(this.getMatchList.name,"required params "+r.yellow("`id/summonerID/playerID` (int)")+" or "+r.yellow("`name` (str)")+" not passed in")}},{key:"getRunes",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.region,i=t.ids,s=t.summonerIDs,o=t.playerIDs,a=t.id,l=t.summonerID,m=t.playerID,g=t.names,h=t.name,d=arguments[1];return f.int(i||s||o)?this._runesMasteriesRequest({endUrl:(i||s||o).join()+"/runes",region:n},d):Number.isInteger(i||a||s||l||o||m)?this._runesMasteriesRequest({endUrl:(i||a||s||l||o||m)+"/runes",region:n},d):f.string(g)?new Promise(function(t,i){return e.getSummoners({names:g,region:n},function(r,s){if(r)return void(d?d(r):i(r));var o=[],a=!0,u=!1,l=void 0;try{for(var m,h=g[Symbol.iterator]();!(a=(m=h.next()).done);a=!0){var p=m.value;o.push(s[e._sanitizeName(p)].id)}}catch(e){u=!0,l=e}finally{try{!a&&h.return&&h.return()}finally{if(u)throw l}}return t(e._runesMasteriesRequest({endUrl:o.join(",")+"/runes",region:n},d))})}):"object"!==u(arguments[0])||"string"!=typeof g&&"string"!=typeof h?this._logError(this.getRunes.name,"required params "+r.yellow("`ids/summonerIDs/playerIDs` ([int]/int)")+", "+r.yellow("`id/summonerID/playerID` (int)")+", "+r.yellow("`names` ([str]/str)")+", or "+r.yellow("`name` (str)")+" not passed in"):new Promise(function(t,i){return e.getSummoner({name:g||h,region:n},function(r,s){return r?void(d?d(r):i(r)):t(e._runesMasteriesRequest({endUrl:s[e._sanitizeName(g||h)].id+"/runes",region:n},d))})})}},{key:"getMasteries",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.region,i=t.ids,s=t.summonerIDs,o=t.playerIDs,a=t.id,l=t.summonerID,m=t.playerID,g=t.names,h=t.name,d=arguments[1];return f.int(i||s||o)?this._runesMasteriesRequest({endUrl:(i||s||o).join()+"/masteries",region:n},d):Number.isInteger(i||a||s||l||o||m)?this._runesMasteriesRequest({endUrl:(i||a||s||l||o||m)+"/masteries",region:n},d):f.string(g)?new Promise(function(t,i){return e.getSummoners({names:g,region:n},function(r,s){if(r)return void(d?d(r):i(r));var o=[],a=!0,u=!1,l=void 0;try{for(var m,h=g[Symbol.iterator]();!(a=(m=h.next()).done);a=!0){var p=m.value;o.push(s[e._sanitizeName(p)].id)}}catch(e){u=!0,l=e}finally{try{!a&&h.return&&h.return()}finally{if(u)throw l}}return t(e._runesMasteriesRequest({endUrl:o.join(",")+"/masteries",region:n},d))})}):"object"!==u(arguments[0])||"string"!=typeof g&&"string"!=typeof h?this._logError(this.getMasteries.name,"required params "+r.yellow("`ids/summonerIDs/playerIDs` ([int]/int)")+", "+r.yellow("`id/summonerID/playerID` (int)")+", "+r.yellow("`names` ([str]/str)")+", or "+r.yellow("`name` (str)")+" not passed in"):new Promise(function(t,i){return e.getSummoner({name:g||h,region:n},function(r,s){return r?void(d?d(r):i(r)):t(e._runesMasteriesRequest({endUrl:s[e._sanitizeName(g||h)].id+"/masteries",region:n},d))})})}},{key:"getRankedStats",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.region,i=t.id,s=t.summonerID,o=t.playerID,a=t.name,l=t.options,m=arguments[1];return Number.isInteger(i||s||o)?this._statsRequest({endUrl:(i||s||o)+"/ranked",region:n,options:l},m):"object"===u(arguments[0])&&"string"==typeof a?new Promise(function(t,i){return e.getSummoner({name:a,region:n},function(r,s){return r?void(m?m(r):i(r)):t(e._statsRequest({endUrl:s[e._sanitizeName(a)].id+"/ranked",region:n,options:l},m))})}):void this._logError(this.getRankedStats.name,"required params "+r.yellow("`id/summonerID/playerID` (int)")+" or "+r.yellow("`name` (string)")+" not passed in")}},{key:"getStatsSummary",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.region,i=t.id,s=t.summonerID,o=t.playerID,a=t.name,l=t.options,m=arguments[1];return Number.isInteger(i||s||o)?this._statsRequest({endUrl:(i||s||o)+"/summary",region:n,options:l},m):"object"===u(arguments[0])&&"string"==typeof a?new Promise(function(t,i){ | ||
return e.getSummoner({name:a,region:n},function(r,s){return r?void(m?m(r):i(r)):t(e._statsRequest({endUrl:s[e._sanitizeName(a)].id+"/summary",region:n,options:l},m))})}):void this._logError(this.getRankedStats.name,"required params "+r.yellow("`id/summonerID/playerID` (int)")+" or "+r.yellow("`name` (string)")+" not passed in")}},{key:"getSummoners",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.region,i=t.ids,s=t.summonerIDs,o=t.playerIDs,a=t.id,l=t.summonerID,m=t.playerID,g=t.names,h=t.name,d=arguments[1];return f.int(i||s||o)?this._summonerRequest({endUrl:""+(i||s||o).join(","),region:n},d):Number.isInteger(i||a||s||l||o||m)?this._summonerRequest({endUrl:""+(i||a||s||l||o||m),region:n},d):f.string(g)?this._summonerRequest({endUrl:"by-name/"+g.map(function(t){return e._sanitizeName(t)}).join(","),region:n},d):"object"!==u(arguments[0])||"string"!=typeof g&&"string"!=typeof h?void this._logError(this.getSummoners.name,"required params "+r.yellow("`ids/summonerIDs/playerIDs` ([int]/int)")+", "+r.yellow("`id/summonerID/playerID` (int)")+", "+r.yellow("`names` ([str]/str)")+", or "+r.yellow("`name` (str)")+" not passed in"):this._summonerRequest({endUrl:"by-name/"+this._sanitizeName(g||h),region:n},d)}},{key:"getSummoner",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.id,i=e.summonerID,s=e.playerID,o=e.name,a=arguments[1];return Number.isInteger(n||i||s)?this.getSummoners({region:t,ids:[n||i||s]},a):"object"===u(arguments[0])&&"string"==typeof o?this.getSummoners({region:t,names:[o]},a):this._logError(this.getSummoner.name,"required params "+r.yellow("`id/summonerID/playerID` (int)")+" or "+r.yellow("`name` (string)")+" not passed in")}},{key:"getSummonerNames",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.ids,i=e.summonerIDs,s=e.playerIDs,o=e.id,a=e.summonerID,u=e.playerID,l=arguments[1];return f.int(n||i||s)?this._summonerRequest({endUrl:(n||i||s).join(",")+"/name",region:t},l):Number.isInteger(n||o||i||a||s||u)?this._summonerRequest({endUrl:(n||o||i||a||s||u)+"/name",region:t},l):void this._logError(this.getSummonerNames.name,"required params "+r.yellow("required params `ids/summonerIDs/playerIDs` ([int]/int)")+" or "+r.yellow("`id/summonerID/playerID` (int)")+" not passed in")}},{key:"getSummonerName",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.id,i=e.summonerID,s=e.playerID,o=arguments[1];if(Number.isInteger(n))return this.getSummonerNames({region:t,id:n||i||s},o);this._logError(this.getSummonerName.name,"required params "+r.yellow("`id/summonerID/playerID` (int)")+" not passed in")}}]),e}(),q={Kindred:S,REGIONS:d,LIMITS:g};e.exports=q}); |
{ | ||
"name": "kindred-api", | ||
"version": "1.2.2", | ||
"version": "1.2.3", | ||
"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", |
@@ -21,3 +21,3 @@ # Kindred | ||
Hopefully there aren't *too* many bugs! ***I'm a noob after all, so use this library at your own risk.*** I'm currently focusing on refactoring the code now. The docs are not fully updated yet. | ||
Hopefully there aren't *too* many bugs! I'm currently focusing on refactoring the code now. | ||
@@ -209,7 +209,7 @@ ## Philosophy | ||
* getSummonerSpells({ region, options (object) }, cb) | ||
* Namespaced Functions: *Static.getSummonerSpells, Static.summonerSpells, Summoner.spells* | ||
* Namespaced Functions: *Static.getSummonerSpells, Static.summonerSpells, Static.spells* | ||
14. **/api/lol/static-data/{region}/v1.2/summoner-spell/{id}** | ||
* Retrieves summoner spell by its unique id. (REST) | ||
* getSummonerSpell({ region, id/spellID/summonerSpellID (int), options (object) }, cb) | ||
* Namespaced Functions: *Static.getSummonerSpell, Static.summonerSpell, Summoner.spell* | ||
* Namespaced Functions: *Static.getSummonerSpell, Static.summonerSpell, Static.spell* | ||
15. **/api/lol/static-data/{region}/v1.2/versions** | ||
@@ -258,3 +258,3 @@ * Retrieve version data. (REST) | ||
* getMasteries({ region, ids/summonerIDs/playerIDs ([int]/int), id/summonerID/playerID (int), names ([str]/str), name (str)}, cb) | ||
* Namespaced Functions: *RunesMasteries.getRunes, RunesMasteries.runes* | ||
* Namespaced Functions: *RunesMasteries.getRunes, RunesMasteries.runes, Runes.get* | ||
* Example 1: ```k.RunesMasteries.runes({ id: 20026563 }, rprint)``` | ||
@@ -264,3 +264,3 @@ 2. **/api/lol/{region}/v1.4/summoner/{summonerIds}/runes** | ||
* getRunes({ region, ids/summonerIDs/playerIDs ([int]/int), id/summonerID/playerID (int), names ([str]/str), name (str) }, cb) | ||
* Namespaced Functions: *RunesMasteries.getMasteries, RunesMasteries.masteriesi* | ||
* Namespaced Functions: *RunesMasteries.getMasteries, RunesMasteries.masteries, Masteries.get* | ||
* Example 1: ```k.RunesMasteries.masteries({ id: 20026563 }, rprint)``` | ||
@@ -345,2 +345,4 @@ | ||
// getSummoners request FAILED; required params `ids` (array of ints), `id` (int), `names` (array of strings), or `name` (string) not passed in | ||
k.Summoner.get(rprint) | ||
// same as above | ||
@@ -355,2 +357,4 @@ k.getSummoner(rprint) | ||
// getChampMastery request FAILED; required params `playerID` (int) AND `championID` (int) not passed in | ||
k.ChampionMastery.get(rprint) | ||
// same as above | ||
@@ -369,3 +373,6 @@ /* | ||
k.getChallengers(rprint) // default region, default solo queue mode, valid | ||
k.League.challengers(rprint) // same as above | ||
k.getRuneList(rprint) // only optional arguments & not passing in any optional arguments, valid | ||
k.Static.runes(rprint) | ||
@@ -475,2 +482,5 @@ /* | ||
.catch(err => console.error(err)) | ||
k.Runes.get({ id: 354959 }) | ||
.then(json => console.log(json)) | ||
.catch(err => console.log(err)) | ||
@@ -484,10 +494,10 @@ /* | ||
*/ | ||
var names2 = ['Richelle', 'Grigne'] | ||
k.getSummoners({ names: names2 }, function (err, data) { | ||
var args = [] | ||
names = ['Richelle', 'Grigne'] | ||
k.getSummoners({ names }, function (err, data) { | ||
var ids = [] | ||
for (var name of names2) | ||
args.push(data[name.replace(/\s/g, '').toLowerCase()].id) | ||
for (var name of names) | ||
ids.push(data[name.replace(/\s/g, '').toLowerCase()].id) | ||
k.getRunes({ ids: args }, rprint) | ||
k.getRunes({ ids }, rprint) | ||
}) | ||
@@ -501,16 +511,15 @@ | ||
k.getLeagues({ names: ['Richelle', 'Grigne'] }, rprint) | ||
/* Note: I handle that platform id stuffs. */ | ||
k.getCurrentGame({ name: 'Fràe', region: REGIONS.OCEANIA }, rprint) | ||
k.getLeagues({ names: ['Richelle', 'Grigne'] }) | ||
.then(data => console.log(data)) | ||
var name = 'Grigne' | ||
k.RunesMasteries.runes({ name }) | ||
.then(data => console.log(data)) | ||
k.Runes.get({ name }) | ||
.then(data => console.log(data)) | ||
k.Masteries.get({ name }) | ||
.then(data => console.log(data)) | ||
/* | ||
WARNING: Currently promises are bugged for these type of chained requests | ||
since I don't fully understand them yet. You'll have to chain for promises | ||
still. | ||
*/ | ||
var ctzName = 'contractz' | ||
k.getSummoner({ name: ctzName }) | ||
.then(json => k.getMasteries({ id: json[ctzName].id })) | ||
.then(json => console.log(json)) | ||
/* | ||
Functions will have an options parameter that you can pass in query | ||
@@ -546,7 +555,7 @@ strings when applicable. Values of options should match the | ||
According to Riot API, query parameters that can accept multiple values | ||
must be a comma separated list (or a single value), which is why I do the above 'join'. | ||
must be a comma separated list (or a single value), which is why I do the below 'join'. | ||
You can also simply do 'RANKED_SOLO_5x5, RANKED_FLEX_SR'. | ||
You can also simply do 'RANKED_SOLO_5x5,RANKED_FLEX_SR'. | ||
*/ | ||
rankedQueues: ['RANKED_SOLO_5x5', 'RANKED_FLEX_SR'].join(), | ||
rankedQueues: ['RANKED_SOLO_5x5', 'RANKED_FLEX_SR'].join(','), | ||
championIds: '67' // '267,67' or ['267', '67'].join(',') | ||
@@ -557,2 +566,19 @@ } }, rprint) | ||
/* The above example with promises. */ | ||
var name = 'caaaaaaaaaria' | ||
var opts = { | ||
region: 'na', | ||
options: { | ||
rankedQueues: ['RANKED_SOLO_5x5', 'RANKED_FLEX_SR'].join(','), | ||
championIDs: '67' | ||
} | ||
} | ||
k.getSummoner({ name, region: opts.region }) | ||
.then(data => k.getMatchList( | ||
Object.assign({ id: data[name].id }, opts) | ||
)) | ||
.then(data => console.log(data)) | ||
.catch(err => console.err(error)) | ||
var furyMasteryId = 6111 | ||
@@ -559,0 +585,0 @@ k.getMastery({ id: furyMasteryId }, rprint) |
@@ -14,7 +14,9 @@ const request = require('request') | ||
import re from './constants/valid-summoner-name-regex' | ||
import checkAll from './helpers/array-checkers' | ||
import checkValidRegion from './helpers/check-valid-region' | ||
import getResponseMessage from './helpers/get-response-message' | ||
import invalidLimits from './helpers/limits-checker' | ||
const re = XRegExp('^[0-9\\p{L} _\\.]+$') | ||
class Kindred { | ||
@@ -24,12 +26,4 @@ constructor({ key, defaultRegion = REGIONS.NORTH_AMERICA, debug = false, limits }) { | ||
let foundRegion | ||
this.defaultRegion = checkValidRegion(defaultRegion) ? defaultRegion : undefined | ||
for (const region of Object.keys(REGIONS)) { | ||
if (REGIONS[region] === defaultRegion) { | ||
foundRegion = true | ||
} | ||
} | ||
this.defaultRegion = foundRegion ? defaultRegion : undefined | ||
if (!this.defaultRegion) { | ||
@@ -44,5 +38,3 @@ console.log(`${chalk.red(`Initialization of Kindred failed: ${chalk.yellow(defaultRegion)} is an invalid region.`)}`) | ||
if (limits) { | ||
const 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 (invalid) { | ||
if (invalidLimits(limits)) { | ||
console.log(`${chalk.red(`Initialization of Kindred failed: Invalid ${chalk.yellow('limits')}. Valid examples: ${chalk.yellow('[[10, 10], [500, 600]]')}`)}.`) | ||
@@ -207,2 +199,10 @@ console.log(`${(chalk.red('You can also pass in one of these two strings:'))} dev/prod `) | ||
this.Runes = { | ||
get: this.getRunes.bind(this) | ||
} | ||
this.Masteries = { | ||
get: this.getMasteries.bind(this) | ||
} | ||
this.Stats = { | ||
@@ -235,7 +235,3 @@ getRankedStats: this.getRankedStats.bind(this), | ||
canMakeRequest(region) { | ||
if (!this.limits[region][0].requestAvailable() || !this.limits[region][1].requestAvailable()) { | ||
return false | ||
} | ||
return true | ||
return !(!this.limits[region][0].requestAvailable() || !this.limits[region][1].requestAvailable()) | ||
} | ||
@@ -262,18 +258,18 @@ | ||
const prefix = !status && !observerMode && !championMastery ? `api/lol/${mid}` : '' | ||
let url = `https://${region}.api.riotgames.com/${prefix}${encodeURI(query)}` | ||
if (url.lastIndexOf('?') === -1) url += '?' | ||
else url += '&' | ||
url += `api_key=${this.key}` | ||
return url | ||
return url + (url.lastIndexOf('?') === -1 ? '?' : '&') + `api_key=${this.key}` | ||
} | ||
_baseRequest({ endUrl, region = this.defaultRegion, status = false, observerMode = false, staticReq = false, championMastery = false, options = {} }, cb) { | ||
_baseRequest({ | ||
endUrl, | ||
region = this.defaultRegion, | ||
status = false, observerMode = false, staticReq = false, championMastery = false, | ||
options = {} | ||
}, cb) { | ||
const doAsync = () => { | ||
return new Promise((resolve, reject) => { | ||
const proxy = staticReq ? 'global' : region | ||
const stringified = queryString.stringify(options) | ||
const postfix = stringified ? '?' + stringified : '' | ||
@@ -292,57 +288,57 @@ const reqUrl = this._makeUrl(endUrl + postfix, proxy, staticReq, status, observerMode, championMastery) | ||
request({ url: reqUrl }, (error, response, body) => { | ||
if (response && body) { | ||
let statusMessage | ||
const { statusCode } = response | ||
request({ url: reqUrl }, (error, response, body) => { | ||
if (response && body) { | ||
let statusMessage | ||
const { statusCode } = response | ||
if (statusCode >= 200 && statusCode < 300) | ||
statusMessage = chalk.green(statusCode) | ||
else if (statusCode >= 400 && statusCode < 500) | ||
statusMessage = chalk.red(`${statusCode} ${getResponseMessage(statusCode)}`) | ||
else if (statusCode >= 500) | ||
statusMessage = chalk.bold.red(`${statusCode} ${getResponseMessage(statusCode)}`) | ||
if (statusCode >= 200 && statusCode < 300) | ||
statusMessage = chalk.green(statusCode) | ||
else if (statusCode >= 400 && statusCode < 500) | ||
statusMessage = chalk.red(`${statusCode} ${getResponseMessage(statusCode)}`) | ||
else if (statusCode >= 500) | ||
statusMessage = chalk.bold.red(`${statusCode} ${getResponseMessage(statusCode)}`) | ||
if (self.debug) { | ||
console.log(statusMessage, reqUrl) | ||
console.log({ | ||
'x-app-rate-limit-count': response.headers['x-app-rate-limit-count'], | ||
'x-method-rate-limit-count': response.headers['x-method-rate-limit-count'], | ||
'x-rate-limit-count': response.headers['x-rate-limit-count'], | ||
'retry-after': response.headers['retry-after'] | ||
}) | ||
console.log() | ||
if (self.debug) { | ||
console.log(statusMessage, reqUrl) | ||
console.log({ | ||
'x-app-rate-limit-count': response.headers['x-app-rate-limit-count'], | ||
'x-method-rate-limit-count': response.headers['x-method-rate-limit-count'], | ||
'x-rate-limit-count': response.headers['x-rate-limit-count'], | ||
'retry-after': response.headers['retry-after'] | ||
}) | ||
console.log() | ||
} | ||
if (callback) { | ||
if (statusCode >= 500) { | ||
if (self.debug) console.log('!!! resending request !!!') | ||
setTimeout(() => { sendRequest.bind(self)(callback) }, 1000) | ||
} | ||
if (callback) { | ||
if (statusCode >= 500) { | ||
if (self.debug) console.log('!!! resending request !!!') | ||
setTimeout(() => { sendRequest.bind(self)(callback) }, 1000) | ||
} | ||
if (statusCode === 429) { | ||
if (self.debug) console.log('!!! resending request !!!') | ||
setTimeout(() => { | ||
sendRequest.bind(self)(callback) | ||
}, (response.headers['retry-after'] * 1000) + 50) | ||
} | ||
if (statusCode === 429) { | ||
if (self.debug) console.log('!!! resending request !!!') | ||
setTimeout(() => { | ||
sendRequest.bind(self)(callback) | ||
}, (response.headers['retry-after'] * 1000) + 50) | ||
} | ||
if (statusCode >= 400) return callback(statusMessage + ' : ' + chalk.yellow(reqUrl)) | ||
else return callback(error, JSON.parse(body)) | ||
if (statusCode >= 400) return callback(statusMessage + ' : ' + chalk.yellow(reqUrl)) | ||
else return callback(error, JSON.parse(body)) | ||
} else { | ||
if (statusCode === 500) { | ||
if (self.debug) console.log('!!! resending promise request !!!') | ||
setTimeout(() => { return reject('retry') }, 1000) | ||
} else if (statusCode === 429) { | ||
if (self.debug) console.log('!!! resending promise request !!!') | ||
setTimeout(() => { return reject('retry') }, (response.headers['retry-after'] * 1000) + 50) | ||
} else if (error || statusCode >= 400) { | ||
return reject('err:', error, statusCode) | ||
} else { | ||
if (statusCode === 500) { | ||
if (self.debug) console.log('!!! resending promise request !!!') | ||
setTimeout(() => { return reject('retry' )}, 1000) | ||
} else if (statusCode === 429) { | ||
if (self.debug) console.log('!!! resending promise request !!!') | ||
setTimeout(() => { return reject('retry') }, (response.headers['retry-after'] * 1000) + 50) | ||
} else if (error || statusCode >= 400) { | ||
return reject('err:', error, statusCode) | ||
} else { | ||
return resolve(JSON.parse(body)) | ||
} | ||
return resolve(JSON.parse(body)) | ||
} | ||
} else { | ||
console.log(error, reqUrl) | ||
} | ||
}) | ||
} else { | ||
console.log(error, reqUrl) | ||
} | ||
}) | ||
} else { | ||
@@ -496,7 +492,10 @@ setTimeout(() => { sendRequest.bind(self)(callback) }, 1000) | ||
return this._championRequest({ | ||
endUrl: `champion`, region, options | ||
}, cb = region || options ? cb : arguments[0]) | ||
endUrl: 'champion', region, options | ||
}, cb = arguments.length === 2 ? cb : arguments[0]) | ||
} | ||
getChamp({ region, id, championID } = {}, cb) { | ||
getChamp({ | ||
region, | ||
id, championID | ||
} = {}, cb) { | ||
if (Number.isInteger(id) || Number.isInteger(championID)) { | ||
@@ -516,3 +515,7 @@ return this._championRequest({ | ||
/* CHAMPIONMASTERY */ | ||
getChampMastery({ region = this.defaultRegion, playerID, championID, options } = {}, cb) { | ||
getChampMastery({ | ||
region = this.defaultRegion, | ||
playerID, championID, | ||
options | ||
} = {}, cb) { | ||
if (Number.isInteger(playerID) && Number.isInteger(championID)) { | ||
@@ -542,8 +545,10 @@ const location = PLATFORM_IDS[REGIONS_BACK[region]] | ||
return this.getSummoner({ name, region }, (err, data) => { | ||
if (err) return cb(err) | ||
return this._championMasteryRequest({ | ||
endUrl: `${location}/player/${data[this._sanitizeName(name)].id}/champions`, | ||
region | ||
}, cb) | ||
return new Promise((resolve, reject) => { | ||
return this.getSummoner({ name, region }, (err, data) => { | ||
if (err) { cb ? cb(err) : reject(err); return } | ||
return resolve(this._championMasteryRequest({ | ||
endUrl: `${location}/player/${data[this._sanitizeName(name)].id}/champions`, | ||
region | ||
}, cb)) | ||
}) | ||
}) | ||
@@ -558,3 +563,8 @@ } else { | ||
getTotalChampMasteryScore({ region = this.defaultRegion, id, summonerID, playerID, name, options } = {}, cb) { | ||
getTotalChampMasteryScore({ | ||
region = this.defaultRegion, | ||
id, summonerID, playerID, | ||
name, | ||
options | ||
} = {}, cb) { | ||
if (Number.isInteger(id || summonerID || playerID)) { | ||
@@ -569,8 +579,10 @@ const location = PLATFORM_IDS[REGIONS_BACK[region]] | ||
return this.getSummoner({ name, region }, (err, data) => { | ||
if (err) return cb(err) | ||
return this._championMasteryRequest({ | ||
endUrl: `${location}/player/${data[this._sanitizeName(name)].id}/score`, | ||
region | ||
}, cb) | ||
return new Promise((resolve, reject) => { | ||
return this.getSummoner({ name, region }, (err, data) => { | ||
if (err) { cb ? cb(err) : reject(err); return } | ||
return resolve(this._championMasteryRequest({ | ||
endUrl: `${location}/player/${data[this._sanitizeName(name)].id}/score`, | ||
region | ||
}, cb)) | ||
}) | ||
}) | ||
@@ -585,3 +597,8 @@ } else { | ||
getTopChamps({ region = this.defaultRegion, id, summonerID, playerID, name, options } = {}, cb) { | ||
getTopChamps({ | ||
region = this.defaultRegion, | ||
id, summonerID, playerID, | ||
name, | ||
options | ||
} = {}, cb) { | ||
if (Number.isInteger(id || summonerID || playerID)) { | ||
@@ -596,8 +613,10 @@ const location = PLATFORM_IDS[REGIONS_BACK[region]] | ||
return this.getSummoner({ name, region }, (err, data) => { | ||
if (err) return cb(err) | ||
return this._championMasteryRequest({ | ||
endUrl: `${location}/player/${data[this._sanitizeName(name)].id}/topchampions`, | ||
region | ||
}, cb) | ||
return new Promise((resolve, reject) => { | ||
return this.getSummoner({ name, region }, (err, data) => { | ||
if (err) { cb ? cb(err) : reject(err); return } | ||
return resolve(this._championMasteryRequest({ | ||
endUrl: `${location}/player/${data[this._sanitizeName(name)].id}/topchampions`, | ||
region | ||
}, cb)) | ||
}) | ||
}) | ||
@@ -613,3 +632,7 @@ } else { | ||
/* CURRENT-GAME-V1.0 */ | ||
getCurrentGame({ region = this.defaultRegion, id, summonerID, playerID, name } = {}, cb) { | ||
getCurrentGame({ | ||
region = this.defaultRegion, | ||
id, summonerID, playerID, | ||
name | ||
} = {}, cb) { | ||
const platformId = PLATFORM_IDS[REGIONS_BACK[region]] | ||
@@ -623,7 +646,9 @@ | ||
} else if (typeof arguments[0] === 'object' && typeof name === 'string') { | ||
return this.getSummoner({ name, region }, (err, data) => { | ||
if (err) return cb(err) | ||
return this._currentGameRequest({ | ||
endUrl: `${data[this._sanitizeName(name)].id}`, platformId, region | ||
}, cb) | ||
return new Promise((resolve, reject) => { | ||
return this.getSummoner({ name, region }, (err, data) => { | ||
if (err) { cb ? cb(err) : reject(err); return } | ||
return resolve(this._currentGameRequest({ | ||
endUrl: `${data[this._sanitizeName(name)].id}`, platformId, region | ||
}, cb)) | ||
}) | ||
}) | ||
@@ -647,3 +672,7 @@ } else { | ||
/* GAME-V1.3 */ | ||
getRecentGames({ region, id, summonerID, playerID, name } = {}, cb) { | ||
getRecentGames({ | ||
region, | ||
id, summonerID, playerID, | ||
name | ||
} = {}, cb) { | ||
if (Number.isInteger(id || summonerID || playerID)) { | ||
@@ -655,7 +684,9 @@ return this._gameRequest({ | ||
} else if (typeof arguments[0] === 'object' && typeof name === 'string') { | ||
return this.getSummoner({ name, region }, (err, data) => { | ||
if (err) return cb(err) | ||
return this._gameRequest({ | ||
endUrl: `by-summoner/${data[this._sanitizeName(name)].id}/recent`, region | ||
}, cb) | ||
return new Promise((resolve, reject) => { | ||
return this.getSummoner({ name, region }, (err, data) => { | ||
if (err) { cb ? cb(err) : reject(err); return } | ||
return resolve(this._gameRequest({ | ||
endUrl: `by-summoner/${data[this._sanitizeName(name)].id}/recent`, region | ||
}, cb)) | ||
}) | ||
}) | ||
@@ -671,3 +702,10 @@ } else { | ||
/* LEAGUE-V2.5 */ | ||
getLeagues({ region, ids, id, summonerIDs, summonerID, playerIDs, playerID, names, name, options } = {}, cb) { | ||
getLeagues({ | ||
region, | ||
ids, summonerIDs, playerIDs, | ||
id, summonerID, playerID, | ||
names, | ||
name, | ||
options | ||
} = {}, cb) { | ||
if (checkAll.int(ids || summonerIDs || playerIDs)) { | ||
@@ -684,20 +722,24 @@ return this._leagueRequest({ | ||
} else if (checkAll.string(names)) { | ||
return this.getSummoners({ names, region }, (err, data) => { | ||
if (err) return cb(err) | ||
return new Promise((resolve, reject) => { | ||
return this.getSummoners({ names, region }, (err, data) => { | ||
if (err) { cb ? cb(err) : reject(err); return } | ||
let args = [] | ||
let args = [] | ||
for (let name of names) | ||
args.push(data[this._sanitizeName(name)].id) | ||
for (let name of names) | ||
args.push(data[this._sanitizeName(name)].id) | ||
return this._leagueRequest({ endUrl: `by-summoner/${args.join(',')}`, region, options }, cb) | ||
return resolve(this._leagueRequest({ endUrl: `by-summoner/${args.join(',')}`, region, options }, cb)) | ||
}) | ||
}) | ||
} else if (typeof arguments[0] === 'object' && (typeof names === 'string' || typeof name === 'string')) { | ||
return this.getSummoner({ name: names || name, region }, (err, data) => { | ||
if (err) return cb(err) | ||
return new Promise((resolve, reject) => { | ||
return this.getSummoner({ name: names || name, region }, (err, data) => { | ||
if (err) { cb ? cb(err) : reject(err); return } | ||
return this._leagueRequest({ | ||
endUrl: `by-summoner/${data[this._sanitizeName(names || name)].id}`, | ||
region, options | ||
}, cb) | ||
return resolve(this._leagueRequest({ | ||
endUrl: `by-summoner/${data[this._sanitizeName(names || name)].id}`, | ||
region, options | ||
}, cb)) | ||
}) | ||
}) | ||
@@ -712,3 +754,9 @@ } else { | ||
getLeagueEntries({ region, ids, id, summonerIDs, summonerID, playerIDs, playerID, names, name } = {}, cb) { | ||
getLeagueEntries({ | ||
region, | ||
ids, summonerIDs, playerIDs, | ||
id, summonerID, playerID, | ||
names, | ||
name | ||
} = {}, cb) { | ||
if (checkAll.int(ids || summonerIDs || playerIDs)) { | ||
@@ -725,19 +773,23 @@ return this._leagueRequest({ | ||
} else if (checkAll.string(names)) { | ||
return this.getSummoners({ names, region }, (err, data) => { | ||
if (err) return cb(err) | ||
return new Promise((resolve, reject) => { | ||
return this.getSummoners({ names, region }, (err, data) => { | ||
if (err) { cb ? cb(err) : reject(err); return } | ||
let args = [] | ||
let args = [] | ||
for (let name of names) | ||
args.push(data[this._sanitizeName(name)].id) | ||
for (let name of names) | ||
args.push(data[this._sanitizeName(name)].id) | ||
return this._leagueRequest({ endUrl: `by-summoner/${args.join(',')}/entry`, region }, cb) | ||
return resolve(this._leagueRequest({ endUrl: `by-summoner/${args.join(',')}/entry`, region }, cb)) | ||
}) | ||
}) | ||
} else if (typeof arguments[0] === 'object' && (typeof names === 'string' || typeof name === 'string')) { | ||
return this.getSummoner({ name: names || name, region }, (err, data) => { | ||
if (err) return cb(err) | ||
return this._leagueRequest({ | ||
endUrl: `by-summoner/${data[this._sanitizeName(names || name)].id}/entry`, | ||
region | ||
}, cb) | ||
return new Promise((resolve, reject) => { | ||
return this.getSummoner({ name: names || name, region }, (err, data) => { | ||
if (err) { cb ? cb(err) : reject(err); return } | ||
return resolve(this._leagueRequest({ | ||
endUrl: `by-summoner/${data[this._sanitizeName(names || name)].id}/entry`, | ||
region | ||
}, cb)) | ||
}) | ||
}) | ||
@@ -752,12 +804,18 @@ } else { | ||
getChallengers({ region, options = { type: 'RANKED_SOLO_5x5' } } = {}, cb) { | ||
getChallengers({ | ||
region, | ||
options = { type: 'RANKED_SOLO_5x5' } | ||
} = {}, cb) { | ||
return this._leagueRequest({ | ||
endUrl: 'challenger', region, options | ||
}, cb = region || options ? cb : arguments[0]) | ||
}, cb = arguments.length === 2 ? cb : arguments[0]) | ||
} | ||
getMasters({ region, options = { type: 'RANKED_SOLO_5x5' } } = {}, cb) { | ||
getMasters({ | ||
region, | ||
options = { type: 'RANKED_SOLO_5x5' } | ||
} = {}, cb) { | ||
return this._leagueRequest({ | ||
endUrl: 'master', region, options | ||
}, cb = region || options ? cb : arguments[0]) | ||
}, cb = arguments.length === 2 ? cb : arguments[0]) | ||
} | ||
@@ -767,6 +825,10 @@ | ||
getChampionList({ region, options } = {}, cb) { | ||
return this._staticRequest({ endUrl: 'champion', region, options }, cb = region || options ? cb : arguments[0]) | ||
return this._staticRequest({ endUrl: 'champion', region, options }, cb = arguments.length === 2 ? cb : arguments[0]) | ||
} | ||
getChampion({ region, id, championID, options } = {}, cb) { | ||
getChampion({ | ||
region, | ||
id, championID, | ||
options | ||
} = {}, cb) { | ||
if (Number.isInteger(id || championID)) { | ||
@@ -783,6 +845,10 @@ return this._staticRequest({ endUrl: `champion/${id || championID}`, region, options }, cb) | ||
getItems({ region, options } = {}, cb) { | ||
return this._staticRequest({ endUrl: 'item', region, options }, cb = region || options ? cb : arguments[0]) | ||
return this._staticRequest({ endUrl: 'item', region, options }, cb = arguments.length === 2 ? cb : arguments[0]) | ||
} | ||
getItem({ region, id, itemID, options } = {}, cb) { | ||
getItem({ | ||
region, | ||
id, itemID, | ||
options | ||
} = {}, cb) { | ||
if (Number.isInteger(id || itemID)) { | ||
@@ -799,3 +865,3 @@ return this._staticRequest({ endUrl: `item/${id || itemID}`, region, options }, cb) | ||
getLanguageStrings({ region, options } = {}, cb) { | ||
return this._staticRequest({ endUrl: 'language-strings', region, options }, cb = region || options ? cb : arguments[0]) | ||
return this._staticRequest({ endUrl: 'language-strings', region, options }, cb = arguments.length === 2 ? cb : arguments[0]) | ||
} | ||
@@ -808,10 +874,14 @@ | ||
getMap({ region, options } = {}, cb) { | ||
return this._staticRequest({ endUrl: 'map', region, options }, cb = region || options ? cb : arguments[0]) | ||
return this._staticRequest({ endUrl: 'map', region, options }, cb = arguments.length === 2 ? cb : arguments[0]) | ||
} | ||
getMasteryList({ region, options } = {}, cb) { | ||
return this._staticRequest({ endUrl: 'mastery', region, options }, cb = region || options ? cb : arguments[0]) | ||
return this._staticRequest({ endUrl: 'mastery', region, options }, cb = arguments.length === 2 ? cb : arguments[0]) | ||
} | ||
getMastery({ region, id, masteryID, options } = {}, cb) { | ||
getMastery({ | ||
region, | ||
id, masteryID, | ||
options | ||
} = {}, cb) { | ||
if (Number.isInteger(id || masteryID)) { | ||
@@ -835,6 +905,10 @@ return this._staticRequest({ | ||
getRuneList({ region, options } = {}, cb) { | ||
return this._staticRequest({ endUrl: 'rune', region, options }, cb = region || options ? cb : arguments[0]) | ||
return this._staticRequest({ endUrl: 'rune', region, options }, cb = arguments.length === 2 ? cb : arguments[0]) | ||
} | ||
getRune({ region, id, runeID, options } = {}, cb) { | ||
getRune({ | ||
region, | ||
id, runeID, | ||
options | ||
} = {}, cb) { | ||
if (Number.isInteger(id || runeID)) { | ||
@@ -851,6 +925,10 @@ return this._staticRequest({ endUrl: `rune/${id || runeID}`, region, options }, cb) | ||
getSummonerSpells({ region, options } = {}, cb) { | ||
return this._staticRequest({ endUrl: 'summoner-spell', region, options }, cb = region || options ? cb : arguments[0]) | ||
return this._staticRequest({ endUrl: 'summoner-spell', region, options }, cb = arguments.length === 2 ? cb : arguments[0]) | ||
} | ||
getSummonerSpell({ region, id, spellID, summonerSpellID, options } = {}, cb) { | ||
getSummonerSpell({ | ||
region, | ||
id, spellID, summonerSpellID, | ||
options | ||
} = {}, cb) { | ||
if (Number.isInteger(id || spellID || summonerSpellID)) { | ||
@@ -870,3 +948,3 @@ return this._staticRequest({ | ||
getVersionData({ region, options } = {}, cb) { | ||
return this._staticRequest({ endUrl: 'versions', region, options }, cb = region || options ? cb : arguments[0]) | ||
return this._staticRequest({ endUrl: 'versions', region, options }, cb = arguments.length === 2 ? cb : arguments[0]) | ||
} | ||
@@ -884,3 +962,7 @@ | ||
/* MATCH-V2.2 */ | ||
getMatch({ region, id, matchID, options = { includeTimeline: true } } = {}, cb) { | ||
getMatch({ | ||
region, | ||
id, matchID, | ||
options = { includeTimeline: true } | ||
} = {}, cb) { | ||
if (Number.isInteger(id || matchID)) { | ||
@@ -897,3 +979,8 @@ return this._matchRequest({ endUrl: `${id || matchID}`, region, options }, cb) | ||
/* MATCHLIST-V2.2 */ | ||
getMatchList({ region, id, summonerID, playerID, name, options = { rankedQueues: 'RANKED_SOLO_5x5' } } = {}, cb) { | ||
getMatchList({ | ||
region, | ||
id, summonerID, playerID, | ||
name, | ||
options = { rankedQueues: 'RANKED_SOLO_5x5' } | ||
} = {}, cb) { | ||
if (Number.isInteger(id || summonerID || playerID)) { | ||
@@ -905,8 +992,10 @@ return this._matchListRequest({ | ||
} else if (typeof arguments[0] === 'object' && typeof name === 'string') { | ||
return this.getSummoner({ name, region }, (err, data) => { | ||
if (err) return cb(err) | ||
return this._matchListRequest({ | ||
endUrl: `${data[this._sanitizeName(name)].id}`, | ||
region, options | ||
}, cb) | ||
return new Promise((resolve, reject) => { | ||
return this.getSummoner({ name, region }, (err, data) => { | ||
if (err) { cb ? cb(err) : reject(err); return } | ||
return resolve(this._matchListRequest({ | ||
endUrl: `${data[this._sanitizeName(name)].id}`, | ||
region, options | ||
}, cb)) | ||
}) | ||
}) | ||
@@ -922,3 +1011,9 @@ } else { | ||
/* RUNES-MASTERIES-V1.4 */ | ||
getRunes({ region, ids, id, summonerIDs, summonerID, playerIDs, playerID, names, name } = {}, cb) { | ||
getRunes({ | ||
region, | ||
ids, summonerIDs, playerIDs, | ||
id, summonerID, playerID, | ||
names, | ||
name | ||
} = {}, cb) { | ||
if (checkAll.int(ids || summonerIDs || playerIDs)) { | ||
@@ -935,22 +1030,26 @@ return this._runesMasteriesRequest({ | ||
} else if (checkAll.string(names)) { | ||
return this.getSummoners({ names, region }, (err, data) => { | ||
if (err) return cb(err) | ||
return new Promise((resolve, reject) => { | ||
return this.getSummoners({ names, region }, (err, data) => { | ||
if (err) { cb ? cb(err) : reject(err); return } | ||
let args = [] | ||
let args = [] | ||
for (let name of names) | ||
args.push(data[this._sanitizeName(name)].id) | ||
for (let name of names) | ||
args.push(data[this._sanitizeName(name)].id) | ||
return this._runesMasteriesRequest({ | ||
endUrl: `${args.join(',')}/runes`, | ||
region | ||
}, cb) | ||
return resolve(this._runesMasteriesRequest({ | ||
endUrl: `${args.join(',')}/runes`, | ||
region | ||
}, cb)) | ||
}) | ||
}) | ||
} else if (typeof arguments[0] === 'object' && (typeof names === 'string' || typeof name === 'string')) { | ||
return this.getSummoner({ name: names || name, region }, (err, data) => { | ||
if (err) return cb(err) | ||
return this._runesMasteriesRequest({ | ||
endUrl: `${data[this._sanitizeName(names || name)].id}/runes`, | ||
region | ||
}, cb) | ||
return new Promise((resolve, reject) => { | ||
return this.getSummoner({ name: names || name, region }, (err, data) => { | ||
if (err) { cb ? cb(err) : reject(err); return } | ||
return resolve(this._runesMasteriesRequest({ | ||
endUrl: `${data[this._sanitizeName(names || name)].id}/runes`, | ||
region | ||
}, cb)) | ||
}) | ||
}) | ||
@@ -965,3 +1064,9 @@ } else { | ||
getMasteries({ region, ids, id, summonerIDs, summonerID, playerIDs, playerID, names, name } = {}, cb) { | ||
getMasteries({ | ||
region, | ||
ids, summonerIDs, playerIDs, | ||
id, summonerID, playerID, | ||
names, | ||
name | ||
} = {}, cb) { | ||
if (checkAll.int(ids || summonerIDs || playerIDs)) { | ||
@@ -978,22 +1083,26 @@ return this._runesMasteriesRequest({ | ||
} else if (checkAll.string(names)) { | ||
return this.getSummoners({ names, region }, (err, data) => { | ||
if (err) return cb(err) | ||
return new Promise((resolve, reject) => { | ||
return this.getSummoners({ names, region }, (err, data) => { | ||
if (err) { cb ? cb(err) : reject(err); return } | ||
let args = [] | ||
let args = [] | ||
for (let name of names) | ||
args.push(data[this._sanitizeName(name)].id) | ||
for (let name of names) | ||
args.push(data[this._sanitizeName(name)].id) | ||
return this._runesMasteriesRequest({ | ||
endUrl: `${args.join(',')}/masteries`, | ||
region | ||
}, cb) | ||
return resolve(this._runesMasteriesRequest({ | ||
endUrl: `${args.join(',')}/masteries`, | ||
region | ||
}, cb)) | ||
}) | ||
}) | ||
} else if (typeof arguments[0] === 'object' && (typeof names === 'string' || typeof name === 'string')) { | ||
return this.getSummoner({ name: names || name, region }, (err, data) => { | ||
if (err) return cb(err) | ||
return this._runesMasteriesRequest({ | ||
endUrl: `${data[this._sanitizeName(names || name)].id}/masteries`, | ||
region | ||
}, cb) | ||
return new Promise((resolve, reject) => { | ||
return this.getSummoner({ name: names || name, region }, (err, data) => { | ||
if (err) { cb ? cb(err) : reject(err); return } | ||
return resolve(this._runesMasteriesRequest({ | ||
endUrl: `${data[this._sanitizeName(names || name)].id}/masteries`, | ||
region | ||
}, cb)) | ||
}) | ||
}) | ||
@@ -1009,3 +1118,8 @@ } else { | ||
/* STATS-V1.3 */ | ||
getRankedStats({ region, id, summonerID, playerID, name, options } = {}, cb) { | ||
getRankedStats({ | ||
region, | ||
id, summonerID, playerID, | ||
name, | ||
options | ||
} = {}, cb) { | ||
if (Number.isInteger(id || summonerID || playerID)) { | ||
@@ -1017,8 +1131,10 @@ return this._statsRequest({ | ||
} else if (typeof arguments[0] === 'object' && typeof name === 'string') { | ||
return this.getSummoner({ name, region }, (err, data) => { | ||
if (err) return cb(err) | ||
return this._statsRequest({ | ||
endUrl: `${data[this._sanitizeName(name)].id}/ranked`, | ||
region, options | ||
}, cb) | ||
return new Promise((resolve, reject) => { | ||
return this.getSummoner({ name, region }, (err, data) => { | ||
if (err) { cb ? cb(err) : reject(err); return } | ||
return resolve(this._statsRequest({ | ||
endUrl: `${data[this._sanitizeName(name)].id}/ranked`, | ||
region, options | ||
}, cb)) | ||
}) | ||
}) | ||
@@ -1033,3 +1149,8 @@ } else { | ||
getStatsSummary({ region, id, summonerID, playerID, name, options } = {}, cb) { | ||
getStatsSummary({ | ||
region, | ||
id, summonerID, playerID, | ||
name, | ||
options | ||
} = {}, cb) { | ||
if (Number.isInteger(id || summonerID || playerID)) { | ||
@@ -1041,8 +1162,10 @@ return this._statsRequest({ | ||
} else if (typeof arguments[0] === 'object' && typeof name === 'string') { | ||
return this.getSummoner({ name, region }, (err, data) => { | ||
if (err) return cb(err) | ||
return this._statsRequest({ | ||
endUrl: `${data[this._sanitizeName(name)].id}/summary`, | ||
region, options | ||
}, cb) | ||
return new Promise((resolve, reject) => { | ||
return this.getSummoner({ name, region }, (err, data) => { | ||
if (err) { cb ? cb(err) : reject(err); return } | ||
return resolve(this._statsRequest({ | ||
endUrl: `${data[this._sanitizeName(name)].id}/summary`, | ||
region, options | ||
}, cb)) | ||
}) | ||
}) | ||
@@ -1058,3 +1181,9 @@ } else { | ||
/* SUMMONER-V1.4 */ | ||
getSummoners({ region, ids, id, summonerIDs, summonerID, playerIDs, playerID, names, name } = {}, cb) { | ||
getSummoners({ | ||
region, | ||
ids, summonerIDs, playerIDs, | ||
id, summonerID, playerID, | ||
names, | ||
name | ||
} = {}, cb) { | ||
if (checkAll.int(ids || summonerIDs || playerIDs)) { | ||
@@ -1088,3 +1217,7 @@ return this._summonerRequest({ | ||
getSummoner({ region, id, summonerID, playerID, name } = {}, cb) { | ||
getSummoner({ | ||
region, | ||
id, summonerID, playerID, | ||
name | ||
} = {}, cb) { | ||
if (Number.isInteger(id || summonerID || playerID)) { | ||
@@ -1102,3 +1235,7 @@ return this.getSummoners({ region, ids: [id || summonerID || playerID] }, cb) | ||
getSummonerNames({ region, ids, id, summonerIDs, summonerID, playerIDs, playerID } = {}, cb) { | ||
getSummonerNames({ | ||
region, | ||
ids, summonerIDs, playerIDs, | ||
id, summonerID, playerID | ||
} = {}, cb) { | ||
if (checkAll.int(ids || summonerIDs || playerIDs)) { | ||
@@ -1122,3 +1259,5 @@ return this._summonerRequest({ | ||
getSummonerName({ region, id, summonerID, playerID } = {}, cb) { | ||
getSummonerName({ | ||
region, id, summonerID, playerID | ||
} = {}, cb) { | ||
if (Number.isInteger(id)) { | ||
@@ -1125,0 +1264,0 @@ return this.getSummonerNames({ region, id: id || summonerID || playerID }, cb) |
Sorry, the diff of this file is too big to display
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
347763
36
3335
599