kindred-api
Advanced tools
Comparing version 1.2.0 to 1.2.1
@@ -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 n={exports:{}};t(n,e.doubleEndedQueue,e.request,e.chalk,e.xregexp,e.queryString),e.kindredApi=n.exports}}(this,function(e,t,n,r,i,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 n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),l=function(){function e(n,r){o(this,e),this.allowedRequests=n,this.seconds=r,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"},d={BRAZIL:"br",EUROPE:"eune",EUROPE_WEST:"euw",KOREA:"kr",LATIN_AMERICA_NORTH:"lan",LATIN_AMERICA_SOUTH:"las",NORTH_AMERICA:"na",OCEANIA:"oce",RUSSIA:"ru",TURKEY:"tr",JAPAN:"jp"},h={br:"BRAZIL",eune:"EUROPE",euw:"EUROPE_WEST",kr:"KOREA",lan:"LATIN_AMERICA_NORTH",las:"LATIN_AMERICA_SOUTH",na:"NORTH_AMERICA",oce:"OCEANIA",ru:"RUSSIA",tr:"TURKEY",jp:"JAPAN"},p={CHAMPION:1.2,CURRENT_GAME:1,FEATURED_GAMES:1,GAME:1.3,LEAGUE:2.5,STATIC_DATA:1.2,STATUS:1,MATCH:2.2,MATCH_LIST:2.2,RUNES_MASTERIES:1.4,STATS:1.3,SUMMONER:1.4},y={int:function(e){return e.every(function(e){return Number.isInteger(e)})},string:function(e){return e.every(function(e){return"string"==typeof e})}},c={int:function(e){return e&&Array.isArray(e)&&y.int(e)&&e.length>0},string:function(e){return e&&Array.isArray(e)&&y.string(e)&&e.length>0}},v={400:"Bad Request",403:"Forbidden",404:"Not Found",415:"Unsupported Media Type",429:"Rate Limit Exceeded",500:"Internal Service Error",503:"Service Unavailable"},f=function(e){var t=v[e];if(t)return t},R=i("^[0-9\\p{L} _\\.]+$"),I=function(){function e(t){var n=t.key,i=t.defaultRegion,s=void 0===i?d.NORTH_AMERICA:i,a=t.debug,u=void 0!==a&&a,g=t.limits;o(this,e),this.key=n;var h=void 0,p=!0,y=!1,v=void 0;try{for(var f,R=Object.keys(d)[Symbol.iterator]();!(p=(f=R.next()).done);p=!0){var I=f.value;d[I]===s&&(h=!0)}}catch(e){y=!0,v=e}finally{try{!p&&R.return&&R.return()}finally{if(y)throw v}}if(this.defaultRegion=h?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,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(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"===g&&(g=m.DEV),"prod"===g&&(g=m.PROD);var b=!0,_=!1,S=void 0;try{for(var q,D=Object.keys(d)[Symbol.iterator]();!(b=(q=D.next()).done);b=!0){var U=q.value;this.limits[d[U]]=[new l(g[0][0],g[0][1]),new l(g[1][0],g[1][1])]}}catch(e){_=!0,S=e}finally{try{!b&&D.return&&D.return()}finally{if(_)throw S}}}this.Champion={getChampions:this.getChamps.bind(this),getAll: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),getTotalChampionMasteryScore:this.getTotalChampMasteryScore.bind(this),getTopChampions: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),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),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),getChampion:this.getChampion.bind(this),getItems:this.getItems.bind(this),getItem:this.getItem.bind(this),getLanguageStrings:this.getLanguageStrings.bind(this),getMasteries:this.getMasteryList.bind(this),getMastery:this.getMastery.bind(this),getRealmData:this.getRealmData.bind(this),getRunes:this.getRuneList.bind(this),getRune:this.getRune.bind(this),getSummonerSpells:this.getSummonerSpells.bind(this),getSummonerSpell:this.getSummonerSpell.bind(this),getVersionData: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)},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),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 "+r.yellow(e)+" is not valid. Request failed."),process.exit(1)}},{key:"_validName",value:function(e){return R.test(e)}},{key:"_makeUrl",value:function(e,t,n,r,i,s){var o=n?"":t+"/",a=r||i||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 i=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,d=void 0!==g&&g,h=e.staticReq,p=void 0!==h&&h,y=e.championMastery,c=void 0!==y&&y,v=e.options,R=void 0===v?{}:v,I=function(){return new Promise(function(e,a){var l=p?"global":u,g=s.stringify(R),h=g?"?"+g:"",y=i._makeUrl(o+h,l,p,m,d,c);if(i.limits){var v=i;!function t(i){v.canMakeRequest(u)?(p||(v.limits[u][0].addRequest(),v.limits[u][1].addRequest()),n({url:y},function(n,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+" "+f(l)):l>=500&&(u=r.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()),i)return l>=500&&(v.debug&&console.log("!!! resending request !!!"),setTimeout(function(){t.bind(v)(i)},1e3)),429===l&&(v.debug&&console.log("!!! resending request !!!"),setTimeout(function(){t.bind(v)(i)},1e3*s.headers["retry-after"]+50)),l>=400?i(u+" : "+r.yellow(y)):i(n,JSON.parse(o));if(500===l)v.debug&&console.log("!!! resending promise request !!!"),setTimeout(function(){return a("retry")},1e3);else{if(429!==l)return n||l>=400?a("err:",n,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(n,y)})):setTimeout(function(){t.bind(v)(i)},1e3)}(t)}else n({url:y},function(n,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+" "+f(l)):l>=500&&(u=r.bold.red(l+" "+f(l))),i.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(n,JSON.parse(o)):n?a("err:",n):e(JSON.parse(o))}console.log(n,y)})})};return t?I():I().catch(I).catch(I).catch(I).then(function(e){return e})}},{key:"_observerRequest",value:function(e,t){var n=e.endUrl,r=e.region;return this._baseRequest({endUrl:"observer-mode/rest/"+n,observerMode:!0,region:r},t)}},{key:"_championRequest",value:function(e,t){var n=e.endUrl,r=e.region,i=e.options;return this._baseRequest({endUrl:"v"+p.CHAMPION+"/"+n,region:r,options:i},t)}},{key:"_championMasteryRequest",value:function(e,t){var n=e.endUrl,r=e.region,i=e.options;return this._baseRequest({endUrl:"championmastery/location/"+n,region:r,options:i,championMastery:!0},t)}},{key:"_currentGameRequest",value:function(e,t){var n=e.endUrl,r=e.region,i=e.platformId;return this._observerRequest({endUrl:"consumer/getSpectatorGameInfo/"+i+"/"+n,region:r},t)}},{key:"_staticRequest",value:function(e,t){var n=e.endUrl,r=e.region,i=void 0===r?this.defaultRegion:r,s=e.options;return this._baseRequest({endUrl:"static-data/"+i+"/v"+p.STATIC_DATA+"/"+n,staticReq:!0,region:i,options:s},t)}},{key:"_statusRequest",value:function(e,t){var n=e.endUrl,r=(e.region,e.options);return this._baseRequest({endUrl:"lol/status/v"+p.STATUS+"/"+n,status:!0,options:r},t)}},{key:"_gameRequest",value:function(e,t){var n=e.endUrl,r=e.region;return this._baseRequest({endUrl:"v"+p.GAME+"/game/"+n,region:r},t)}},{key:"_leagueRequest",value:function(e,t){var n=e.endUrl,r=e.region,i=e.options;return this._baseRequest({endUrl:"v"+p.LEAGUE+"/league/"+n,region:r,options:i},t)}},{key:"_matchRequest",value:function(e,t){var n=e.endUrl,r=e.region,i=e.options;return this._baseRequest({endUrl:"v"+p.MATCH+"/match/"+n,region:r,options:i},t)}},{key:"_matchListRequest",value:function(e,t){var n=e.endUrl,r=e.region,i=e.options;return this._baseRequest({endUrl:"v"+p.MATCH_LIST+"/matchlist/by-summoner/"+n,region:r,options:i},t)}},{key:"_runesMasteriesRequest",value:function(e,t){var n=e.endUrl,r=e.region;return this._summonerRequest({endUrl:n,region:r},t)}},{key:"_statsRequest",value:function(e,t){var n=e.endUrl,r=e.region,i=e.options;return this._baseRequest({endUrl:"v"+p.STATS+"/stats/by-summoner/"+n,region:r,options:i},t)}},{key:"_summonerRequest",value:function(e,t){var n=e.endUrl,r=e.region;return this._baseRequest({endUrl:"v"+p.SUMMONER+"/summoner/"+n,region:r},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,r=arguments[1];return this._championRequest({endUrl:"champion",region:t,options:n},r=t||n?r: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=g[h[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,u=t.playerID,l=t.name,m=t.options,d=arguments[1];if(Number.isInteger(s||o||u)){var p=g[h[i]];return this._championMasteryRequest({endUrl:p+"/player/"+(s||o||u)+"/champions",region:i,options:m},d)}if("object"===a(arguments[0])&&"string"==typeof l){var y=g[h[i]];return this.getSummoner({name:l,region:i},function(t,n){return t?d(t):e._championMasteryRequest({endUrl:y+"/player/"+n[e._sanitizeName(l)].id+"/champions",region:i},d)})}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,u=t.playerID,l=t.name,m=t.options,d=arguments[1];if(Number.isInteger(s||o||u)){var p=g[h[i]];return this._championMasteryRequest({endUrl:p+"/player/"+(s||o||u)+"/score",region:i,options:m},d)}if("object"===a(arguments[0])&&"string"==typeof l){var y=g[h[i]];return this.getSummoner({name:l,region:i},function(t,n){return t?d(t):e._championMasteryRequest({endUrl:y+"/player/"+n[e._sanitizeName(l)].id+"/score",region:i},d)})}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,u=t.playerID,l=t.name,m=t.options,d=arguments[1];if(Number.isInteger(s||o||u)){var p=g[h[i]];return this._championMasteryRequest({endUrl:p+"/player/"+(s||o||u)+"/topchampions",region:i,options:m},d)}if("object"===a(arguments[0])&&"string"==typeof l){var y=g[h[i]];return this.getSummoner({name:l,region:i},function(t,n){return t?d(t):e._championMasteryRequest({endUrl:y+"/player/"+n[e._sanitizeName(l)].id+"/topchampions",region:i},d)})}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,u=t.playerID,l=t.name,m=arguments[1],d=g[h[i]];return Number.isInteger(s||o||u)?this._currentGameRequest({endUrl:""+(s||o||u),platformId:d,region:i},m):"object"===a(arguments[0])&&"string"==typeof l?this.getSummoner({name:l,region:i},function(t,n){return t?m(t):e._currentGameRequest({endUrl:""+n[e._sanitizeName(l)].id,platformId:d,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,u=t.name,l=arguments[1];return Number.isInteger(i||s||o)?this._gameRequest({endUrl:"by-summoner/"+(i||s||o)+"/recent",region:n},l):"object"===a(arguments[0])&&"string"==typeof u?this.getSummoner({name:u,region:n},function(t,r){return t?l(t):e._gameRequest({endUrl:"by-summoner/"+r[e._sanitizeName(u)].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.id,o=t.summonerIDs,u=t.summonerID,l=t.playerIDs,m=t.playerID,g=t.names,d=t.name,h=t.options,p=arguments[1];return c.int(i||o||l)?this._leagueRequest({endUrl:"by-summoner/"+(i||o||l).join(","),region:n,options:h},p):Number.isInteger(i||s||o||u||l||m)?this._leagueRequest({endUrl:"by-summoner/"+(i||s||o||u||l||m),region:n,options:h},p):c.string(g)?this.getSummoners({names:g,region:n},function(t,r){if(t)return p(t);var i=[],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;i.push(r[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/"+i.join(","),region:n,options:h},p)}):"object"!==a(arguments[0])||"string"!=typeof g&&"string"!=typeof d?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"):this.getSummoner({name:g||d,region:n},function(t,r){return t?p(t):e._leagueRequest({endUrl:"by-summoner/"+r[e._sanitizeName(g||d)].id,region:n,options:h},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.id,o=t.summonerIDs,u=t.summonerID,l=t.playerIDs,m=t.playerID,g=t.names,d=t.name,h=arguments[1];return c.int(i||o||l)?this._leagueRequest({endUrl:"by-summoner/"+(i||o||l).join(",")+"/entry",region:n},h):Number.isInteger(i||s||o||u||l||m)?this._leagueRequest({endUrl:"by-summoner/"+(i||s||o||u||l||m)+"/entry",region:n},h):c.string(g)?this.getSummoners({names:g,region:n},function(t,r){if(t)return h(t);var i=[],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;i.push(r[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/"+i.join(",")+"/entry",region:n},h)}):"object"!==a(arguments[0])||"string"!=typeof g&&"string"!=typeof d?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"):this.getSummoner({name:g||d,region:n},function(t,r){return t?h(t):e._leagueRequest({endUrl:"by-summoner/"+r[e._sanitizeName(g||d)].id+"/entry",region:n},h)})}},{key:"getChallengers",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.options,r=void 0===n?{type:"RANKED_SOLO_5x5"}:n,i=arguments[1];return this._leagueRequest({endUrl:"challenger",region:t,options:r},i=t||r?i:arguments[0])}},{key:"getMasters",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.options,r=void 0===n?{type:"RANKED_SOLO_5x5"}:n,i=arguments[1];return this._leagueRequest({endUrl:"master",region:t,options:r},i=t||r?i:arguments[0])}},{key:"getChampionList",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.options,r=arguments[1];return this._staticRequest({endUrl:"champion",region:t,options:n},r=t||n?r: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,r=arguments[1];return this._staticRequest({endUrl:"item",region:t,options:n},r=t||n?r: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,r=arguments[1];return this._staticRequest({endUrl:"language-strings",region:t,options:n},r=t||n?r: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,r=arguments[1];return this._staticRequest({endUrl:"map",region:t,options:n},r=t||n?r:arguments[0])}},{key:"getMasteryList",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.options,r=arguments[1];return this._staticRequest({endUrl:"mastery",region:t,options:n},r=t||n?r: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,r=arguments[1];return this._staticRequest({endUrl:"rune",region:t,options:n},r=t||n?r: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,r=arguments[1];return this._staticRequest({endUrl:"summoner-spell",region:t,options:n},r=t||n?r: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,r=arguments[1];return this._staticRequest({endUrl:"versions",region:t,options:n},r=t||n?r: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,u=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"===a(arguments[0])&&"string"==typeof u?this.getSummoner({name:u,region:n},function(t,r){return t?g(t):e._matchListRequest({endUrl:""+r[e._sanitizeName(u)].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.id,o=t.summonerIDs,u=t.summonerID,l=t.playerIDs,m=t.playerID,g=t.names,d=t.name,h=arguments[1];return c.int(i||o||l)?this._runesMasteriesRequest({endUrl:(i||o||l).join()+"/runes",region:n},h):Number.isInteger(i||s||o||u||l||m)?this._runesMasteriesRequest({endUrl:(i||s||o||u||l||m)+"/runes",region:n},h):c.string(g)?this.getSummoners({names:g,region:n},function(t,r){if(t)return h(t);var i=[],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;i.push(r[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:i.join(",")+"/runes",region:n},h)}):"object"!==a(arguments[0])||"string"!=typeof g&&"string"!=typeof d?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"):this.getSummoner({name:g||d,region:n},function(t,r){return t?h(t):e._runesMasteriesRequest({endUrl:r[e._sanitizeName(g||d)].id+"/runes",region:n},h)})}},{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.id,o=t.summonerIDs,u=t.summonerID,l=t.playerIDs,m=t.playerID,g=t.names,d=t.name,h=arguments[1];return c.int(i||o||l)?this._runesMasteriesRequest({endUrl:(i||o||l).join()+"/masteries",region:n},h):Number.isInteger(i||s||o||u||l||m)?this._runesMasteriesRequest({endUrl:(i||s||o||u||l||m)+"/masteries",region:n},h):c.string(g)?this.getSummoners({names:g,region:n},function(t,r){if(t)return h(t);var i=[],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;i.push(r[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:i.join(",")+"/masteries",region:n},h)}):"object"!==a(arguments[0])||"string"!=typeof g&&"string"!=typeof d?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"):this.getSummoner({name:g||d,region:n},function(t,r){return t?h(t):e._runesMasteriesRequest({endUrl:r[e._sanitizeName(g||d)].id+"/masteries",region:n},h)})}},{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,u=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"===a(arguments[0])&&"string"==typeof u?this.getSummoner({name:u,region:n},function(t,r){return t?m(t):e._statsRequest({endUrl:r[e._sanitizeName(u)].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,u=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"===a(arguments[0])&&"string"==typeof u?this.getSummoner({name:u,region:n},function(t,r){return t?m(t):e._statsRequest({endUrl:r[e._sanitizeName(u)].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.id,o=t.summonerIDs,u=t.summonerID,l=t.playerIDs,m=t.playerID,g=t.names,d=t.name,h=arguments[1];return c.int(i||o||l)?this._summonerRequest({endUrl:""+(i||o||l).join(","),region:n},h):Number.isInteger(i||s||o||u||l||m)?this._summonerRequest({endUrl:""+(i||s||o||u||l||m),region:n},h):c.string(g)?this._summonerRequest({endUrl:"by-name/"+g.map(function(t){return e._sanitizeName(t)}).join(","),region:n},h):"object"!==a(arguments[0])||"string"!=typeof g&&"string"!=typeof d?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||d),region:n},h)}},{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,u=arguments[1];return Number.isInteger(n||i||s)?this.getSummoners({region:t,ids:[n||i||s]},u):"object"===a(arguments[0])&&"string"==typeof o?this.getSummoners({region:t,names:[o]},u):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.id,s=e.summonerIDs,o=e.summonerID,a=e.playerIDs,u=e.playerID,l=arguments[1];return c.int(n||s||a)?this._summonerRequest({endUrl:(n||s||a).join(",")+"/name",region:t},l):Number.isInteger(n||i||s||o||a||u)?this._summonerRequest({endUrl:(n||i||s||o||a||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}(),b={Kindred:I,REGIONS:d,LIMITS:m};e.exports=b}); | ||
!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 n={exports:{}};t(n,e.doubleEndedQueue,e.request,e.chalk,e.xregexp,e.queryString),e.kindredApi=n.exports}}(this,function(e,t,n,i,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 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}}(),l=function(){function e(n,i){o(this,e),this.allowedRequests=n,this.seconds=i,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"},d={BRAZIL:"br",EUROPE:"eune",EUROPE_WEST:"euw",KOREA:"kr",LATIN_AMERICA_NORTH:"lan",LATIN_AMERICA_SOUTH:"las",NORTH_AMERICA:"na",OCEANIA:"oce",RUSSIA:"ru",TURKEY:"tr",JAPAN:"jp"},h={br:"BRAZIL",eune:"EUROPE",euw:"EUROPE_WEST",kr:"KOREA",lan:"LATIN_AMERICA_NORTH",las:"LATIN_AMERICA_SOUTH",na:"NORTH_AMERICA",oce:"OCEANIA",ru:"RUSSIA",tr:"TURKEY",jp:"JAPAN"},p={CHAMPION:1.2,CURRENT_GAME:1,FEATURED_GAMES:1,GAME:1.3,LEAGUE:2.5,STATIC_DATA:1.2,STATUS:1,MATCH:2.2,MATCH_LIST:2.2,RUNES_MASTERIES:1.4,STATS:1.3,SUMMONER:1.4},y={int:function(e){return e.every(function(e){return Number.isInteger(e)})},string:function(e){return e.every(function(e){return"string"==typeof e})}},c={int:function(e){return e&&Array.isArray(e)&&y.int(e)&&e.length>0},string:function(e){return e&&Array.isArray(e)&&y.string(e)&&e.length>0}},v={400:"Bad Request",403:"Forbidden",404:"Not Found",415:"Unsupported Media Type",429:"Rate Limit Exceeded",500:"Internal Service Error",503:"Service Unavailable"},f=function(e){var t=v[e];if(t)return t},R=r("^[0-9\\p{L} _\\.]+$"),I=function(){function e(t){var n=t.key,r=t.defaultRegion,s=void 0===r?d.NORTH_AMERICA:r,a=t.debug,u=void 0!==a&&a,g=t.limits;o(this,e),this.key=n;var h=void 0,p=!0,y=!1,v=void 0;try{for(var f,R=Object.keys(d)[Symbol.iterator]();!(p=(f=R.next()).done);p=!0){var I=f.value;d[I]===s&&(h=!0)}}catch(e){y=!0,v=e}finally{try{!p&&R.return&&R.return()}finally{if(y)throw v}}if(this.defaultRegion=h?s:void 0,this.defaultRegion||(console.log(""+i.red("Initialization of Kindred failed: "+i.yellow(s)+" is an invalid region.")),console.log(""+i.red("Try importing "+i.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(i.red("Initialization of Kindred failed: Invalid "+i.yellow("limits")+". Valid examples: "+i.yellow("[[10, 10], [500, 600]]"))+"."),console.log(i.red("You can also pass in one of these two strings:")+" dev/prod "),console.log(""+i.red("and Kindred will set the limits appropriately.")),process.exit(1)),this.limits={},"dev"===g&&(g=m.DEV),"prod"===g&&(g=m.PROD);var b=!0,_=!1,S=void 0;try{for(var q,D=Object.keys(d)[Symbol.iterator]();!(b=(q=D.next()).done);b=!0){var U=q.value;this.limits[d[U]]=[new l(g[0][0],g[0][1]),new l(g[1][0],g[1][1])]}}catch(e){_=!0,S=e}finally{try{!b&&D.return&&D.return()}finally{if(_)throw S}}}this.Champion={getChampions:this.getChamps.bind(this),getAll: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),getTotalChampionMasteryScore: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),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),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),getChampion:this.getChampion.bind(this),getItems:this.getItems.bind(this),getItem:this.getItem.bind(this),getLanguageStrings:this.getLanguageStrings.bind(this),getMasteries:this.getMasteryList.bind(this),getMastery:this.getMastery.bind(this),getRealmData:this.getRealmData.bind(this),getRunes:this.getRuneList.bind(this),getRune:this.getRune.bind(this),getSummonerSpells:this.getSummonerSpells.bind(this),getSummonerSpell:this.getSummonerSpell.bind(this),getVersionData: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)},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),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 "+i.yellow(e)+" is not valid. Request failed."),process.exit(1)}},{key:"_validName",value:function(e){return R.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?"?":"&",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,d=void 0!==g&&g,h=e.staticReq,p=void 0!==h&&h,y=e.championMastery,c=void 0!==y&&y,v=e.options,R=void 0===v?{}:v,I=function(){return new Promise(function(e,a){var l=p?"global":u,g=s.stringify(R),h=g?"?"+g:"",y=r._makeUrl(o+h,l,p,m,d,c);if(r.limits){var v=r;!function t(r){v.canMakeRequest(u)?(p||(v.limits[u][0].addRequest(),v.limits[u][1].addRequest()),n({url:y},function(n,s,o){if(s&&o){var u=void 0,l=s.statusCode;if(l>=200&&l<300?u=i.green(l):l>=400&&l<500?u=i.red(l+" "+f(l)):l>=500&&(u=i.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+" : "+i.yellow(y)):r(n,JSON.parse(o));if(500===l)v.debug&&console.log("!!! resending promise request !!!"),setTimeout(function(){return a("retry")},1e3);else{if(429!==l)return n||l>=400?a("err:",n,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(n,y)})):setTimeout(function(){t.bind(v)(r)},1e3)}(t)}else n({url:y},function(n,s,o){if(s){var u=void 0,l=s.statusCode;return l>=200&&l<300?u=i.green(l):l>=400&&l<500?u=i.red(l+" "+f(l)):l>=500&&(u=i.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+" : "+i.yellow(y)):t(n,JSON.parse(o)):n?a("err:",n):e(JSON.parse(o))}console.log(n,y)})})};return t?I():I().catch(I).catch(I).catch(I).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"+p.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"+p.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"+p.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"+p.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"+p.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"+p.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"+p.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"+p.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"+p.SUMMONER+"/summoner/"+n,region:i},t)}},{key:"_logError",value:function(e,t){console.log(i.bold.yellow(e),i.red("request"),i.bold.red("FAILED")+i.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=t||n?i:arguments[0])}},{key:"getChamp",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.id,r=e.championID,s=arguments[1];return Number.isInteger(n)||Number.isInteger(r)?this._championRequest({endUrl:"champion/"+(n||r),region:t},s):this._logError(this.getChamp.name,"required params "+i.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,r=e.playerID,s=e.championID,o=e.options,a=arguments[1];if(Number.isInteger(r)&&Number.isInteger(s)){var u=g[h[n]];return this._championMasteryRequest({endUrl:u+"/player/"+r+"/champion/"+s,region:n,options:o},a)}return this._logError(this.getChampMastery.name,"required params "+i.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,r=void 0===n?this.defaultRegion:n,s=t.id,o=t.summonerID,u=t.playerID,l=t.name,m=t.options,d=arguments[1];if(Number.isInteger(s||o||u)){var p=g[h[r]];return this._championMasteryRequest({endUrl:p+"/player/"+(s||o||u)+"/champions",region:r,options:m},d)}if("object"===a(arguments[0])&&"string"==typeof l){var y=g[h[r]];return this.getSummoner({name:l,region:r},function(t,n){return t?d(t):e._championMasteryRequest({endUrl:y+"/player/"+n[e._sanitizeName(l)].id+"/champions",region:r},d)})}return this._logError(this.getChampMasteries.name,"required params "+i.yellow("`id/summonerID/playerID` (int)")+" or "+i.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,r=void 0===n?this.defaultRegion:n,s=t.id,o=t.summonerID,u=t.playerID,l=t.name,m=t.options,d=arguments[1];if(Number.isInteger(s||o||u)){var p=g[h[r]];return this._championMasteryRequest({endUrl:p+"/player/"+(s||o||u)+"/score",region:r,options:m},d)}if("object"===a(arguments[0])&&"string"==typeof l){var y=g[h[r]];return this.getSummoner({name:l,region:r},function(t,n){return t?d(t):e._championMasteryRequest({endUrl:y+"/player/"+n[e._sanitizeName(l)].id+"/score",region:r},d)})}return this._logError(this.getTotalChampMasteryScore.name,"required params "+i.yellow("`id/summonerID/playerID` (int)")+" or "+i.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,r=void 0===n?this.defaultRegion:n,s=t.id,o=t.summonerID,u=t.playerID,l=t.name,m=t.options,d=arguments[1];if(Number.isInteger(s||o||u)){var p=g[h[r]];return this._championMasteryRequest({endUrl:p+"/player/"+(s||o||u)+"/topchampions",region:r,options:m},d)}if("object"===a(arguments[0])&&"string"==typeof l){var y=g[h[r]];return this.getSummoner({name:l,region:r},function(t,n){return t?d(t):e._championMasteryRequest({endUrl:y+"/player/"+n[e._sanitizeName(l)].id+"/topchampions",region:r},d)})}return this._logError(this.getTopChamps.name,"required params "+i.yellow("`id/summonerID/playerID` (int)")+" or "+i.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,r=void 0===n?this.defaultRegion:n,s=t.id,o=t.summonerID,u=t.playerID,l=t.name,m=arguments[1],d=g[h[r]];return Number.isInteger(s||o||u)?this._currentGameRequest({endUrl:""+(s||o||u),platformId:d,region:r},m):"object"===a(arguments[0])&&"string"==typeof l?this.getSummoner({name:l,region:r},function(t,n){return t?m(t):e._currentGameRequest({endUrl:""+n[e._sanitizeName(l)].id,platformId:d,region:r},m)}):this._logError(this.getCurrentGame.name,"required params "+i.yellow("`id/summonerID/playerID` (int)")+" or "+i.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,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:n},l):"object"===a(arguments[0])&&"string"==typeof u?this.getSummoner({name:u,region:n},function(t,i){return t?l(t):e._gameRequest({endUrl:"by-summoner/"+i[e._sanitizeName(u)].id+"/recent",region:n},l)}):this._logError(this.getRecentGames.name,"required params "+i.yellow("`id/summonerID/playerID` (int)")+" or "+i.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,r=t.ids,s=t.id,o=t.summonerIDs,u=t.summonerID,l=t.playerIDs,m=t.playerID,g=t.names,d=t.name,h=t.options,p=arguments[1];return c.int(r||o||l)?this._leagueRequest({endUrl:"by-summoner/"+(r||o||l).join(","),region:n,options:h},p):Number.isInteger(r||s||o||u||l||m)?this._leagueRequest({endUrl:"by-summoner/"+(r||s||o||u||l||m),region:n,options:h},p):c.string(g)?this.getSummoners({names:g,region:n},function(t,i){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(i[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:n,options:h},p)}):"object"!==a(arguments[0])||"string"!=typeof g&&"string"!=typeof d?this._logError(this.getLeagues.name,"required params "+i.yellow("`ids/summonerIDs/playerIDs` ([int]/int)")+", "+i.yellow("`id/summonerID/playerID` (int)")+", "+i.yellow("`names` ([str]/str)")+", or "+i.yellow("`name` (str)")+" not passed in"):this.getSummoner({name:g||d,region:n},function(t,i){return t?p(t):e._leagueRequest({endUrl:"by-summoner/"+i[e._sanitizeName(g||d)].id,region:n,options:h},p)})}},{key:"getLeagueEntries",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.region,r=t.ids,s=t.id,o=t.summonerIDs,u=t.summonerID,l=t.playerIDs,m=t.playerID,g=t.names,d=t.name,h=arguments[1];return c.int(r||o||l)?this._leagueRequest({endUrl:"by-summoner/"+(r||o||l).join(",")+"/entry",region:n},h):Number.isInteger(r||s||o||u||l||m)?this._leagueRequest({endUrl:"by-summoner/"+(r||s||o||u||l||m)+"/entry",region:n},h):c.string(g)?this.getSummoners({names:g,region:n},function(t,i){if(t)return h(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(i[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:n},h)}):"object"!==a(arguments[0])||"string"!=typeof g&&"string"!=typeof d?void this._logError(this.getLeagueEntries.name,"required params "+i.yellow("`ids/summonerIDs/playerIDs` ([int]/int)")+", "+i.yellow("`id/summonerID/playerID` (int)")+", "+i.yellow("`names` ([str]/str)")+", or "+i.yellow("`name` (str)")+" not passed in"):this.getSummoner({name:g||d,region:n},function(t,i){return t?h(t):e._leagueRequest({endUrl:"by-summoner/"+i[e._sanitizeName(g||d)].id+"/entry",region:n},h)})}},{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=t||i?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=t||i?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=t||n?i:arguments[0])}},{key:"getChampion",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.id,r=e.championID,s=e.options,o=arguments[1];return Number.isInteger(n||r)?this._staticRequest({endUrl:"champion/"+(n||r),region:t,options:s},o):this._logError(this.getChampion.name,"required params "+i.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=t||n?i:arguments[0])}},{key:"getItem",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.id,r=e.itemID,s=e.options,o=arguments[1];return Number.isInteger(n||r)?this._staticRequest({endUrl:"item/"+(n||r),region:t,options:s},o):this._logError(this.getItem.name,"required params "+i.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=t||n?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=t||n?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=t||n?i:arguments[0])}},{key:"getMastery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.id,r=e.masteryID,s=e.options,o=arguments[1];return Number.isInteger(n||r)?this._staticRequest({endUrl:"mastery/"+(n||r),region:t,options:s},o):this._logError(this.getMastery.name,"required params "+i.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=t||n?i:arguments[0])}},{key:"getRune",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.id,r=e.runeID,s=e.options,o=arguments[1];return Number.isInteger(n||r)?this._staticRequest({endUrl:"rune/"+(n||r),region:t,options:s},o):this._logError(this.getRune.name,"required params "+i.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=t||n?i:arguments[0])}},{key:"getSummonerSpell",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.id,r=e.spellID,s=e.summonerSpellID,o=e.options,a=arguments[1];return Number.isInteger(n||r||s)?this._staticRequest({endUrl:"summoner-spell/"+(n||r||s),region:t,options:o},a):this._logError(this.getSummonerSpell.name,"required params "+i.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=t||n?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,r=e.matchID,s=e.options,o=void 0===s?{includeTimeline:!0}:s,a=arguments[1];return Number.isInteger(n||r)?this._matchRequest({endUrl:""+(n||r),region:t,options:o},a):this._logError(this.getMatch.name,"required params "+i.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,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:n,options:m},g):"object"===a(arguments[0])&&"string"==typeof u?this.getSummoner({name:u,region:n},function(t,i){return t?g(t):e._matchListRequest({endUrl:""+i[e._sanitizeName(u)].id,region:n,options:m},g)}):this._logError(this.getMatchList.name,"required params "+i.yellow("`id/summonerID/playerID` (int)")+" or "+i.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,r=t.ids,s=t.id,o=t.summonerIDs,u=t.summonerID,l=t.playerIDs,m=t.playerID,g=t.names,d=t.name,h=arguments[1];return c.int(r||o||l)?this._runesMasteriesRequest({endUrl:(r||o||l).join()+"/runes",region:n},h):Number.isInteger(r||s||o||u||l||m)?this._runesMasteriesRequest({endUrl:(r||s||o||u||l||m)+"/runes",region:n},h):c.string(g)?this.getSummoners({names:g,region:n},function(t,i){if(t)return h(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(i[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:n},h)}):"object"!==a(arguments[0])||"string"!=typeof g&&"string"!=typeof d?this._logError(this.getRunes.name,"required params "+i.yellow("`ids/summonerIDs/playerIDs` ([int]/int)")+", "+i.yellow("`id/summonerID/playerID` (int)")+", "+i.yellow("`names` ([str]/str)")+", or "+i.yellow("`name` (str)")+" not passed in"):this.getSummoner({name:g||d,region:n},function(t,i){return t?h(t):e._runesMasteriesRequest({endUrl:i[e._sanitizeName(g||d)].id+"/runes",region:n},h)})}},{key:"getMasteries",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.region,r=t.ids,s=t.id,o=t.summonerIDs,u=t.summonerID,l=t.playerIDs,m=t.playerID,g=t.names,d=t.name,h=arguments[1];return c.int(r||o||l)?this._runesMasteriesRequest({endUrl:(r||o||l).join()+"/masteries",region:n},h):Number.isInteger(r||s||o||u||l||m)?this._runesMasteriesRequest({endUrl:(r||s||o||u||l||m)+"/masteries",region:n},h):c.string(g)?this.getSummoners({names:g,region:n},function(t,i){if(t)return h(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(i[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:n},h)}):"object"!==a(arguments[0])||"string"!=typeof g&&"string"!=typeof d?this._logError(this.getMasteries.name,"required params "+i.yellow("`ids/summonerIDs/playerIDs` ([int]/int)")+", "+i.yellow("`id/summonerID/playerID` (int)")+", "+i.yellow("`names` ([str]/str)")+", or "+i.yellow("`name` (str)")+" not passed in"):this.getSummoner({name:g||d,region:n},function(t,i){return t?h(t):e._runesMasteriesRequest({endUrl:i[e._sanitizeName(g||d)].id+"/masteries",region:n},h)})}},{key:"getRankedStats",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=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:n,options:l},m):"object"===a(arguments[0])&&"string"==typeof u?this.getSummoner({name:u,region:n},function(t,i){return t?m(t):e._statsRequest({endUrl:i[e._sanitizeName(u)].id+"/ranked",region:n,options:l},m)}):void this._logError(this.getRankedStats.name,"required params "+i.yellow("`id/summonerID/playerID` (int)")+" or "+i.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,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:n,options:l},m):"object"===a(arguments[0])&&"string"==typeof u?this.getSummoner({name:u,region:n},function(t,i){return t?m(t):e._statsRequest({endUrl:i[e._sanitizeName(u)].id+"/summary",region:n,options:l},m)}):void this._logError(this.getRankedStats.name,"required params "+i.yellow("`id/summonerID/playerID` (int)")+" or "+i.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,r=t.ids,s=t.id,o=t.summonerIDs,u=t.summonerID,l=t.playerIDs,m=t.playerID,g=t.names,d=t.name,h=arguments[1];return c.int(r||o||l)?this._summonerRequest({endUrl:""+(r||o||l).join(","),region:n},h):Number.isInteger(r||s||o||u||l||m)?this._summonerRequest({endUrl:""+(r||s||o||u||l||m),region:n},h):c.string(g)?this._summonerRequest({endUrl:"by-name/"+g.map(function(t){return e._sanitizeName(t)}).join(","),region:n},h):"object"!==a(arguments[0])||"string"!=typeof g&&"string"!=typeof d?void this._logError(this.getSummoners.name,"required params "+i.yellow("`ids/summonerIDs/playerIDs` ([int]/int)")+", "+i.yellow("`id/summonerID/playerID` (int)")+", "+i.yellow("`names` ([str]/str)")+", or "+i.yellow("`name` (str)")+" not passed in"):this._summonerRequest({endUrl:"by-name/"+this._sanitizeName(g||d),region:n},h)}},{key:"getSummoner",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,n=e.id,r=e.summonerID,s=e.playerID,o=e.name,u=arguments[1];return Number.isInteger(n||r||s)?this.getSummoners({region:t,ids:[n||r||s]},u):"object"===a(arguments[0])&&"string"==typeof o?this.getSummoners({region:t,names:[o]},u):this._logError(this.getSummoner.name,"required params "+i.yellow("`id/summonerID/playerID` (int)")+" or "+i.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,r=e.id,s=e.summonerIDs,o=e.summonerID,a=e.playerIDs,u=e.playerID,l=arguments[1];return c.int(n||s||a)?this._summonerRequest({endUrl:(n||s||a).join(",")+"/name",region:t},l):Number.isInteger(n||r||s||o||a||u)?this._summonerRequest({endUrl:(n||r||s||o||a||u)+"/name",region:t},l):void this._logError(this.getSummonerNames.name,"required params "+i.yellow("required params `ids/summonerIDs/playerIDs` ([int]/int)")+" or "+i.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,r=e.summonerID,s=e.playerID,o=arguments[1];if(Number.isInteger(n))return this.getSummonerNames({region:t,id:n||r||s},o);this._logError(this.getSummonerName.name,"required params "+i.yellow("`id/summonerID/playerID` (int)")+" not passed in")}}]),e}(),b={Kindred:I,REGIONS:d,LIMITS:m};e.exports=b}); |
{ | ||
"name": "kindred-api", | ||
"version": "1.2.0", | ||
"version": "1.2.1", | ||
"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 working on adding namespaced functions. In addition, I'm heavily focusing on refactoring the code now. The docs are not fully updated yet. | ||
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. | ||
@@ -64,5 +64,10 @@ ## Philosophy | ||
* getChamps({ region, id (int), options (object) }, cb) | ||
* Namespaced Functions: *Champion.getChampions, CurrentGame.getAll* | ||
* Example 1: ```k.Champion.getAll({ region: REGIONS.KOREA }, rprint)``` | ||
2. **/api/lol/{region}/v1.2/champion/{id}** | ||
* Retrieve champion by ID. (REST) | ||
* getChamp({ region, id/championID (int) }, cb) | ||
* Namespaced Functions: *Champion.getChampion, Champion.get* | ||
* Example 1: ```k.Champion.get({ champID: 67 }, rprint)``` | ||
* Example 2: ```k.Champion.get({ champID: 67 }, rprint).then(data => console.log(data))``` | ||
@@ -75,5 +80,11 @@ ### Champion Mastery | ||
* getChampMastery({ region = this.defaultRegion, playerID (int), championID (int), options (object) }, cb) | ||
* Namespaced Functions: *ChampionMastery.getChampionMastery, ChampionMastery.get* | ||
* Example 1: ```k.ChampionMastery.get({ playerID: 20026563, championID: 203 }, rprint)``` | ||
* Example 2: ```k.ChampionMastery.get({ playerID: 20026563, championID: 203 }).then(data => console.log(data))``` | ||
2. **/championmastery/location/{location}/player/{playerId}/champions** | ||
* Get all champion mastery entries sorted by number of champion points descending. (RPC) | ||
* getChampMasteries({ region = this.defaultRegion, id/summonerID/playerID (int), name (string), options (object) }, cb) | ||
* Namespaced Functions: *ChampionMastery.getChampionMasteries, ChampionMastery.getAll, ChampionMastery.top, ChampionMastery.best* | ||
* Example 1: ```k.ChampionMastery.best({ id: 20026563 }, rprint)``` | ||
* Example 2: ```k.ChampionMastery.getAll({ id: 20026563 }).then(data => console.log(data))``` | ||
3. **/championmastery/location/{location}/player/{playerId}/score** | ||
@@ -92,2 +103,4 @@ * Get a player's total champion mastery score, which is sum of individual champion mastery levels. (RPC) | ||
* getCurrentGame({ region = this.defaultRegion, id/summonerID/playerID (int), name (str) }, cb) | ||
* Namespaced Functions: *CurrentGame.getCurrentGame, CurrentGame.get* | ||
* Example 1: ```k.CurrentGame.get({ name: 'Contractz' }, rprint)``` | ||
@@ -297,2 +310,16 @@ ### Featured Games | ||
/* | ||
I have recently added namespacing to the methods. | ||
You can check out all the namespaces and the aliases in the code | ||
since I didn't mention them in the endpoints-covered | ||
section yet. | ||
All the namespaces are named after the official names Riot have given them. | ||
*/ | ||
k.League.getChallengers(rprint) | ||
k.League.challengers(rprint) | ||
k.League.challengers() | ||
.then(data => console.log(data)) | ||
.catch(err => console.error(err)) | ||
/* | ||
getSummoners & getSummoner target both the by-name and by-id endpoints. | ||
@@ -306,2 +333,7 @@ In the case of the summoner endpoints, it made a lot more sense for the two | ||
k.getSummoner({ id: 354959 }, rprint) | ||
k.Summoner.getSummoner({ id: 354959 }, rprint) | ||
k.Summoner.get({ id: 354959 }, rprint) | ||
k.Summoner.get({ id: 354959 }) | ||
.then(data => console.log(data)) | ||
.catch(err => console.error(err)) | ||
@@ -329,6 +361,13 @@ /* | ||
k.getMatch({ matchID: 2459973154 }, rprint) | ||
k.Match.get({ id: 2459973154 }, rprint) | ||
k.Match.get({ id: 2459973154 }) | ||
.then(data => console.log(data)) | ||
.catch(err => console.error(err)) | ||
var names = ['beautifulkorean', 'c9gun', 'caaaaaaaaarIa'] | ||
k.getSummoners({ names: names }, rprint) | ||
k.Summoner.getAll({ names }, rprint) // getSummoners | ||
var ids = [22059766, 20026563, 44989337] | ||
k.Summoner.names({ ids }, rprint) | ||
k.getSummoners({ names: 'caaaaaaaaaria' }, rprint) | ||
@@ -404,3 +443,3 @@ k.getSummoners({ name: 'caaaaaaaaaria' }, rprint) | ||
/* | ||
Currently promises are bugged for these type of chained requests | ||
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 | ||
@@ -431,4 +470,4 @@ still. | ||
}}, rprint) // get challengers from ranked flex ladder | ||
k.getMatch({ id: 2459973154 }, rprint) // includes timeline by default | ||
k.getMatch({ id: 2459973154, options: { includeTimeline: false } }, rprint) | ||
k.Match.get({ id: 2459973154 }, rprint) // includes timeline by default | ||
k.Match.get({ id: 2459973154, options: { includeTimeline: false } }, rprint) | ||
@@ -458,5 +497,6 @@ /* | ||
k.getMastery({ id: furyMasteryId }, rprint) | ||
k.Static.getMastery({ id: furyMasteryId }, rprint) | ||
var msRuneId = 10002 | ||
k.getRune({ id: msRuneId }, rprint) | ||
k.Static.getRune({ id: msRuneId }, rprint) | ||
``` | ||
@@ -470,12 +510,15 @@ | ||
For example, the two methods getChamp() and getChampion() are actually different. | ||
~~For example, the two methods getChamp() and getChampion() are actually different.~~ | ||
getChamp() targets the champ endpoint | ||
~~getChamp() targets the champ endpoint~~ | ||
getChampion() targets the static endpoint | ||
~~getChampion() targets the static endpoint~~ | ||
I didn't want to attach getChampion() with 'static' in any way or form since I thought it looked kind of annoying because then I would want to attach static to the other static methods as well (maybe that's better?). | ||
~~I didn't want to attach getChampion() with 'static' in any way or form since I thought it looked kind of annoying because then I would want to attach static to the other static methods as well (maybe that's better?).~~ | ||
March 31: I decided to combat the above by just namespacing the functions | ||
(k.Static.getChampion vs k.Champion.getChampion/get). | ||
**Right now, the code is also quite messy and there is a lot of repeated code.** Function definitions are quite long because I include many aliases as well. I haven't thought of an elegant way to make a magic function that manages to work for every single endpoint request yet. | ||
Any help and/or advice is appreciated! |
@@ -80,3 +80,5 @@ const request = require('request') | ||
getTotalChampionMasteryScore: this.getTotalChampMasteryScore.bind(this), | ||
getTopChampions: this.getTopChamps.bind(this) | ||
getTopChampions: this.getTopChamps.bind(this), | ||
top: this.getTopChamps.bind(this), | ||
best: this.getTopChamps.bind(this) | ||
} | ||
@@ -83,0 +85,0 @@ |
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
332105
3050
513