kindred-api
Advanced tools
Comparing version 2.0.32 to 2.0.33
@@ -1,2 +0,2 @@ | ||
!function(e,t){if("function"==typeof define&&define.amd)define("kindred-api",["module","redis","double-ended-queue","xregexp","chalk","request","chalk","query-string"],t);else if("undefined"!=typeof exports)t(module,require("redis"),require("double-ended-queue"),require("xregexp"),require("chalk"),require("request"),require("chalk"),require("query-string"));else{var i={exports:{}};t(i,e.redis,e.doubleEndedQueue,e.xregexp,e.chalk,e.request,e.chalk,e.queryString),e.kindredApi=i.exports}}(this,function(e,t,i,n,s,r,o,a){"use strict";function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function d(e,t,i){return new P({key:e,defaultRegion:t,debug:i,limits:R.DEV,cacheOptions:M[0]})}function g(e,t){e?console.log(e):console.log(t)}var c="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 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}}(),h=function(){function e(){u(this,e),this.cache={}}return l(e,[{key:"get",value:function(e,t){return this.cache[e.key]?Date.now()>this.cache[e.key].expires?(delete this.cache[e.key],t("expired cache key")):t(null,this.cache[e.key].value):t("cache key doesn't exist")}},{key:"set",value:function(e,t){this.cache[e.key]={expires:e.ttl?Date.now()+1e3*e.ttl:null,value:t}}}]),e}(),m=function(){function e(i){u(this,e);var n=Object.assign({},i||{},{host:"127.0.0.1",port:6379,keyPrefix:"kindredAPI-"});this.client=t.createClient(n.port,n.host),this.client.on("error",function(e){console.log("Redis error:",e)}),process.on("exit",function(){console.log("closing"),this.client.quit()}),this.prefix=n.keyPrefix}return l(e,[{key:"get",value:function(e,t){this.client.get(this.prefix+e.key,function(e,i){i?t(e,i):t(e)})}},{key:"set",value:function(e,t){this.client.setex(this.prefix+e.key,e.ttl,t)}}]),e}(),y=function(){function e(t,n){u(this,e),this.allowedRequests=t,this.seconds=n,this.madeRequests=new i}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}(),p={CHAMPION:"platform",CHAMPION_MASTERY:"champion-mastery",GAME:null,LEAGUE:"league",STATUS:"status",MASTERIES:"platform",MATCH:"match",MATCH_LIST:null,RUNES:"platform",RUNES_MASTERIES:"platform",SPECTATOR:"spectator",STATIC_DATA:"static-data",STATS:null,SUMMONER:"summoner",TOURNAMENT_STUB:"tournament-stub",TOURNAMENT:"tournament"},f={MONTH:2592e3,WEEK:604800,DAY:846400,SIX_HOURS:21600,THREE_HOURS:10800,TWO_HOURS:7200,HOUR:3600,THIRTY_MINUTES:1800,SHORT:600,NONE:null},v={CHAMPION:f.MONTH,CHAMPION_MASTERY:f.SIX_HOURS,CURRENT_GAME:f.NONE,FEATURED_GAMES:f.NONE,GAME:f.HOUR,LEAGUE:f.SIX_HOURS,STATIC:f.MONTH,STATUS:f.NONE,MATCH:f.MONTH,MATCH_LIST:f.ONE_HOUR,RUNES_MASTERIES:f.WEEK,SPECTATOR:f.NONE,STATS:f.HOUR,SUMMONER:f.DAY,TOURNAMENT_STUB:f.HOUR,TOURNAMENT:f.HOUR},R={DEV:[[10,10],[500,600]],PROD:[[3e3,10],[18e4,600]]},I={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"},S={CUSTOM:0,NORMAL_3x3:8,NORMAL_5x5_BLIND:2,NORMAL_5x5_DRAFT:14,RANKED_SOLO_5x5:4,RANKED_PREMADE_5x5:6,RANKED_PREMADE_3x3:9,RANKED_FLEX_TT:9,RANKED_TEAM_3x3:41,RANKED_TEAM_5x5:42,ODIN_5x5_BLIND:16,ODIN_5x5_DRAFT:17,BOT_5x5:7,BOT_ODIN_5x5:25,BOT_5x5_INTRO:31,BOT_5x5_BEGINNER:32,BOT_5x5_INTERMEDIATE:33,BOT_TT_3x3:52,GROUP_FINDER_5x5:61,ARAM_5x5:65,ONEFORALL_5x5:70,FIRSTBLOOD_1x1:72,FIRSTBLOOD_2x2:73,SR_6x6:75,URF_5x5:76,ONEFORALL_MIRRORMODE_5x5:78,BOT_URF_5x5:83,NIGHTMARE_BOT_5x5_RANK1:91,NIGHTMARE_BOT_5x5_RANK2:92,NIGHTMARE_BOT_5x5_RANK5:93,ASCENSION_5x5:96,HEXAKILL:98,BILGEWATER_ARAM_5x5:100,KING_PORO_5x5:300,COUNTER_PICK:310,BILGEWATER_5x5:313,SIEGE:315,DEFINITELY_NOT_DOMINION_5x5:317,ARURF_5X5:318,ARSR_5x5:325,TEAM_BUILDER_DRAFT_UNRANKED_5x5:400,TEAM_BUILDER_DRAFT_RANKED_5x5:410,TEAM_BUILDER_RANKED_SOLO:420,RANKED_FLEX_SR:440,ASSASSINATE_5x5:600,DARKSTAR_3x3:610},b={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"},_={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"},E={CHAMPION:3,CHAMPION_MASTERY:3,CURRENT_GAME:1,FEATURED_GAMES:1,GAME:1.3,LEAGUE:3,STATIC_DATA:3,STATUS:3,MATCH:3,MATCH_LIST:2.2,RUNES_MASTERIES:3,SPECTATOR:3,STATS:1.3,SUMMONER:3,TOURNAMENT_STUB:3,TOURNAMENT:3},M=["in-memory-cache","redis"],A=n("^[0-9\\p{L} _\\.]+$"),T={int:function(e){return e.every(function(e){return Number.isInteger(e)})},string:function(e){return e.every(function(e){return"string"==typeof e})}},N={int:function(e){return e&&Array.isArray(e)&&T.int(e)&&e.length>0},string:function(e){return e&&Array.isArray(e)&&T.string(e)&&e.length>0}},U=function(e){var t=!0,i=!1,n=void 0;try{for(var s,r=Object.keys(b)[Symbol.iterator]();!(t=(s=r.next()).done);t=!0){var o=s.value;if(b[o]===e)return!0}}catch(e){i=!0,n=e}finally{try{!t&&r.return&&r.return()}finally{if(i)throw n}}return!1},C={400:"Bad Request",403:"Forbidden",404:"Not Found",415:"Unsupported Media Type",429:"Rate Limit Exceeded",500:"Internal Service Error",503:"Service Unavailable"},q=function(e){var t=C[e];if(t)return t},k=[200,400,500],O=function(e){return e>=k[0]&&e<k[1]?s.green(e):e>=k[1]&&e<k[2]?s.red(e+" "+q(e)):s.bold.red(e+" "+q(e))},L=function(e){return(Array.isArray(e)&&2!==e.length||!N.int(e[0])||2!==e[0].length||!N.int(e[1])||2!==e[1].length)&&"dev"!==e&&"prod"!==e},w=function(e,t,i){console.log(t,i),console.log({"x-app-rate-limit-count":e.headers["x-app-rate-limit-count"],"x-method-rate-limit-count":e.headers["x-method-rate-limit-count"],"x-rate-limit-count":e.headers["x-rate-limit-count"],"retry-after":e.headers["retry-after"]}),console.log()},P=function(){function e(t){var i=t.key,n=t.defaultRegion,s=void 0===n?b.NORTH_AMERICA:n,r=t.debug,a=void 0!==r&&r,d=t.limits,g=t.cacheOptions,c=t.cacheTTL;if(u(this,e),this.key=i,this.defaultRegion=U(s)?s:void 0,this.defaultRegion||(console.log(""+o.red("Initialization of Kindred failed: "+o.yellow(s)+" is an invalid region.")),console.log(""+o.red("Try importing "+o.yellow("require('./dist/kindred-api').REGIONS")+" and using one of those values instead.")),process.exit(1)),this.debug=a,g?(g===M[0]?this.cache=new h:g===M[1]?this.cache=new m:this.cache=g,this.CACHE_TIMERS=c?c:v):this.cache={get:function(e,t){return t(null,null)},set:function(e,t){}},this.CACHE_TIMERS||(this.CACHE_TIMERS={CHAMPION:0,CHAMPION_MASTERY:0,CURRENT_GAME:0,FEATURED_GAMES:0,GAME:0,LEAGUE:0,STATIC:0,STATUS:0,MATCH:0,MATCH_LIST:0,RUNES_MASTERIES:0,STATS:0,SUMMONER:0}),d){L(d)&&(console.log(o.red("Initialization of Kindred failed: Invalid "+o.yellow("limits")+". Valid examples: "+o.yellow("[[10, 10], [500, 600]]"))+"."),console.log(o.red("You can also pass in one of these two strings:")+" dev/prod "),console.log(""+o.red("and Kindred will set the limits appropriately.")),process.exit(1)),this.limits={},"dev"===d&&(d=R.DEV),"prod"===d&&(d=R.PROD);var l=!0,p=!1,f=void 0;try{for(var I,S=Object.keys(b)[Symbol.iterator]();!(l=(I=S.next()).done);l=!0){var _=I.value;this.limits[b[_]]=[new y(d[0][0],d[0][1]),new y(d[1][0],d[1][1])]}}catch(e){p=!0,f=e}finally{try{!l&&S.return&&S.return()}finally{if(p)throw f}}}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),list:this.listChampions.bind(this),by:{id:this.getChampionById.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),score:this.getTotalChampMasteryScore.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),list:this.listFeaturedGames.bind(this)},this.Game={getRecentGames:this.getRecentGames.bind(this),getRecent:this.getRecentGames.bind(this),recent:this.getRecentGames.bind(this),get:this.getRecentGames.bind(this)},this.League={getLeagues:this.getLeagues.bind(this),leagues:this.getLeagues.bind(this),get:this.getLeagues.bind(this),getLeaguePositions:this.getLeaguePositions.bind(this),getPositions:this.getLeaguePositions.bind(this),positions:this.getLeaguePositions.bind(this),getChallengers:this.getChallengers.bind(this),challengers:this.getChallengers.bind(this),getMasters:this.getMasters.bind(this),masters:this.getMasters.bind(this)},this.Challenger={list:this.listChallengers.bind(this)},this.Master={list:this.listMasters.bind(this)},this.Static={Champion:{list:this.getStaticChampionList.bind(this),by:{id:this.getStaticChampionById.bind(this)}},Item:{list:this.getStaticItemList.bind(this),by:{id:this.getStaticItemById.bind(this)}},LanguageString:{list:this.getStaticLanguageStringList.bind(this)},Language:{list:this.getStaticLanguageList.bind(this)},Map:{list:this.getStaticMapList.bind(this)},Mastery:{list:this.getStaticMasteryList.bind(this),by:{id:this.getStaticMasteryById.bind(this)}},ProfileIcon:{list:this.getStaticProfileIconList.bind(this)},Realm:{list:this.getStaticRealmList.bind(this)},Rune:{list:this.getStaticRuneList.bind(this),by:{id:this.getStaticRuneById.bind(this)}},SummonerSpell:{list:this.getStaticSummonerSpellList.bind(this),by:{id:this.getStaticSummonerSpellById.bind(this)}},Version:{list:this.getStaticVersionList.bind(this)},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),getMapData:this.getMapData.bind(this),mapData:this.getMapData.bind(this),map:this.getMapData.bind(this),maps:this.getMapData.bind(this),getMasteries:this.getMasteryList.bind(this),masteries:this.getMasteryList.bind(this),getMastery:this.getMastery.bind(this),mastery:this.getMastery.bind(this),getProfileIcons:this.getProfileIcons.bind(this),profileIcons:this.getProfileIcons.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)},this.Match={getMatch:this.getMatch.bind(this),get:this.getMatch.bind(this),getMatchTimeline:this.getMatchTimeline.bind(this),getTimeline:this.getMatchTimeline.bind(this),timeline:this.getMatchTimeline.bind(this),by:{id:this.getMatchById.bind(this)}},this.Matchlist={getMatchlist:this.getMatchlist.bind(this),get:this.getMatchlist.bind(this),getRecentMatchlist:this.getRecentMatchlist.bind(this),recent:this.getRecentMatchlist.bind(this),by:{account:this.getMatchlistByAccountId.bind(this),id:this.getMatchlistById.bind(this),name:this.getMatchlistByName.bind(this)}},this.MatchHistory={by:{account:"test"}},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),by:{account:this.getRunesByAccountId.bind(this),id:this.getRunesById.bind(this),name:this.getRunesByName.bind(this)}},this.Masteries={get:this.getMasteries.bind(this),by:{account:this.getMasteriesByAccountId.bind(this),id:this.getMasteriesById.bind(this),name:this.getMasteriesByName.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={getSummoner:this.getSummoner.bind(this),get:this.getSummoner.bind(this),grab:this.getSummoner.bind(this),getRunes:this.getRunes.bind(this),runes:this.getRunes.bind(this),getMasteries:this.getMasteries.bind(this),masteries:this.getMasteries.bind(this),getMatchHistory:this.getRecentMatchlist.bind(this),matchHistory:this.getRecentMatchlist.bind(this),getMatchlist:this.getMatchlist.bind(this),matchlist:this.getMatchlist.bind(this),getChampionMasteries:this.getChampMasteries.bind(this),championMasteries:this.getChampMasteries.bind(this),getTotalChampionMasteryScore:this.getTotalChampMasteryScore.bind(this),totalChampionMasteryScore:this.getTotalChampMasteryScore.bind(this),by:{account:this.getSummonerByAccountId.bind(this),id:this.getSummonerById.bind(this),name:this.getSummonerByName.bind(this)}},this.Tournament={getDTOByCode:this.getDTOByCode.bind(this),DTO:{by:{code:this.getDTOByCode.bind(this)}},getLobbyListEventsByCode:this.getLobbyListEventsByCode.bind(this),LobbyListEvents:{by:{code:this.getLobbyListEventsByCode.bind(this)}}},this.Ex={getSummonerByAccId:this.getSummonerByAccId.bind(this),getMatchlistByName:this.getMatchlistByName.bind(this),getRunesBySummonerId:this.getRunesBySummonerId.bind(this),getRunesByAccountId:this.getRunesByAccountId.bind(this),staticRuneList:this.staticRuneList.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 "+o.yellow(e)+" is not valid. Request failed."),process.exit(1)}},{key:"_validName",value:function(e){return A.test(e)}},{key:"_makeUrl",value:function(e,t,i,n,s,r){var o=i?"":t+"/",a=n||s||r?"":"api/lol/"+o,u="https://"+t+".api.riotgames.com/"+a+encodeURI(e),d="https://"+I[_[t]].toLowerCase()+".api.riotgames.com/lol/"+encodeURI(e);return d.lastIndexOf("v3")==-1?u:d}},{key:"_baseRequest",value:function(e,t){var i=this,n=e.endUrl,s=e.region,u=void 0===s?this.defaultRegion:s,d=e.status,g=void 0!==d&&d,c=e.observerMode,l=void 0!==c&&c,h=e.staticReq,m=void 0!==h&&h,y=e.championMastery,p=void 0!==y&&y,f=e.options,v=void 0===f?{}:f,R=e.cacheParams,I=void 0===R?{}:R,S=function(){return new Promise(function(e,s){var d=!0,c=!1,h=void 0;try{for(var y,f=Object.keys(v)[Symbol.iterator]();!(d=(y=f.next()).done);d=!0){var R=y.value;Array.isArray(v[R])&&(v[R]=v[R].join(","))}}catch(e){c=!0,h=e}finally{try{!d&&f.return&&f.return()}finally{if(c)throw h}}var S=a.stringify(v).replace(/%2C/,","),b=S?"?"+S:"",_=i._makeUrl(n+b,u,m,g,l,p),E=_+(_.lastIndexOf("?")===-1?"?":"&")+"api_key="+i.key;i.cache.get({key:_},function(n,a){if(a){i.debug&&console.log(o.green("CACHE HIT")+" "+E);var d=JSON.parse(a);return t?t(n,d):e(d)}if(i.limits){var g=i;!function t(i){g.canMakeRequest(u)?(m||(g.limits[u][0].addRequest(),g.limits[u][1].addRequest()),r({url:E},function(n,r,a){if(r&&a){var u=r.statusCode,d=O(u);if(g.debug&&w(r,d,E),"function"==typeof i)return u>=500&&(g.debug&&console.log("!!! resending request !!!"),setTimeout(function(){t.bind(g)(i)},1e3)),429===u&&(g.debug&&console.log("!!! resending request !!!"),setTimeout(function(){t.bind(g)(i)},1e3*r.headers["retry-after"]+50)),u>=400?i(d+" : "+o.yellow(_)):(Number.isInteger(I.ttl)&&I.ttl>0&&g.cache.set({key:_,ttl:I.ttl},a),i(n,JSON.parse(a)));if(500===u)g.debug&&console.log("!!! resending promise request !!!"),setTimeout(function(){return s("retry")},1e3);else{if(429!==u)return n||u>=400?s("err:",n,u):(Number.isInteger(I.ttl)&&I.ttl>0&&g.cache.set({key:_,ttl:I.ttl},a),e(JSON.parse(a)));g.debug&&console.log("!!! resending promise request !!!"),setTimeout(function(){return s("retry")},1e3*r.headers["retry-after"]+50)}}else console.log(n,E)})):setTimeout(function(){t.bind(g)(i)},1e3)}(t)}else r({url:E},function(n,r,a){if(r){var u=i,d=r.statusCode,g=O(d);return u.debug&&w(r,g,E),"function"==typeof t?d>=400?t(g+" : "+o.yellow(_)):t(n,JSON.parse(a)):n?s("err:",n):e(JSON.parse(a))}console.log(n,_)})})})};return t?S():S().catch(S).catch(S).catch(S).then(function(e){return e})}},{key:"_championMasteryRequest",value:function(e,t){var i=e.endUrl,n=e.region,s=e.options;return this._baseRequest({endUrl:p.CHAMPION_MASTERY+"/v"+E.CHAMPION+"/"+i,region:n,options:s,championMastery:!0,cacheParams:{ttl:this.CACHE_TIMERS.CHAMPION_MASTERY}},t)}},{key:"_championRequest",value:function(e,t){var i=e.endUrl,n=e.region,s=e.options;return this._baseRequest({endUrl:p.CHAMPION+"/v"+E.CHAMPION+"/"+i,region:n,options:s,cacheParams:{ttl:this.CACHE_TIMERS.CHAMPION}},t)}},{key:"_spectatorRequest",value:function(e,t){var i=e.endUrl,n=e.region;return this._baseRequest({endUrl:p.SPECTATOR+"/v"+E.SPECTATOR+"/"+i,region:n,cacheParams:{ttl:this.CACHE_TIMERS.SPECTATOR}},t)}},{key:"_staticRequest",value:function(e,t){var i=e.endUrl,n=e.region,s=void 0===n?this.defaultRegion:n,r=e.options;return this._baseRequest({endUrl:p.STATIC_DATA+"/v"+E.STATIC_DATA+"/"+i,staticReq:!0,region:s,options:r,cacheParams:{ttl:this.CACHE_TIMERS.STATIC}},t)}},{key:"_statusRequest",value:function(e,t){var i=e.endUrl,n=(e.region,e.options);return this._baseRequest({endUrl:p.STATUS+"/v"+E.STATUS+"/"+i,status:!0,options:n,cacheParams:{ttl:this.CACHE_TIMERS.STATUS}},t)}},{key:"_gameRequest",value:function(e,t){var i=e.endUrl,n=e.region;return this._baseRequest({endUrl:"v"+E.GAME+"/game/"+i,region:n,cacheParams:{ttl:this.CACHE_TIMERS.GAME}},t)}},{key:"_leagueRequest",value:function(e,t){var i=e.endUrl,n=e.region,s=e.options;return this._baseRequest({endUrl:p.LEAGUE+"/v"+E.LEAGUE+"/"+i,region:n,options:s,cacheParams:{ttl:this.CACHE_TIMERS.LEAGUE}},t)}},{key:"_matchRequest",value:function(e,t){var i=e.endUrl,n=e.region,s=e.options;return this._baseRequest({endUrl:p.MATCH+"/v"+E.MATCH+"/"+i,region:n,options:s,cacheParams:{ttl:this.CACHE_TIMERS.MATCH}},t)}},{key:"_matchlistRequest",value:function(e,t){var i=e.endUrl,n=e.region,s=e.options;return this._baseRequest({endUrl:"v"+E.MATCH_LIST+"/matchlist/by-summoner/"+i,region:n,options:s,cacheParams:{ttl:this.CACHE_TIMERS.MATCH_LIST}},t)}},{key:"_runesMasteriesRequest",value:function(e,t){var i=e.endUrl,n=e.region;return this._baseRequest({endUrl:p.RUNES_MASTERIES+"/v"+E.RUNES_MASTERIES+"/"+i,region:n,cacheParams:{ttl:this.CACHE_TIMERS.RUNES_MASTERIES}},t)}},{key:"_statsRequest",value:function(e,t){var i=e.endUrl,n=e.region,s=e.options;return this._baseRequest({endUrl:"v"+E.STATS+"/stats/by-summoner/"+i,region:n,options:s,cacheParams:{ttl:this.CACHE_TIMERS.STATS}},t)}},{key:"_summonerRequest",value:function(e,t){var i=e.endUrl,n=e.region;return this._baseRequest({endUrl:p.SUMMONER+"/v"+E.SUMMONER+"/summoners/"+i,region:n,cacheParams:{ttl:this.CACHE_TIMERS.SUMMONER}},t)}},{key:"_tournamentRequest",value:function(e,t){var i=(e.endUrl,e.region);return this._baseRequest({endUrl:p.TOURNAMENT+"/v"+E.TOURNAMENT,region:i,cacheParams:{ttl:this.CACHE_TIMERS.TOURNAMENT}},t)}},{key:"_logError",value:function(e,t){console.log(o.bold.yellow(e),o.red("request"),o.bold.red("FAILED")+o.red("; "+t)),process.exit(1)}},{key:"setRegion",value:function(e){this.defaultRegion=U(e)?e:void 0,console.log(""+o.red("setRegion() by Kindred failed: "+o.yellow(e)+" is an invalid region.")),console.log(""+o.red("Try importing "+o.yellow("require('./dist/kindred-api').REGIONS")+" and using one of those values instead.")),process.exit(1)}},{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"function"==typeof arguments[0]&&(n=arguments[0],arguments[0]=void 0),this._championRequest({endUrl:"champions",region:t,options:i},n)}},{key:"getChamp",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.id,n=e.championId,s=arguments[1];return Number.isInteger(i)||Number.isInteger(n)?this._championRequest({endUrl:"champions/"+(i||n),region:t},s):this._logError(this.getChamp.name,"required params "+o.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,n=e.playerId,s=e.championId,r=e.options,a=arguments[1];return Number.isInteger(n)&&Number.isInteger(s)?this._championMasteryRequest({endUrl:"champion-masteries/by-summoner/"+n+"/by-champion/"+s,region:i,options:r},a):this._logError(this.getChampMastery.name,"required params "+o.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,n=void 0===i?this.defaultRegion:i,s=t.accountId,r=t.accId,a=t.id,u=t.summonerId,d=t.playerId,g=t.name,l=arguments[1];return Number.isInteger(s||r)?new Promise(function(t,i){return e.getSummoner({accId:s||r,region:n},function(s,r){return s?void(l?l(s):i(s)):t(e._championMasteryRequest({endUrl:"champion-masteries/by-summoner/"+r.id,region:n},l))})}):Number.isInteger(a||u||d)?this._championMasteryRequest({endUrl:"champion-masteries/by-summoner/"+(a||u||d),region:n},l):"object"===c(arguments[0])&&"string"==typeof g?new Promise(function(t,i){return e.getSummoner({name:g,region:n},function(s,r){return s?void(l?l(s):i(s)):t(e._championMasteryRequest({endUrl:"champion-masteries/by-summoner/"+r.id,region:n},l))})}):this._logError(this.getChampMasteries.name,"required params "+o.yellow("`id/summonerId/playerId` (int)")+", "+o.yellow("`accountId/accId` (int)")+", or "+o.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,n=void 0===i?this.defaultRegion:i,s=t.accountId,r=t.accId,a=t.id,u=t.summonerId,d=t.playerId,g=t.name,l=t.options,h=arguments[1];return Number.isInteger(s||r)?new Promise(function(t,i){return e.getSummoner({accId:s||r,region:n},function(s,r){return s?void(h?h(s):i(s)):t(e._championMasteryRequest({endUrl:"scores/by-summoner/"+r.id,region:n},h))})}):Number.isInteger(a||u||d)?this._championMasteryRequest({endUrl:"scores/by-summoner/"+(a||u||d),region:n,options:l},h):"object"===c(arguments[0])&&"string"==typeof g?new Promise(function(t,i){return e.getSummoner({name:g,region:n},function(s,r){return s?void(h?h(s):i(s)):t(e._championMasteryRequest({endUrl:"scores/by-summoner/"+r.id,region:n},h))})}):this._logError(this.getTotalChampMasteryScore.name,"required params "+o.yellow("`id/summonerId/playerId` (int)")+", "+o.yellow("`accountId/accId` (int)")+", or "+o.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,n=t.accountId,s=t.accId,r=t.id,a=t.summonerId,u=t.playerId,d=t.name,g=arguments[1];return Number.isInteger(n||s)?new Promise(function(t,r){return e.getSummoner({accId:n||s,region:i},function(n,s){return n?void(g?g(n):r(n)):t(e._spectatorRequest({endUrl:"active-games/by-summoner/"+s.id,region:i},g))})}):Number.isInteger(r||a||u)?this._spectatorRequest({endUrl:"active-games/by-summoner/"+(r||a||u),region:i},g):"object"===c(arguments[0])&&"string"==typeof d?new Promise(function(t,n){return e.getSummoner({name:d,region:i},function(s,r){return s?void(g?g(s):n(s)):t(e._spectatorRequest({endUrl:"active-games/by-summoner/"+r.id,region:i},g))})}):this._logError(this.getCurrentGame.name,"required params "+o.yellow("`id/summonerId/playerId` (int)")+", "+o.yellow("`accountId/accId` (int)")+", or "+o.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"function"==typeof arguments[0]&&(i=arguments[0],arguments[0]=void 0),this._spectatorRequest({endUrl:"featured-games",region:t},i)}},{key:"getRecentGames",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=t.region,n=t.accountId,s=t.accId,r=t.id,a=t.summonerId,u=t.playerId,d=t.name,g=arguments[1];return Number.isInteger(n||s)?new Promise(function(t,r){return e.getSummoner({accId:n||s,region:i},function(n,s){return n?void(g?g(n):r(n)):t(e._gameRequest({endUrl:"by-summoner/"+s.id+"/recent",region:i},g))})}):Number.isInteger(r||a||u)?this._gameRequest({endUrl:"by-summoner/"+(r||a||u)+"/recent",region:i},g):"object"===c(arguments[0])&&"string"==typeof d?new Promise(function(t,n){return e.getSummoner({name:d,region:i},function(s,r){return s?void(g?g(s):n(s)):t(e._gameRequest({endUrl:"by-summoner/"+r.id+"/recent",region:i},g))})}):this._logError(this.getRecentGames.name,"required params "+o.yellow("`id/summonerId/playerId` (int)")+", "+o.yellow("`accountId/accId` (int)")+", or "+o.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,n=t.accountId,s=t.accId,r=t.id,a=t.summonerId,u=t.playerId,d=t.name,g=t.options,l=arguments[1];return Number.isInteger(n||s)?new Promise(function(t,r){return e.getSummoner({accId:n||s,region:i},function(n,s){return n?void(l?l(n):r(n)):t(e._leagueRequest({endUrl:"leagues/by-summoner/"+s.id,region:i,options:g},l))})}):Number.isInteger(r||a||u)?this._leagueRequest({endUrl:"leagues/by-summoner/"+(r||a||u),region:i,options:g},l):"object"===c(arguments[0])&&"string"==typeof d?new Promise(function(t,n){return e.getSummoner({name:d,region:i},function(s,r){return s?void(l?l(s):n(s)):t(e._leagueRequest({endUrl:"leagues/by-summoner/"+r.id,region:i,options:g},l))})}):this._logError(this.getLeagues.name,"required params "+o.yellow("`id/summonerId/playerId` (int)")+", "+o.yellow("`accountId/accId` (int)")+", or "+o.yellow("`name` (string)")+" not passed in")}},{key:"getLeaguePositions",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=t.region,n=t.accountId,s=t.accId,r=t.id,a=t.summonerId,u=t.playerId,d=t.name,g=arguments[1];return Number.isInteger(n||s)?new Promise(function(t,r){return e.getSummoner({accId:n||s,region:i},function(n,s){return n?void(g?g(n):r(n)):t(e._leagueRequest({endUrl:"positions/by-summoner/"+s.id,region:i},g))})}):Number.isInteger(r||a||u)?this._leagueRequest({endUrl:"positions/by-summoner/"+(r||a||u),region:i},g):"object"===c(arguments[0])&&"string"==typeof d?new Promise(function(t,n){return e.getSummoner({name:d,region:i},function(s,r){return s?void(g?g(s):n(s)):t(e._leagueRequest({endUrl:"positions/by-summoner/"+r.id,region:i},g))})}):void this._logError(this.getLeaguePositions.name,"required params "+o.yellow("`id/summonerId/playerId` (int)")+", "+o.yellow("`accountId/accId` (int)")+", or "+o.yellow("`name` (string)")+" not passed in")}},{key:"getChallengers",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.queue,n=void 0===i?"RANKED_SOLO_5x5":i,s=arguments[1];if(s="function"==typeof arguments[0]?arguments[0]:arguments[1],"string"==typeof n)return this._leagueRequest({endUrl:"challengerleagues/by-queue/"+n,region:t},s);this._logError(this.getChallengers.name,"required params "+o.yellow("`queue` (string)")+" not passed in")}},{key:"getMasters",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.queue,n=void 0===i?"RANKED_SOLO_5x5":i,s=arguments[1];if(s="function"==typeof arguments[0]?arguments[0]:arguments[1],"string"==typeof n)return this._leagueRequest({endUrl:"masterleagues/by-queue/"+n,region:t},s);this._logError(this.getMasters.name,"required params "+o.yellow("`queue` (string)")+" not passed in")}},{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"function"==typeof arguments[0]&&(n=arguments[0],arguments[0]=void 0),this._staticRequest({endUrl:"champions",region:t,options:i},n)}},{key:"getChampion",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.id,n=e.championId,s=e.options,r=arguments[1];return Number.isInteger(i||n)?this._staticRequest({endUrl:"champions/"+(i||n),region:t,options:s},r):this._logError(this.getChampion.name,"required params "+o.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"function"==typeof arguments[0]&&(n=arguments[0],arguments[0]=void 0),this._staticRequest({endUrl:"items",region:t,options:i},n)}},{key:"getItem",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.id,n=e.itemId,s=e.options,r=arguments[1];return Number.isInteger(i||n)?this._staticRequest({endUrl:"items/"+(i||n),region:t,options:s},r):this._logError(this.getItem.name,"required params "+o.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"function"==typeof arguments[0]&&(n=arguments[0],arguments[0]=void 0),this._staticRequest({endUrl:"language-strings",region:t,options:i},n)}},{key:"getLanguages",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=arguments[1];return"function"==typeof arguments[0]&&(i=arguments[0],arguments[0]=void 0),this._staticRequest({endUrl:"languages",region:t},i)}},{key:"getMapData",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.options,n=arguments[1];return"function"==typeof arguments[0]&&(n=arguments[0],arguments[0]=void 0),this._staticRequest({endUrl:"maps",region:t,options:i},n)}},{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"function"==typeof arguments[0]&&(n=arguments[0],arguments[0]=void 0),this._staticRequest({endUrl:"masteries",region:t,options:i},n)}},{key:"getMastery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.id,n=e.masteryId,s=e.options,r=arguments[1];return Number.isInteger(i||n)?this._staticRequest({endUrl:"masteries/"+(i||n),region:t,options:s},r):this._logError(this.getMastery.name,"required params "+o.yellow("`id/masteryId` (int)")+" not passed in")}},{key:"getProfileIcons",value:function(e,t){var i=e.region,n=e.options | ||
!function(e,t){if("function"==typeof define&&define.amd)define("kindred-api",["module","redis","double-ended-queue","xregexp","chalk","request","chalk","query-string"],t);else if("undefined"!=typeof exports)t(module,require("redis"),require("double-ended-queue"),require("xregexp"),require("chalk"),require("request"),require("chalk"),require("query-string"));else{var i={exports:{}};t(i,e.redis,e.doubleEndedQueue,e.xregexp,e.chalk,e.request,e.chalk,e.queryString),e.kindredApi=i.exports}}(this,function(e,t,i,n,s,r,o,a){"use strict";function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function d(e,t,i){return new P({key:e,defaultRegion:t,debug:i,limits:R.DEV,cacheOptions:M[0]})}function g(e,t){e?console.log(e):console.log(t)}var c="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 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}}(),h=function(){function e(){u(this,e),this.cache={}}return l(e,[{key:"get",value:function(e,t){return this.cache[e.key]?Date.now()>this.cache[e.key].expires?(delete this.cache[e.key],t("expired cache key")):t(null,this.cache[e.key].value):t("cache key doesn't exist")}},{key:"set",value:function(e,t){this.cache[e.key]={expires:e.ttl?Date.now()+1e3*e.ttl:null,value:t}}}]),e}(),m=function(){function e(i){u(this,e);var n=Object.assign({},i||{},{host:"127.0.0.1",port:6379,keyPrefix:"kindredAPI-"});this.client=t.createClient(n.port,n.host),this.client.on("error",function(e){console.log("Redis error:",e)}),process.on("exit",function(){console.log("closing"),this.client.quit()}),this.prefix=n.keyPrefix}return l(e,[{key:"get",value:function(e,t){this.client.get(this.prefix+e.key,function(e,i){i?t(e,i):t(e)})}},{key:"set",value:function(e,t){this.client.setex(this.prefix+e.key,e.ttl,t)}}]),e}(),y=function(){function e(t,n){u(this,e),this.allowedRequests=t,this.seconds=n,this.madeRequests=new i}return l(e,[{key:"__reload",value:function(){for(var e=(new Date).getTime();this.madeRequests.length>0&&e-this.madeRequests.peekFront()>=100*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}(),p={CHAMPION:"platform",CHAMPION_MASTERY:"champion-mastery",GAME:null,LEAGUE:"league",STATUS:"status",MASTERIES:"platform",MATCH:"match",MATCH_LIST:null,RUNES:"platform",RUNES_MASTERIES:"platform",SPECTATOR:"spectator",STATIC_DATA:"static-data",STATS:null,SUMMONER:"summoner",TOURNAMENT_STUB:"tournament-stub",TOURNAMENT:"tournament"},f={MONTH:2592e3,WEEK:604800,DAY:846400,SIX_HOURS:21600,THREE_HOURS:10800,TWO_HOURS:7200,HOUR:3600,THIRTY_MINUTES:1800,SHORT:600,NONE:null},v={CHAMPION:f.MONTH,CHAMPION_MASTERY:f.SIX_HOURS,CURRENT_GAME:f.NONE,FEATURED_GAMES:f.NONE,GAME:f.HOUR,LEAGUE:f.SIX_HOURS,STATIC:f.MONTH,STATUS:f.NONE,MATCH:f.MONTH,MATCH_LIST:f.ONE_HOUR,RUNES_MASTERIES:f.WEEK,SPECTATOR:f.NONE,STATS:f.HOUR,SUMMONER:f.DAY,TOURNAMENT_STUB:f.HOUR,TOURNAMENT:f.HOUR},R={DEV:[[10,10],[500,600]],PROD:[[3e3,10],[18e4,600]]},I={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"},S={CUSTOM:0,NORMAL_3x3:8,NORMAL_5x5_BLIND:2,NORMAL_5x5_DRAFT:14,RANKED_SOLO_5x5:4,RANKED_PREMADE_5x5:6,RANKED_PREMADE_3x3:9,RANKED_FLEX_TT:9,RANKED_TEAM_3x3:41,RANKED_TEAM_5x5:42,ODIN_5x5_BLIND:16,ODIN_5x5_DRAFT:17,BOT_5x5:7,BOT_ODIN_5x5:25,BOT_5x5_INTRO:31,BOT_5x5_BEGINNER:32,BOT_5x5_INTERMEDIATE:33,BOT_TT_3x3:52,GROUP_FINDER_5x5:61,ARAM_5x5:65,ONEFORALL_5x5:70,FIRSTBLOOD_1x1:72,FIRSTBLOOD_2x2:73,SR_6x6:75,URF_5x5:76,ONEFORALL_MIRRORMODE_5x5:78,BOT_URF_5x5:83,NIGHTMARE_BOT_5x5_RANK1:91,NIGHTMARE_BOT_5x5_RANK2:92,NIGHTMARE_BOT_5x5_RANK5:93,ASCENSION_5x5:96,HEXAKILL:98,BILGEWATER_ARAM_5x5:100,KING_PORO_5x5:300,COUNTER_PICK:310,BILGEWATER_5x5:313,SIEGE:315,DEFINITELY_NOT_DOMINION_5x5:317,ARURF_5X5:318,ARSR_5x5:325,TEAM_BUILDER_DRAFT_UNRANKED_5x5:400,TEAM_BUILDER_DRAFT_RANKED_5x5:410,TEAM_BUILDER_RANKED_SOLO:420,RANKED_FLEX_SR:440,ASSASSINATE_5x5:600,DARKSTAR_3x3:610},b={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"},_={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"},E={CHAMPION:3,CHAMPION_MASTERY:3,CURRENT_GAME:1,FEATURED_GAMES:1,GAME:1.3,LEAGUE:3,STATIC_DATA:3,STATUS:3,MATCH:3,MATCH_LIST:2.2,RUNES_MASTERIES:3,SPECTATOR:3,STATS:1.3,SUMMONER:3,TOURNAMENT_STUB:3,TOURNAMENT:3},M=["in-memory-cache","redis"],A=n("^[0-9\\p{L} _\\.]+$"),T={int:function(e){return e.every(function(e){return Number.isInteger(e)})},string:function(e){return e.every(function(e){return"string"==typeof e})}},N={int:function(e){return e&&Array.isArray(e)&&T.int(e)&&e.length>0},string:function(e){return e&&Array.isArray(e)&&T.string(e)&&e.length>0}},U=function(e){var t=!0,i=!1,n=void 0;try{for(var s,r=Object.keys(b)[Symbol.iterator]();!(t=(s=r.next()).done);t=!0){var o=s.value;if(b[o]===e)return!0}}catch(e){i=!0,n=e}finally{try{!t&&r.return&&r.return()}finally{if(i)throw n}}return!1},C={400:"Bad Request",403:"Forbidden",404:"Not Found",415:"Unsupported Media Type",429:"Rate Limit Exceeded",500:"Internal Service Error",503:"Service Unavailable"},q=function(e){var t=C[e];if(t)return t},k=[200,400,500],O=function(e){return e>=k[0]&&e<k[1]?s.green(e):e>=k[1]&&e<k[2]?s.red(e+" "+q(e)):s.bold.red(e+" "+q(e))},L=function(e){return(Array.isArray(e)&&2!==e.length||!N.int(e[0])||2!==e[0].length||!N.int(e[1])||2!==e[1].length)&&"dev"!==e&&"prod"!==e},w=function(e,t,i){console.log(t,i),console.log({"x-app-rate-limit-count":e.headers["x-app-rate-limit-count"],"x-method-rate-limit-count":e.headers["x-method-rate-limit-count"],"x-rate-limit-count":e.headers["x-rate-limit-count"],"retry-after":e.headers["retry-after"]}),console.log()},P=function(){function e(t){var i=t.key,n=t.defaultRegion,s=void 0===n?b.NORTH_AMERICA:n,r=t.debug,a=void 0!==r&&r,d=t.limits,g=t.cacheOptions,c=t.cacheTTL;if(u(this,e),this.key=i,this.defaultRegion=U(s)?s:void 0,this.defaultRegion||(console.log(""+o.red("Initialization of Kindred failed: "+o.yellow(s)+" is an invalid region.")),console.log(""+o.red("Try importing "+o.yellow("require('./dist/kindred-api').REGIONS")+" and using one of those values instead.")),process.exit(1)),this.debug=a,g?(g===M[0]?this.cache=new h:g===M[1]?this.cache=new m:this.cache=g,this.CACHE_TIMERS=c?c:v):this.cache={get:function(e,t){return t(null,null)},set:function(e,t){}},this.CACHE_TIMERS||(this.CACHE_TIMERS={CHAMPION:0,CHAMPION_MASTERY:0,CURRENT_GAME:0,FEATURED_GAMES:0,GAME:0,LEAGUE:0,STATIC:0,STATUS:0,MATCH:0,MATCH_LIST:0,RUNES_MASTERIES:0,STATS:0,SUMMONER:0}),d){L(d)&&(console.log(o.red("Initialization of Kindred failed: Invalid "+o.yellow("limits")+". Valid examples: "+o.yellow("[[10, 10], [500, 600]]"))+"."),console.log(o.red("You can also pass in one of these two strings:")+" dev/prod "),console.log(""+o.red("and Kindred will set the limits appropriately.")),process.exit(1)),this.limits={},"dev"===d&&(d=R.DEV),"prod"===d&&(d=R.PROD);var l=!0,p=!1,f=void 0;try{for(var I,S=Object.keys(b)[Symbol.iterator]();!(l=(I=S.next()).done);l=!0){var _=I.value;this.limits[b[_]]=[new y(d[0][0],d[0][1]),new y(d[1][0],d[1][1])]}}catch(e){p=!0,f=e}finally{try{!l&&S.return&&S.return()}finally{if(p)throw f}}}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),list:this.listChampions.bind(this),by:{id:this.getChampionById.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),score:this.getTotalChampMasteryScore.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),list:this.listFeaturedGames.bind(this)},this.Game={getRecentGames:this.getRecentGames.bind(this),getRecent:this.getRecentGames.bind(this),recent:this.getRecentGames.bind(this),get:this.getRecentGames.bind(this)},this.League={getLeagues:this.getLeagues.bind(this),leagues:this.getLeagues.bind(this),get:this.getLeagues.bind(this),getLeaguePositions:this.getLeaguePositions.bind(this),getPositions:this.getLeaguePositions.bind(this),positions:this.getLeaguePositions.bind(this),getChallengers:this.getChallengers.bind(this),challengers:this.getChallengers.bind(this),getMasters:this.getMasters.bind(this),masters:this.getMasters.bind(this)},this.Challenger={list:this.listChallengers.bind(this)},this.Master={list:this.listMasters.bind(this)},this.Static={Champion:{list:this.getStaticChampionList.bind(this),by:{id:this.getStaticChampionById.bind(this)}},Item:{list:this.getStaticItemList.bind(this),by:{id:this.getStaticItemById.bind(this)}},LanguageString:{list:this.getStaticLanguageStringList.bind(this)},Language:{list:this.getStaticLanguageList.bind(this)},Map:{list:this.getStaticMapList.bind(this)},Mastery:{list:this.getStaticMasteryList.bind(this),by:{id:this.getStaticMasteryById.bind(this)}},ProfileIcon:{list:this.getStaticProfileIconList.bind(this)},Realm:{list:this.getStaticRealmList.bind(this)},Rune:{list:this.getStaticRuneList.bind(this),by:{id:this.getStaticRuneById.bind(this)}},SummonerSpell:{list:this.getStaticSummonerSpellList.bind(this),by:{id:this.getStaticSummonerSpellById.bind(this)}},Version:{list:this.getStaticVersionList.bind(this)},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),getMapData:this.getMapData.bind(this),mapData:this.getMapData.bind(this),map:this.getMapData.bind(this),maps:this.getMapData.bind(this),getMasteries:this.getMasteryList.bind(this),masteries:this.getMasteryList.bind(this),getMastery:this.getMastery.bind(this),mastery:this.getMastery.bind(this),getProfileIcons:this.getProfileIcons.bind(this),profileIcons:this.getProfileIcons.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)},this.Match={getMatch:this.getMatch.bind(this),get:this.getMatch.bind(this),getMatchTimeline:this.getMatchTimeline.bind(this),getTimeline:this.getMatchTimeline.bind(this),timeline:this.getMatchTimeline.bind(this),by:{id:this.getMatchById.bind(this)}},this.Matchlist={getMatchlist:this.getMatchlist.bind(this),get:this.getMatchlist.bind(this),getRecentMatchlist:this.getRecentMatchlist.bind(this),recent:this.getRecentMatchlist.bind(this),by:{account:this.getMatchlistByAccountId.bind(this),id:this.getMatchlistById.bind(this),name:this.getMatchlistByName.bind(this)}},this.MatchHistory={by:{account:"test"}},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),by:{account:this.getRunesByAccountId.bind(this),id:this.getRunesById.bind(this),name:this.getRunesByName.bind(this)}},this.Masteries={get:this.getMasteries.bind(this),by:{account:this.getMasteriesByAccountId.bind(this),id:this.getMasteriesById.bind(this),name:this.getMasteriesByName.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={getSummoner:this.getSummoner.bind(this),get:this.getSummoner.bind(this),grab:this.getSummoner.bind(this),getRunes:this.getRunes.bind(this),runes:this.getRunes.bind(this),getMasteries:this.getMasteries.bind(this),masteries:this.getMasteries.bind(this),getMatchHistory:this.getRecentMatchlist.bind(this),matchHistory:this.getRecentMatchlist.bind(this),getMatchlist:this.getMatchlist.bind(this),matchlist:this.getMatchlist.bind(this),getChampionMasteries:this.getChampMasteries.bind(this),championMasteries:this.getChampMasteries.bind(this),getTotalChampionMasteryScore:this.getTotalChampMasteryScore.bind(this),totalChampionMasteryScore:this.getTotalChampMasteryScore.bind(this),by:{account:this.getSummonerByAccountId.bind(this),id:this.getSummonerById.bind(this),name:this.getSummonerByName.bind(this)}},this.Tournament={getDTOByCode:this.getDTOByCode.bind(this),DTO:{by:{code:this.getDTOByCode.bind(this)}},getLobbyListEventsByCode:this.getLobbyListEventsByCode.bind(this),LobbyListEvents:{by:{code:this.getLobbyListEventsByCode.bind(this)}}},this.Ex={getSummonerByAccId:this.getSummonerByAccId.bind(this),getMatchlistByName:this.getMatchlistByName.bind(this),getRunesBySummonerId:this.getRunesBySummonerId.bind(this),getRunesByAccountId:this.getRunesByAccountId.bind(this),staticRuneList:this.staticRuneList.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 "+o.yellow(e)+" is not valid. Request failed."),process.exit(1)}},{key:"_validName",value:function(e){return A.test(e)}},{key:"_makeUrl",value:function(e,t,i,n,s,r){var o=i?"":t+"/",a=n||s||r?"":"api/lol/"+o,u="https://"+t+".api.riotgames.com/"+a+encodeURI(e),d="https://"+I[_[t]].toLowerCase()+".api.riotgames.com/lol/"+encodeURI(e);return d.lastIndexOf("v3")==-1?u:d}},{key:"_baseRequest",value:function(e,t){var i=this,n=e.endUrl,s=e.region,u=void 0===s?this.defaultRegion:s,d=e.status,g=void 0!==d&&d,c=e.observerMode,l=void 0!==c&&c,h=e.staticReq,m=void 0!==h&&h,y=e.championMastery,p=void 0!==y&&y,f=e.options,v=void 0===f?{}:f,R=e.cacheParams,I=void 0===R?{}:R,S=function(){return new Promise(function(e,s){var d=!0,c=!1,h=void 0;try{for(var y,f=Object.keys(v)[Symbol.iterator]();!(d=(y=f.next()).done);d=!0){var R=y.value;Array.isArray(v[R])&&(v[R]=v[R].join(","))}}catch(e){c=!0,h=e}finally{try{!d&&f.return&&f.return()}finally{if(c)throw h}}var S=a.stringify(v).replace(/%2C/,","),b=S?"?"+S:"",_=i._makeUrl(n+b,u,m,g,l,p),E=_+(_.lastIndexOf("?")===-1?"?":"&")+"api_key="+i.key;i.cache.get({key:_},function(n,a){if(a){i.debug&&console.log(o.green("CACHE HIT")+" "+E);var d=JSON.parse(a);return t?t(n,d):e(d)}if(i.limits){var g=i;!function t(i){g.canMakeRequest(u)?(m||(g.limits[u][0].addRequest(),g.limits[u][1].addRequest()),r({url:E},function(n,r,a){if(r&&a){var u=r.statusCode,d=O(u);if(g.debug&&w(r,d,E),"function"==typeof i)return u>=500&&(g.debug&&console.log("!!! resending request !!!"),setTimeout(function(){t.bind(g)(i)},1e3)),429===u&&(g.debug&&console.log("!!! resending request !!!"),setTimeout(function(){t.bind(g)(i)},1e3*r.headers["retry-after"]+50)),u>=400?i(d+" : "+o.yellow(_)):(Number.isInteger(I.ttl)&&I.ttl>0&&g.cache.set({key:_,ttl:I.ttl},a),i(n,JSON.parse(a)));if(500===u)g.debug&&console.log("!!! resending promise request !!!"),setTimeout(function(){return s("retry")},1e3);else{if(429!==u)return n||u>=400?s("err:",n,u):(Number.isInteger(I.ttl)&&I.ttl>0&&g.cache.set({key:_,ttl:I.ttl},a),e(JSON.parse(a)));g.debug&&console.log("!!! resending promise request !!!"),setTimeout(function(){return s("retry")},1e3*r.headers["retry-after"]+50)}}else console.log(n,E)})):setTimeout(function(){t.bind(g)(i)},1e3)}(t)}else r({url:E},function(n,r,a){if(r){var u=i,d=r.statusCode,g=O(d);return u.debug&&w(r,g,E),"function"==typeof t?d>=400?t(g+" : "+o.yellow(_)):t(n,JSON.parse(a)):n?s("err:",n):e(JSON.parse(a))}console.log(n,_)})})})};return t?S():S().catch(S).catch(S).catch(S).then(function(e){return e})}},{key:"_championMasteryRequest",value:function(e,t){var i=e.endUrl,n=e.region,s=e.options;return this._baseRequest({endUrl:p.CHAMPION_MASTERY+"/v"+E.CHAMPION+"/"+i,region:n,options:s,championMastery:!0,cacheParams:{ttl:this.CACHE_TIMERS.CHAMPION_MASTERY}},t)}},{key:"_championRequest",value:function(e,t){var i=e.endUrl,n=e.region,s=e.options;return this._baseRequest({endUrl:p.CHAMPION+"/v"+E.CHAMPION+"/"+i,region:n,options:s,cacheParams:{ttl:this.CACHE_TIMERS.CHAMPION}},t)}},{key:"_spectatorRequest",value:function(e,t){var i=e.endUrl,n=e.region;return this._baseRequest({endUrl:p.SPECTATOR+"/v"+E.SPECTATOR+"/"+i,region:n,cacheParams:{ttl:this.CACHE_TIMERS.SPECTATOR}},t)}},{key:"_staticRequest",value:function(e,t){var i=e.endUrl,n=e.region,s=void 0===n?this.defaultRegion:n,r=e.options;return this._baseRequest({endUrl:p.STATIC_DATA+"/v"+E.STATIC_DATA+"/"+i,staticReq:!0,region:s,options:r,cacheParams:{ttl:this.CACHE_TIMERS.STATIC}},t)}},{key:"_statusRequest",value:function(e,t){var i=e.endUrl,n=(e.region,e.options);return this._baseRequest({endUrl:p.STATUS+"/v"+E.STATUS+"/"+i,status:!0,options:n,cacheParams:{ttl:this.CACHE_TIMERS.STATUS}},t)}},{key:"_gameRequest",value:function(e,t){var i=e.endUrl,n=e.region;return this._baseRequest({endUrl:"v"+E.GAME+"/game/"+i,region:n,cacheParams:{ttl:this.CACHE_TIMERS.GAME}},t)}},{key:"_leagueRequest",value:function(e,t){var i=e.endUrl,n=e.region,s=e.options;return this._baseRequest({endUrl:p.LEAGUE+"/v"+E.LEAGUE+"/"+i,region:n,options:s,cacheParams:{ttl:this.CACHE_TIMERS.LEAGUE}},t)}},{key:"_matchRequest",value:function(e,t){var i=e.endUrl,n=e.region,s=e.options;return this._baseRequest({endUrl:p.MATCH+"/v"+E.MATCH+"/"+i,region:n,options:s,cacheParams:{ttl:this.CACHE_TIMERS.MATCH}},t)}},{key:"_matchlistRequest",value:function(e,t){var i=e.endUrl,n=e.region,s=e.options;return this._baseRequest({endUrl:"v"+E.MATCH_LIST+"/matchlist/by-summoner/"+i,region:n,options:s,cacheParams:{ttl:this.CACHE_TIMERS.MATCH_LIST}},t)}},{key:"_runesMasteriesRequest",value:function(e,t){var i=e.endUrl,n=e.region;return this._baseRequest({endUrl:p.RUNES_MASTERIES+"/v"+E.RUNES_MASTERIES+"/"+i,region:n,cacheParams:{ttl:this.CACHE_TIMERS.RUNES_MASTERIES}},t)}},{key:"_statsRequest",value:function(e,t){var i=e.endUrl,n=e.region,s=e.options;return this._baseRequest({endUrl:"v"+E.STATS+"/stats/by-summoner/"+i,region:n,options:s,cacheParams:{ttl:this.CACHE_TIMERS.STATS}},t)}},{key:"_summonerRequest",value:function(e,t){var i=e.endUrl,n=e.region;return this._baseRequest({endUrl:p.SUMMONER+"/v"+E.SUMMONER+"/summoners/"+i,region:n,cacheParams:{ttl:this.CACHE_TIMERS.SUMMONER}},t)}},{key:"_tournamentRequest",value:function(e,t){var i=(e.endUrl,e.region);return this._baseRequest({endUrl:p.TOURNAMENT+"/v"+E.TOURNAMENT,region:i,cacheParams:{ttl:this.CACHE_TIMERS.TOURNAMENT}},t)}},{key:"_logError",value:function(e,t){console.log(o.bold.yellow(e),o.red("request"),o.bold.red("FAILED")+o.red("; "+t)),process.exit(1)}},{key:"setRegion",value:function(e){this.defaultRegion=U(e)?e:void 0,console.log(""+o.red("setRegion() by Kindred failed: "+o.yellow(e)+" is an invalid region.")),console.log(""+o.red("Try importing "+o.yellow("require('./dist/kindred-api').REGIONS")+" and using one of those values instead.")),process.exit(1)}},{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"function"==typeof arguments[0]&&(n=arguments[0],arguments[0]=void 0),this._championRequest({endUrl:"champions",region:t,options:i},n)}},{key:"getChamp",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.id,n=e.championId,s=arguments[1];return Number.isInteger(i)||Number.isInteger(n)?this._championRequest({endUrl:"champions/"+(i||n),region:t},s):this._logError(this.getChamp.name,"required params "+o.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,n=e.playerId,s=e.championId,r=e.options,a=arguments[1];return Number.isInteger(n)&&Number.isInteger(s)?this._championMasteryRequest({endUrl:"champion-masteries/by-summoner/"+n+"/by-champion/"+s,region:i,options:r},a):this._logError(this.getChampMastery.name,"required params "+o.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,n=void 0===i?this.defaultRegion:i,s=t.accountId,r=t.accId,a=t.id,u=t.summonerId,d=t.playerId,g=t.name,l=arguments[1];return Number.isInteger(s||r)?new Promise(function(t,i){return e.getSummoner({accId:s||r,region:n},function(s,r){return s?void(l?l(s):i(s)):t(e._championMasteryRequest({endUrl:"champion-masteries/by-summoner/"+r.id,region:n},l))})}):Number.isInteger(a||u||d)?this._championMasteryRequest({endUrl:"champion-masteries/by-summoner/"+(a||u||d),region:n},l):"object"===c(arguments[0])&&"string"==typeof g?new Promise(function(t,i){return e.getSummoner({name:g,region:n},function(s,r){return s?void(l?l(s):i(s)):t(e._championMasteryRequest({endUrl:"champion-masteries/by-summoner/"+r.id,region:n},l))})}):this._logError(this.getChampMasteries.name,"required params "+o.yellow("`id/summonerId/playerId` (int)")+", "+o.yellow("`accountId/accId` (int)")+", or "+o.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,n=void 0===i?this.defaultRegion:i,s=t.accountId,r=t.accId,a=t.id,u=t.summonerId,d=t.playerId,g=t.name,l=t.options,h=arguments[1];return Number.isInteger(s||r)?new Promise(function(t,i){return e.getSummoner({accId:s||r,region:n},function(s,r){return s?void(h?h(s):i(s)):t(e._championMasteryRequest({endUrl:"scores/by-summoner/"+r.id,region:n},h))})}):Number.isInteger(a||u||d)?this._championMasteryRequest({endUrl:"scores/by-summoner/"+(a||u||d),region:n,options:l},h):"object"===c(arguments[0])&&"string"==typeof g?new Promise(function(t,i){return e.getSummoner({name:g,region:n},function(s,r){return s?void(h?h(s):i(s)):t(e._championMasteryRequest({endUrl:"scores/by-summoner/"+r.id,region:n},h))})}):this._logError(this.getTotalChampMasteryScore.name,"required params "+o.yellow("`id/summonerId/playerId` (int)")+", "+o.yellow("`accountId/accId` (int)")+", or "+o.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,n=t.accountId,s=t.accId,r=t.id,a=t.summonerId,u=t.playerId,d=t.name,g=arguments[1];return Number.isInteger(n||s)?new Promise(function(t,r){return e.getSummoner({accId:n||s,region:i},function(n,s){return n?void(g?g(n):r(n)):t(e._spectatorRequest({endUrl:"active-games/by-summoner/"+s.id,region:i},g))})}):Number.isInteger(r||a||u)?this._spectatorRequest({endUrl:"active-games/by-summoner/"+(r||a||u),region:i},g):"object"===c(arguments[0])&&"string"==typeof d?new Promise(function(t,n){return e.getSummoner({name:d,region:i},function(s,r){return s?void(g?g(s):n(s)):t(e._spectatorRequest({endUrl:"active-games/by-summoner/"+r.id,region:i},g))})}):this._logError(this.getCurrentGame.name,"required params "+o.yellow("`id/summonerId/playerId` (int)")+", "+o.yellow("`accountId/accId` (int)")+", or "+o.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"function"==typeof arguments[0]&&(i=arguments[0],arguments[0]=void 0),this._spectatorRequest({endUrl:"featured-games",region:t},i)}},{key:"getRecentGames",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=t.region,n=t.accountId,s=t.accId,r=t.id,a=t.summonerId,u=t.playerId,d=t.name,g=arguments[1];return Number.isInteger(n||s)?new Promise(function(t,r){return e.getSummoner({accId:n||s,region:i},function(n,s){return n?void(g?g(n):r(n)):t(e._gameRequest({endUrl:"by-summoner/"+s.id+"/recent",region:i},g))})}):Number.isInteger(r||a||u)?this._gameRequest({endUrl:"by-summoner/"+(r||a||u)+"/recent",region:i},g):"object"===c(arguments[0])&&"string"==typeof d?new Promise(function(t,n){return e.getSummoner({name:d,region:i},function(s,r){return s?void(g?g(s):n(s)):t(e._gameRequest({endUrl:"by-summoner/"+r.id+"/recent",region:i},g))})}):this._logError(this.getRecentGames.name,"required params "+o.yellow("`id/summonerId/playerId` (int)")+", "+o.yellow("`accountId/accId` (int)")+", or "+o.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,n=t.accountId,s=t.accId,r=t.id,a=t.summonerId,u=t.playerId,d=t.name,g=t.options,l=arguments[1];return Number.isInteger(n||s)?new Promise(function(t,r){return e.getSummoner({accId:n||s,region:i},function(n,s){return n?void(l?l(n):r(n)):t(e._leagueRequest({endUrl:"leagues/by-summoner/"+s.id,region:i,options:g},l))})}):Number.isInteger(r||a||u)?this._leagueRequest({endUrl:"leagues/by-summoner/"+(r||a||u),region:i,options:g},l):"object"===c(arguments[0])&&"string"==typeof d?new Promise(function(t,n){return e.getSummoner({name:d,region:i},function(s,r){return s?void(l?l(s):n(s)):t(e._leagueRequest({endUrl:"leagues/by-summoner/"+r.id,region:i,options:g},l))})}):this._logError(this.getLeagues.name,"required params "+o.yellow("`id/summonerId/playerId` (int)")+", "+o.yellow("`accountId/accId` (int)")+", or "+o.yellow("`name` (string)")+" not passed in")}},{key:"getLeaguePositions",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=t.region,n=t.accountId,s=t.accId,r=t.id,a=t.summonerId,u=t.playerId,d=t.name,g=arguments[1];return Number.isInteger(n||s)?new Promise(function(t,r){return e.getSummoner({accId:n||s,region:i},function(n,s){return n?void(g?g(n):r(n)):t(e._leagueRequest({endUrl:"positions/by-summoner/"+s.id,region:i},g))})}):Number.isInteger(r||a||u)?this._leagueRequest({endUrl:"positions/by-summoner/"+(r||a||u),region:i},g):"object"===c(arguments[0])&&"string"==typeof d?new Promise(function(t,n){return e.getSummoner({name:d,region:i},function(s,r){return s?void(g?g(s):n(s)):t(e._leagueRequest({endUrl:"positions/by-summoner/"+r.id,region:i},g))})}):void this._logError(this.getLeaguePositions.name,"required params "+o.yellow("`id/summonerId/playerId` (int)")+", "+o.yellow("`accountId/accId` (int)")+", or "+o.yellow("`name` (string)")+" not passed in")}},{key:"getChallengers",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.queue,n=void 0===i?"RANKED_SOLO_5x5":i,s=arguments[1];if(s="function"==typeof arguments[0]?arguments[0]:arguments[1],"string"==typeof n)return this._leagueRequest({endUrl:"challengerleagues/by-queue/"+n,region:t},s);this._logError(this.getChallengers.name,"required params "+o.yellow("`queue` (string)")+" not passed in")}},{key:"getMasters",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.queue,n=void 0===i?"RANKED_SOLO_5x5":i,s=arguments[1];if(s="function"==typeof arguments[0]?arguments[0]:arguments[1],"string"==typeof n)return this._leagueRequest({endUrl:"masterleagues/by-queue/"+n,region:t},s);this._logError(this.getMasters.name,"required params "+o.yellow("`queue` (string)")+" not passed in")}},{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"function"==typeof arguments[0]&&(n=arguments[0],arguments[0]=void 0),this._staticRequest({endUrl:"champions",region:t,options:i},n)}},{key:"getChampion",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.id,n=e.championId,s=e.options,r=arguments[1];return Number.isInteger(i||n)?this._staticRequest({endUrl:"champions/"+(i||n),region:t,options:s},r):this._logError(this.getChampion.name,"required params "+o.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"function"==typeof arguments[0]&&(n=arguments[0],arguments[0]=void 0),this._staticRequest({endUrl:"items",region:t,options:i},n)}},{key:"getItem",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.id,n=e.itemId,s=e.options,r=arguments[1];return Number.isInteger(i||n)?this._staticRequest({endUrl:"items/"+(i||n),region:t,options:s},r):this._logError(this.getItem.name,"required params "+o.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"function"==typeof arguments[0]&&(n=arguments[0],arguments[0]=void 0),this._staticRequest({endUrl:"language-strings",region:t,options:i},n)}},{key:"getLanguages",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=arguments[1];return"function"==typeof arguments[0]&&(i=arguments[0],arguments[0]=void 0),this._staticRequest({endUrl:"languages",region:t},i)}},{key:"getMapData",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.options,n=arguments[1];return"function"==typeof arguments[0]&&(n=arguments[0],arguments[0]=void 0),this._staticRequest({endUrl:"maps",region:t,options:i},n)}},{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"function"==typeof arguments[0]&&(n=arguments[0],arguments[0]=void 0),this._staticRequest({endUrl:"masteries",region:t,options:i},n)}},{key:"getMastery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.id,n=e.masteryId,s=e.options,r=arguments[1];return Number.isInteger(i||n)?this._staticRequest({endUrl:"masteries/"+(i||n),region:t,options:s},r):this._logError(this.getMastery.name,"required params "+o.yellow("`id/masteryId` (int)")+" not passed in")}},{key:"getProfileIcons",value:function(e,t){var i=e.region,n=e.options | ||
;return"function"==typeof arguments[0]&&(t=arguments[0],arguments[0]=void 0),this._staticRequest({endUrl:"profile-icons",region:i,options:n},t)}},{key:"getRealmData",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=arguments[1];return"function"==typeof arguments[0]&&(i=arguments[0],arguments[0]=void 0),this._staticRequest({endUrl:"realms",region:t},i)}},{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"function"==typeof arguments[0]&&(n=arguments[0],arguments[0]=void 0),this._staticRequest({endUrl:"runes",region:t,options:i},n)}},{key:"getRune",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.id,n=e.runeId,s=e.options,r=arguments[1];return Number.isInteger(i||n)?this._staticRequest({endUrl:"runes/"+(i||n),region:t,options:s},r):this._logError(this.getRune.name,"required params "+o.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"function"==typeof arguments[0]&&(n=arguments[0],arguments[0]=void 0),this._staticRequest({endUrl:"summoner-spells",region:t,options:i},n)}},{key:"getSummonerSpell",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.id,n=e.spellId,s=e.summonerSpellId,r=e.options,a=arguments[1];return Number.isInteger(i||n||s)?this._staticRequest({endUrl:"summoner-spells/"+(i||n||s),region:t,options:r},a):this._logError(this.getSummonerSpell.name,"required params "+o.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"function"==typeof arguments[0]&&(n=arguments[0],arguments[0]=void 0),this._staticRequest({endUrl:"versions",region:t,options:i},n)}},{key:"getShardStatus",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=arguments[1];return"function"==typeof arguments[0]&&(i=arguments[0],arguments[0]=void 0),this._statusRequest({endUrl:"shard-data",region:t},i)}},{key:"getMatch",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.id,n=e.matchId,s=e.options,r=arguments[1];return Number.isInteger(i||n)?this._matchRequest({endUrl:"matches/"+(i||n),region:t,options:s},r):this._logError(this.getMatch.name,"required params "+o.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,n=t.accountId,s=t.accId,r=t.id,a=t.summonerId,u=t.playerId,d=t.name,g=t.options,l=void 0===g?{queue:S.TEAM_BUILDER_RANKED_SOLO}:g,h=arguments[1];return Number.isInteger(n||s)?this._matchRequest({endUrl:"matchlists/by-account/"+(n||s),region:i,options:l},h):Number.isInteger(r||a||u)?new Promise(function(t,n){return e.getSummoner({id:r,region:i},function(s,r){return s?void(h?h(s):n(s)):t(e._matchRequest({endUrl:"matchlists/by-account/"+r.accountId,region:i,options:l},h))})}):"object"===c(arguments[0])&&"string"==typeof d?new Promise(function(t,n){return e.getSummoner({name:d,region:i},function(s,r){return s?void(h?h(s):n(s)):t(e._matchRequest({endUrl:"matchlists/by-account/"+r.accountId,region:i,options:l},h))})}):this._logError(this.getMatchlist.name,"required params "+o.yellow("`accountId/accId` (int)")+", "+o.yellow("`id/summonerId/playerId` (int)")+", or "+o.yellow("`name` (str)")+" not passed in")}},{key:"getRecentMatchlist",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=t.region,n=t.accountId,s=t.accId,r=t.id,a=t.summonerId,u=t.playerId,d=t.name,g=arguments[1];return Number.isInteger(n||s)?this._matchRequest({endUrl:"matchlists/by-account/"+(n||s)+"/recent",region:i},g):Number.isInteger(r||a||u)?new Promise(function(t,n){return e.getSummoner({id:r,region:i},function(s,r){return s?void(g?g(s):n(s)):t(e._matchRequest({endUrl:"matchlists/by-account/"+r.accountId+"/recent",region:i},g))})}):"object"===c(arguments[0])&&"string"==typeof d?new Promise(function(t,n){return e.getSummoner({name:d,region:i},function(s,r){return s?void(g?g(s):n(s)):t(e._matchRequest({endUrl:"matchlists/by-account/"+r.accountId+"/recent",region:i},g))})}):this._logError(this.getRecentMatchlist.name,"required params "+o.yellow("`accountId/accId` (int)")+", "+o.yellow("`id/summonerId/playerId` (int)")+", or "+o.yellow("`name` (str)")+" not passed in")}},{key:"getMatchTimeline",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.id,n=e.matchId,s=arguments[1];return Number.isInteger(i||n)?this._matchRequest({endUrl:"timelines/by-match/"+(i||n),region:t},s):this._logError(this.getMatchTimeline.name,"required params "+o.yellow("`id/matchId` (int)")+" not passed in")}},{key:"getRunes",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=t.region,n=t.accountId,s=t.accId,r=t.id,a=t.summonerId,u=t.playerId,d=t.name,g=arguments[1];return Number.isInteger(n||s)?new Promise(function(t,r){return e.getSummoner({accId:n||s,region:i},function(n,s){return n?void(g?g(n):r(n)):t(e._runesMasteriesRequest({endUrl:"runes/by-summoner/"+s.id,region:i},g))})}):Number.isInteger(r||a||u)?this._runesMasteriesRequest({endUrl:"runes/by-summoner/"+(r||a||u),region:i},g):"object"===c(arguments[0])&&"string"==typeof d?new Promise(function(t,n){return e.getSummoner({name:d,region:i},function(s,r){return s?void(g?g(s):n(s)):t(e._runesMasteriesRequest({endUrl:"runes/by-summoner/"+r.id,region:i},g))})}):this._logError(this.getRunes.name,"required params "+o.yellow("`id/summonerId/playerId` (int)")+", "+o.yellow("`accountId/accId` (int)")+", or "+o.yellow("`name` (str)")+" not passed in")}},{key:"getMasteries",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=t.region,n=t.accountId,s=t.accId,r=t.id,a=t.summonerId,u=t.playerId,d=t.name,g=arguments[1];return Number.isInteger(n||s)?new Promise(function(t,r){return e.getSummoner({accId:n||s,region:i},function(n,s){return n?void(g?g(n):r(n)):t(e._runesMasteriesRequest({endUrl:"masteries/by-summoner/"+s.id,region:i},g))})}):Number.isInteger(r||a||u)?this._runesMasteriesRequest({endUrl:"masteries/by-summoner/"+(r||a||u),region:i},g):"object"===c(arguments[0])&&"string"==typeof d?new Promise(function(t,n){return e.getSummoner({name:d,region:i},function(s,r){return s?void(g?g(s):n(s)):t(e._runesMasteriesRequest({endUrl:"masteries/by-summoner/"+r.id,region:i},g))})}):this._logError(this.getMasteries.name,"required params "+o.yellow("`id/summonerId/playerId` (int)")+", "+o.yellow("`accountId/accId` (int)")+", or "+o.yellow("`name` (str)")+" not passed in")}},{key:"getRankedStats",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=t.region,n=t.accountId,s=t.accId,r=t.id,a=t.summonerId,u=t.playerId,d=t.name,g=t.options,l=arguments[1];return Number.isInteger(n||s)?new Promise(function(t,r){return e.getSummoner({accId:n||s,region:i},function(n,s){return n?void(l?l(n):r(n)):t(e._statsRequest({endUrl:s.id+"/ranked",region:i,options:g},l))})}):Number.isInteger(r||a||u)?this._statsRequest({endUrl:(r||a||u)+"/ranked",region:i,options:g},l):"object"===c(arguments[0])&&"string"==typeof d?new Promise(function(t,n){return e.getSummoner({name:d,region:i},function(s,r){return s?void(l?l(s):n(s)):t(e._statsRequest({endUrl:r.id+"/ranked",region:i,options:g},l))})}):void this._logError(this.getRankedStats.name,"required params "+o.yellow("`id/summonerId/playerId` (int)")+", "+o.yellow("`accountId/accId` (int)")+", or "+o.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,n=t.accountId,s=t.accId,r=t.id,a=t.summonerId,u=t.playerId,d=t.name,g=t.options,l=arguments[1];return Number.isInteger(n||s)?new Promise(function(t,r){return e.getSummoner({accId:n||s,region:i},function(n,s){return n?void(l?l(n):r(n)):t(e._statsRequest({endUrl:s.id+"/summary",region:i,options:g},l))})}):Number.isInteger(r||a||u)?this._statsRequest({endUrl:(r||a||u)+"/summary",region:i,options:g},l):"object"===c(arguments[0])&&"string"==typeof d?new Promise(function(t,n){return e.getSummoner({name:d,region:i},function(s,r){return s?void(l?l(s):n(s)):t(e._statsRequest({endUrl:r.id+"/summary",region:i,options:g},l))})}):void this._logError(this.getStatsSummary.name,"required params "+o.yellow("`id/summonerId/playerId` (int)")+", "+o.yellow("`accountId/accId` (int)")+", or "+o.yellow("`name` (string)")+" not passed in")}},{key:"getSummoner",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.id,n=e.summonerId,s=e.playerId,r=e.accountId,a=e.accId,u=e.name,d=arguments[1];return Number.isInteger(i||n||s)?this._summonerRequest({endUrl:""+(i||n||s),region:t},d):"object"===c(arguments[0])&&"string"==typeof u?this._summonerRequest({endUrl:"by-name/"+this._sanitizeName(u),region:t},d):Number.isInteger(r||a)?this._summonerRequest({endUrl:"by-account/"+(r||a),region:t},d):this._logError(this.getSummoner.name,"required params "+o.yellow("`id/summonerId/playerId` (int)")+", "+o.yellow("`accountId/accId` (int)")+", or "+o.yellow("`name` (string)")+" not passed in")}},{key:"getDTOByCode",value:function(e,t){return"string"==typeof e?this._tournamentRequest({endUrl:"lobby-events/codes/"+e},t):this._logError(this.getDTOByCode.name,"required params "+o.yellow("`code` (string)")+" not passed in")}},{key:"getLobbyListEventsByCode",value:function(e,t){return"string"==typeof e?this._tournamentRequest({endUrl:"lobby-events/by-code/"+e},t):this._logError(this.getLobbyListEventsByCode.name,"required params "+o.yellow("`code` (string)")+" not passed in")}},{key:"listChampions",value:function(e,t,i){return"function"==typeof e&&(i=e,e=void 0),"function"==typeof t&&(i=t,t=void 0),"string"==typeof e&&(t=e,e=void 0),this.Champion.all({options:e,region:t},i)}},{key:"getChampionById",value:function(e,t,i){return"function"==typeof t&&(i=t,t=void 0),this.Champion.get({id:e,region:t},i)}},{key:"listFeaturedGames",value:function(e,t){return"function"==typeof e&&(t=e,e=void 0),this.FeaturedGames.get({region:e},t)}},{key:"listChallengers",value:function(e,t,i){return"function"==typeof e&&(i=e,e=void 0),"function"==typeof t&&(i=t,t=void 0),this.League.challengers({queue:e,region:t},i)}},{key:"listMasters",value:function(e,t,i){return"function"==typeof e&&(i=e,e=void 0),"function"==typeof t&&(i=t,t=void 0),this.League.masters({queue:e,region:t},i)}},{key:"getSummonerByAccountId",value:function(e,t,i){return"function"==typeof t&&(i=t,t=void 0),this.Summoner.get({region:t,accId:e},i)}},{key:"getSummonerById",value:function(e,t,i){return"function"==typeof t&&(i=t,t=void 0),this.Summoner.get({region:t,id:e},i)}},{key:"getSummonerByName",value:function(e,t,i){return"function"==typeof t&&(i=t,t=void 0),this.Summoner.get({region:t,name:e},i)}},{key:"getMasteriesByAccountId",value:function(e,t,i){return"function"==typeof t&&(i=t,t=void 0),this.Masteries.get({region:t,accId:e},i)}},{key:"getMasteriesById",value:function(e,t,i){return"function"==typeof t&&(i=t,t=void 0),this.Masteries.get({region:t,id:e},i)}},{key:"getMasteriesByName",value:function(e,t,i){return"function"==typeof t&&(i=t,t=void 0),this.Masteries.get({region:t,name:e},i)}},{key:"getMatchById",value:function(e,t,i){return"function"==typeof t&&(i=t,t=void 0),this.Match.get({region:t,id:e},i)}},{key:"getMatchlistByAccountId",value:function(e,t,i,n){return"function"==typeof t&&(n=t,t=void 0),"function"==typeof i&&(n=i,i=void 0),"string"==typeof t&&(i=t,t=void 0),this.Matchlist.get({region:i,accId:e},n)}},{key:"getMatchlistById",value:function(e,t,i,n){return"function"==typeof t&&(n=t,t=void 0),"function"==typeof i&&(n=i,i=void 0),"string"==typeof t&&(i=t,t=void 0),this.Matchlist.get({region:i,id:e},n)}},{key:"getMatchlistByName",value:function(e,t,i,n){return"function"==typeof t&&(n=t,t=void 0),"function"==typeof i&&(n=i,i=void 0),"string"==typeof t&&(i=t,t=void 0),this.Matchlist.get({name:e,options:t,region:i},n)}},{key:"getRunesByAccountId",value:function(e,t,i){return"function"==typeof t&&(i=t,t=void 0),this.Runes.get({region:t,accId:e},i)}},{key:"getRunesById",value:function(e,t,i){return"function"==typeof t&&(i=t,t=void 0),this.Runes.get({region:t,id:e},i)}},{key:"getRunesByName",value:function(e,t,i){return"function"==typeof t&&(i=t,t=void 0),this.Runes.get({region:t,name:e},i)}},{key:"getStaticChampionList",value:function(e,t,i){return"function"==typeof e&&(i=e,e=void 0),"function"==typeof t&&(i=t,t=void 0),"string"==typeof e&&(t=e,e=void 0),this.Static.champions({region:t,options:e},i)}},{key:"getStaticChampionById",value:function(e,t,i,n){return"function"==typeof t&&(n=t,t=void 0),"function"==typeof i&&(n=i,i=void 0),"string"==typeof t&&(i=t,t=void 0),this.Static.champion({id:e,options:t,region:i},n)}},{key:"getStaticItemList",value:function(e,t,i){return"function"==typeof e&&(i=e,e=void 0),"function"==typeof t&&(i=t,t=void 0),"string"==typeof e&&(t=e,e=void 0),this.Static.items({options:e,region:t},i)}},{key:"getStaticItemById",value:function(e,t,i,n){return"function"==typeof t&&(n=t,t=void 0),"function"==typeof i&&(n=i,i=void 0),"string"==typeof t&&(i=t,t=void 0),this.Static.item({id:e,options:t,region:i},n)}},{key:"getStaticLanguageStringList",value:function(e,t,i){return"function"==typeof e&&(i=e,e=void 0),"function"==typeof t&&(i=t,t=void 0),"string"==typeof e&&(t=e,e=void 0),this.Static.languageStrings({options:e,region:t},i)}},{key:"getStaticLanguageList",value:function(e,t){return"function"==typeof e&&(t=e,e=void 0),this.Static.languages({region:e},t)}},{key:"getStaticMapList",value:function(e,t,i){return"function"==typeof e&&(i=e,e=void 0),"function"==typeof t&&(i=t,t=void 0),"string"==typeof e&&(t=e,e=void 0),this.Static.mapData({options:e,region:t},i)}},{key:"getStaticMasteryList",value:function(e,t,i){return"function"==typeof e&&(i=e,e=void 0),"function"==typeof t&&(i=t,t=void 0),"string"==typeof e&&(t=e,e=void 0),this.Static.masteries({options:e,region:t},i)}},{key:"getStaticMasteryById",value:function(e,t,i,n){return"function"==typeof t&&(n=t,t=void 0),"function"==typeof i&&(n=i,i=void 0),"string"==typeof t&&(i=t,t=void 0),this.Static.mastery({id:e,options:t,region:i},n)}},{key:"getStaticProfileIconList",value:function(e,t,i){return"function"==typeof e&&(i=e,e=void 0),"function"==typeof t&&(i=t,t=void 0),"string"==typeof e&&(t=e,e=void 0),this.Static.profileIcons({options:e,region:t},i)}},{key:"getStaticRealmList",value:function(e,t){return"function"==typeof e&&(t=e,e=void 0),this.Static.realm({region:e},t)}},{key:"getStaticRuneList",value:function(e,t,i){return"function"==typeof e&&(i=e,e=void 0),"function"==typeof t&&(i=t,t=void 0),"string"==typeof e&&(t=e,e=void 0),this.Static.runes({options:e,region:t},i)}},{key:"getStaticRuneById",value:function(e,t,i,n){return"function"==typeof t&&(n=t,t=void 0),"function"==typeof i&&(n=i,i=void 0),"string"==typeof t&&(i=t,t=void 0),this.Static.rune({id:e,options:t,region:i},n)}},{key:"getStaticSummonerSpellList",value:function(e,t,i){return"function"==typeof e&&(i=e,e=void 0),"function"==typeof t&&(i=t,t=void 0),"string"==typeof e&&(t=e,e=void 0),this.Static.spells({options:e,region:t},i)}},{key:"getStaticSummonerSpellById",value:function(e,t,i,n){return"function"==typeof t&&(n=t,t=void 0),"function"==typeof i&&(n=i,i=void 0),"string"==typeof t&&(i=t,t=void 0),this.Static.spell({id:e,options:t,region:i},n)}},{key:"getStaticVersionList",value:function(e,t){return"function"==typeof e&&(t=e,e=void 0),this.Static.versions({region:e},t)}},{key:"getSummonerByAccId",value:function(e,t,i){return this.Summoner.get({region:t,accId:e},i)}},{key:"getRunesBySummonerId",value:function(e,t,i){return this.Runes.get({region:t,id:e},i)}},{key:"staticRuneList",value:function(e,t,i){return this.Static.runes({region:e,options:t},i)}}]),e}(),B={Kindred:P,REGIONS:b,LIMITS:R,TIME_CONSTANTS:f,CACHE_TYPES:M,QUEUE_TYPES:S,QuickStart:d,print:g};e.exports=B}); |
{ | ||
"name": "kindred-api", | ||
"version": "2.0.32", | ||
"version": "2.0.33", | ||
"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,2 +21,3 @@ # Kindred | ||
* [Quickstart](#quickstart) | ||
* [Known Issues](#known-issues) | ||
@@ -27,3 +28,3 @@ # Core Features | ||
* Rate limiter that is **enforced per region** and **follows retry headers**. | ||
* Retries on 429 and >= 500. | ||
* Retries on 429 and >= 500. (Doesn't retry on 404) | ||
* Built-in **parameter checks** so you can hopefully refer to documentation less! :) | ||
@@ -231,2 +232,49 @@ * Built-in **caching** (in-memory and Redis). | ||
.catch(error => console.error(err)) | ||
``` | ||
``` | ||
# Known Issues | ||
## Rate Limiter is not as optimized as it should be. | ||
## Promises retry on 404. | ||
This is problematic because certain calls such as getCurrentGame, which will hit 404's often, will always retry up to 3 times. | ||
This means it'll send a request, get a 404, and then send three more requests for a total of 3 unnecessary requests. | ||
```javascript | ||
k.CurrentGame.get({ name: 'Contractz' }) | ||
/* | ||
200 https://na1.api.riotgames.com/lol/summoner/v3/summoners/by-name/contractz?api_key= | ||
{ 'x-app-rate-limit-count': '1:10,1:600', | ||
'x-method-rate-limit-count': '1:10,2:600', | ||
'x-rate-limit-count': '1:10,1:600', | ||
'retry-after': undefined } | ||
404 Not Found https://na1.api.riotgames.com/lol/spectator/v3/active-games/by-summoner/32932398?api_key= | ||
{ 'x-app-rate-limit-count': '2:10,2:600', | ||
'x-method-rate-limit-count': '1:10,5:600', | ||
'x-rate-limit-count': '2:10,2:600', | ||
'retry-after': undefined } | ||
404 Not Found https://na1.api.riotgames.com/lol/spectator/v3/active-games/by-summoner/32932398?api_key= | ||
{ 'x-app-rate-limit-count': '3:10,3:600', | ||
'x-method-rate-limit-count': '2:10,6:600', | ||
'x-rate-limit-count': '3:10,3:600', | ||
'retry-after': undefined } | ||
404 Not Found https://na1.api.riotgames.com/lol/spectator/v3/active-games/by-summoner/32932398?api_key= | ||
{ 'x-app-rate-limit-count': '4:10,4:600', | ||
'x-method-rate-limit-count': '3:10,7:600', | ||
'x-rate-limit-count': '4:10,4:600', | ||
'retry-after': undefined } | ||
404 Not Found https://na1.api.riotgames.com/lol/spectator/v3/active-games/by-summoner/32932398?api_key= | ||
{ 'x-app-rate-limit-count': '5:10,5:600', | ||
'x-method-rate-limit-count': '4:10,8:600', | ||
'x-rate-limit-count': '5:10,5:600', | ||
'retry-after': undefined } | ||
*/ | ||
``` | ||
@@ -13,3 +13,3 @@ const Deque = require('double-ended-queue') | ||
while (this.madeRequests.length > 0 && (t - this.madeRequests.peekFront() >= (this.seconds*1000))) { | ||
while (this.madeRequests.length > 0 && (t - this.madeRequests.peekFront() >= (this.seconds*100))) { | ||
this.madeRequests.shift() | ||
@@ -16,0 +16,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
393974
278