kindred-api
Advanced tools
Comparing version 2.0.6 to 2.0.8
@@ -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,r,s,o,a){"use strict";function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function l(e,t,i){return new w({key:e,defaultRegion:t,debug:i,limits:S.DEV,cacheOptions:_[0]})}function g(e,t){e?console.log(e):console.log(t)}var h="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},m=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}}(),d=function(){function e(){u(this,e),this.cache={}}return m(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}(),c=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 m(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,i){this.client.setex(this.prefix+e.key,e.ttl,i,t.print),console.log("set for "+e.ttl+" seconds")}}]),e}(),p=function(){function e(t,n){u(this,e),this.allowedRequests=t,this.seconds=n,this.madeRequests=new i}return m(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}(),y={CHAMPION:"platform",CHAMPION_MASTERY:"champion-mastery",GAME:null,LEAGUE:null,STATUS:"status",MASTERIES:"platform",MATCH:null,MATCH_LIST:null,RUNES:"platform",RUNES_MASTERIES:"platform",SPECTATOR:"spectator",STATIC_DATA:"static-data",STATS:null,SUMMONER:"summoner"},R={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:R.MONTH,CHAMPION_MASTERY:R.SIX_HOURS,CURRENT_GAME:R.NONE,FEATURED_GAMES:R.NONE,GAME:R.HOUR,LEAGUE:R.SIX_HOURS,STATIC:R.MONTH,STATUS:R.NONE,MATCH:R.MONTH,MATCH_LIST:R.ONE_HOUR,RUNES_MASTERIES:R.WEEK,SPECTATOR:R.NONE,STATS:R.HOUR,SUMMONER:R.DAY},S={DEV:[[10,10],[500,600]],PROD:[[3e3,10],[18e4,600]]},f={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"},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"},E={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"},I={CHAMPION:3,CHAMPION_MASTERY:3,CURRENT_GAME:1,FEATURED_GAMES:1,GAME:1.3,LEAGUE:2.5,STATIC_DATA:3,STATUS:3,MATCH:2.2,MATCH_LIST:2.2,RUNES_MASTERIES:3,SPECTATOR:3,STATS:1.3,SUMMONER:3},_=["in-memory-cache","redis"],A=n("^[0-9\\p{L} _\\.]+$"),M={int:function(e){return e.every(function(e){return Number.isInteger(e)})},string:function(e){return e.every(function(e){return"string"==typeof e})}},T={int:function(e){return e&&Array.isArray(e)&&M.int(e)&&e.length>0},string:function(e){return e&&Array.isArray(e)&&M.string(e)&&e.length>0}},C=function(e){var t=!0,i=!1,n=void 0;try{for(var r,s=Object.keys(b)[Symbol.iterator]();!(t=(r=s.next()).done);t=!0){var o=r.value;if(b[o]===e)return!0}}catch(e){i=!0,n=e}finally{try{!t&&s.return&&s.return()}finally{if(i)throw n}}return!1},U={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=U[e];if(t)return t},D=[200,400,500],N=function(e){return e>=D[0]&&e<D[1]?r.green(e):e>=D[1]&&e<D[2]?r.red(e+" "+q(e)):r.bold.red(e+" "+q(e))},k=function(e){return(Array.isArray(e)&&2!==e.length||!T.int(e[0])||2!==e[0].length||!T.int(e[1])||2!==e[1].length)&&"dev"!==e&&"prod"!==e},O=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()},w=function(){function e(t){var i=t.key,n=t.defaultRegion,r=void 0===n?b.NORTH_AMERICA:n,s=t.debug,a=void 0!==s&&s,l=t.limits,g=t.cacheOptions,h=t.cacheTTL;if(u(this,e),this.key=i,this.defaultRegion=C(r)?r:void 0,this.defaultRegion||(console.log(""+o.red("Initialization of Kindred failed: "+o.yellow(r)+" 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===_[0]?this.cache=new d:g===_[1]?this.cache=new c:this.cache=g,this.CACHE_TIMERS=h?h: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}),l){k(l)&&(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"===l&&(l=S.DEV),"prod"===l&&(l=S.PROD);var m=!0,y=!1,R=void 0;try{for(var f,E=Object.keys(b)[Symbol.iterator]();!(m=(f=E.next()).done);m=!0){var I=f.value;this.limits[b[I]]=[new p(l[0][0],l[0][1]),new p(l[1][0],l[1][1])]}}catch(e){y=!0,R=e}finally{try{!m&&E.return&&E.return()}finally{if(y)throw R}}}this.Champion={getChampions:this.getChamps.bind(this),getAll:this.getChamps.bind(this),all:this.getChamps.bind(this),getChampion:this.getChamp.bind(this),get:this.getChamp.bind(this)},this.ChampionMastery={getChampionMastery:this.getChampMastery.bind(this),get:this.getChampMastery.bind(this),getChampionMasteries:this.getChampMasteries.bind(this),getAll:this.getChampMasteries.bind(this),all:this.getChampMasteries.bind(this),getTotalChampionMasteryScore:this.getTotalChampMasteryScore.bind(this),getTotalScore:this.getTotalChampMasteryScore.bind(this),totalScore:this.getTotalChampMasteryScore.bind(this),total:this.getTotalChampMasteryScore.bind(this),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)},this.Game={getRecentGames:this.getRecentGames.bind(this),getRecent:this.getRecentGames.bind(this),get:this.getRecentGames.bind(this)},this.League={getLeagues:this.getLeagues.bind(this),get:this.getLeagues.bind(this),getLeagueEntries:this.getLeagueEntries.bind(this),getEntries:this.getLeagueEntries.bind(this),entries:this.getLeagueEntries.bind(this),getChallengers:this.getChallengers.bind(this),challengers:this.getChallengers.bind(this),getMasters:this.getMasters.bind(this),masters:this.getMasters.bind(this)},this.Static={getChampions:this.getChampionList.bind(this),champions:this.getChampionList.bind(this),getChampion:this.getChampion.bind(this),champion:this.getChampion.bind(this),getItems:this.getItems.bind(this),items:this.getItems.bind(this),getItem:this.getItem.bind(this),item:this.getItem.bind(this),getLanguageStrings:this.getLanguageStrings.bind(this),languageStrings:this.getLanguageStrings.bind(this),getLanguages:this.getLanguages.bind(this),languages:this.getLanguages.bind(this),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),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)},this.MatchList={getMatchList:this.getMatchList.bind(this),get:this.getMatchList.bind(this)},this.RunesMasteries={getRunes:this.getRunes.bind(this),runes:this.getRunes.bind(this),getMasteries:this.getMasteries.bind(this),masteries:this.getMasteries.bind(this)},this.Runes={get:this.getRunes.bind(this)},this.Masteries={get:this.getMasteries.bind(this)},this.Stats={getRankedStats:this.getRankedStats.bind(this),ranked:this.getRankedStats.bind(this),getStatsSummary:this.getStatsSummary.bind(this),summary:this.getStatsSummary.bind(this)},this.Summoner={getSummoner:this.getSummoner.bind(this),get:this.getSummoner.bind(this)}}return m(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,r,s){var o=i?"":t+"/",a=n||r||s?"":"api/lol/"+o,u="https://"+t+".api.riotgames.com/"+a+encodeURI(e),l="https://"+f[E[t]].toLowerCase()+".api.riotgames.com/lol/"+encodeURI(e);return l.lastIndexOf("v3")==-1?u:l}},{key:"_baseRequest",value:function(e,t){var i=this,n=e.endUrl,r=e.region,u=void 0===r?this.defaultRegion:r,l=e.status,g=void 0!==l&&l,h=e.observerMode,m=void 0!==h&&h,d=e.staticReq,c=void 0!==d&&d,p=e.championMastery,y=void 0!==p&&p,R=e.options,v=void 0===R?{}:R,S=e.cacheParams,f=void 0===S?{}:S,b=function(){return new Promise(function(e,r){var l=!0,h=!1,d=void 0;try{for(var p,R=Object.keys(v)[Symbol.iterator]();!(l=(p=R.next()).done);l=!0){var S=p.value;Array.isArray(v[S])&&(v[S]=v[S].join(","))}}catch(e){h=!0,d=e}finally{try{!l&&R.return&&R.return()}finally{if(h)throw d}}var b=a.stringify(v).replace(/%2C/,","),E=b?"?"+b:"",I=i._makeUrl(n+E,u,c,g,m,y),_=I+(I.lastIndexOf("?")===-1?"?":"&")+"api_key="+i.key;i.cache.get({key:I},function(n,a){if(a){var l=JSON.parse(a);return t?t(n,l):e(l)}if(i.limits){var g=i;!function t(i){g.canMakeRequest(u)?(c||(g.limits[u][0].addRequest(),g.limits[u][1].addRequest()),s({url:_},function(n,s,a){if(s&&a){var u=s.statusCode,l=N(u);if(g.debug&&O(s,l,_),"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*s.headers["retry-after"]+50)),u>=400?i(l+" : "+o.yellow(I)):(Number.isInteger(f.ttl)&&f.ttl>0&&g.cache.set({key:I,ttl:f.ttl},a),i(n,JSON.parse(a)));if(500===u)g.debug&&console.log("!!! resending promise request !!!"),setTimeout(function(){return r("retry")},1e3);else{if(429!==u)return n||u>=400?r("err:",n,u):(Number.isInteger(f.ttl)&&f.ttl>0&&g.cache.set({key:I,ttl:f.ttl},a),e(JSON.parse(a)));g.debug&&console.log("!!! resending promise request !!!"),setTimeout(function(){return r("retry")},1e3*s.headers["retry-after"]+50)}}else console.log(n,_)})):setTimeout(function(){t.bind(g)(i)},1e3)}(t)}else s({url:_},function(i,n,s){if(n){var a=n.statusCode,u=N(a);return g.debug&&O(n,u,_),"function"==typeof t?a>=400?t(u+" : "+o.yellow(I)):t(i,JSON.parse(s)):i?r("err:",i):e(JSON.parse(s))}console.log(i,I)})})})};return t?b():b().catch(b).catch(b).catch(b).then(function(e){return e})}},{key:"_championMasteryRequest",value:function(e,t){var i=e.endUrl,n=e.region,r=e.options;return this._baseRequest({endUrl:y.CHAMPION_MASTERY+"/v"+I.CHAMPION+"/"+i,region:n,options:r,championMastery:!0,cacheParams:{ttl:this.CACHE_TIMERS.CHAMPION_MASTERY}},t)}},{key:"_championRequest",value:function(e,t){var i=e.endUrl,n=e.region,r=e.options;return this._baseRequest({endUrl:y.CHAMPION+"/v"+I.CHAMPION+"/"+i,region:n,options:r,cacheParams:{ttl:this.CACHE_TIMERS.CHAMPION}},t)}},{key:"_spectatorRequest",value:function(e,t){var i=e.endUrl,n=e.region;return this._baseRequest({endUrl:y.SPECTATOR+"/v"+I.SPECTATOR+"/"+i,region:n,cacheParams:{ttl:this.CACHE_TIMERS.SPECTATOR}},t)}},{key:"_staticRequest",value:function(e,t){var i=e.endUrl,n=e.region,r=void 0===n?this.defaultRegion:n,s=e.options;return this._baseRequest({endUrl:y.STATIC_DATA+"/v"+I.STATIC_DATA+"/"+i,staticReq:!0,region:r,options:s,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:y.STATUS+"/v"+I.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"+I.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,r=e.options;return this._baseRequest({endUrl:"v"+I.LEAGUE+"/league/"+i,region:n,options:r,cacheParams:{ttl:this.CACHE_TIMERS.LEAGUE}},t)}},{key:"_matchRequest",value:function(e,t){var i=e.endUrl,n=e.region,r=e.options;return this._baseRequest({endUrl:"v"+I.MATCH+"/match/"+i,region:n,options:r,cacheParams:{ttl:this.CACHE_TIMERS.MATCH}},t)}},{key:"_matchListRequest",value:function(e,t){var i=e.endUrl,n=e.region,r=e.options;return this._baseRequest({endUrl:"v"+I.MATCH_LIST+"/matchlist/by-summoner/"+i,region:n,options:r,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:y.RUNES_MASTERIES+"/v"+I.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,r=e.options;return this._baseRequest({endUrl:"v"+I.STATS+"/stats/by-summoner/"+i,region:n,options:r,cacheParams:{ttl:this.CACHE_TIMERS.STATS}},t)}},{key:"_summonerRequest",value:function(e,t){var i=e.endUrl,n=e.region;return this._baseRequest({endUrl:y.SUMMONER+"/v"+I.SUMMONER+"/summoners/"+i,region:n,cacheParams:{ttl:this.CACHE_TIMERS.SUMMONER}},t)}},{key:"_logError",value:function(e,t){console.log(o.bold.yellow(e),o.red("request"),o.bold.red("FAILED")+o.red("; "+t))}},{key:"setRegion",value:function(e){this.defaultRegion=C(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 this._championRequest({endUrl:"champions",region:t,options:i},n=2===arguments.length?n:arguments[0])}},{key:"getChamp",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.id,n=e.championID,r=arguments[1];return Number.isInteger(i)||Number.isInteger(n)?this._championRequest({endUrl:"champions/"+(i||n),region:t},r):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,r=e.championID,s=e.options,a=arguments[1];return Number.isInteger(n)&&Number.isInteger(r)?this._championMasteryRequest({endUrl:"champion-masteries/by-summoner/"+n+"/by-champion/"+r,region:i,options:s},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,r=t.id,s=t.summonerID,a=t.playerID,u=t.name,l=t.options,g=arguments[1];return Number.isInteger(r||s||a)?this._championMasteryRequest({endUrl:"champion-masteries/by-summoner/"+(r||s||a),region:n,options:l},g):"object"===h(arguments[0])&&"string"==typeof u?new Promise(function(t,i){return e.getSummoner({name:u,region:n},function(r,s){return r?void(g?g(r):i(r)):t(e._championMasteryRequest({endUrl:"champion-masteries/by-summoner/"+s.id,region:n},g))})}):this._logError(this.getChampMasteries.name,"required params "+o.yellow("`id/summonerID/playerID` (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,r=t.id,s=t.summonerID,a=t.playerID,u=t.name,l=t.options,g=arguments[1];return Number.isInteger(r||s||a)?this._championMasteryRequest({endUrl:"scores/by-summoner/"+(r||s||a),region:n,options:l},g):"object"===h(arguments[0])&&"string"==typeof u?new Promise(function(t,i){return e.getSummoner({name:u,region:n},function(r,s){return r?void(g?g(r):i(r)):t(e._championMasteryRequest({endUrl:"scores/by-summoner/"+s.id,region:n},g))})}):this._logError(this.getTotalChampMasteryScore.name,"required params "+o.yellow("`id/summonerID/playerID` (int)")+" or "+o.yellow("`name` (str)")+" not passed in")}},{key:"getCurrentGame",value:function(){var e=this,t=arguments,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=i.region,r=void 0===n?this.defaultRegion:n,s=i.id,a=i.summonerID,u=i.playerID,l=i.name,g=arguments[1];return Number.isInteger(s||a||u)?this._spectatorRequest({endUrl:"active-games/by-summoner/"+(s||a||u),region:r},g=r?g:arguments[0]):"object"===h(arguments[0])&&"string"==typeof l?new Promise(function(i,n){return e.getSummoner({name:l,region:r},function(s,o){return s?void(g?g(s):n(s)):i(e._spectatorRequest({endUrl:"active-games/by-summoner/"+o.id,region:r},g=r?g:t[0]))})}):this._logError(this.getCurrentGame.name,"required params "+o.yellow("`id/summonerID/playerID` (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 this._spectatorRequest({endUrl:"featured-games",region:t},i=t?i:arguments[0])}},{key:"getRecentGames",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=t.region,n=t.id,r=t.summonerID,s=t.playerID,a=t.name,u=arguments[1];return Number.isInteger(n||r||s)?this._gameRequest({endUrl:"by-summoner/"+(n||r||s)+"/recent",region:i},u):"object"===h(arguments[0])&&"string"==typeof a?new Promise(function(t,n){return e.getSummoner({name:a,region:i},function(r,s){return r?void(u?u(r):n(r)):t(e._gameRequest({endUrl:"by-summoner/"+s.id+"/recent",region:i},u))})}):this._logError(this.getRecentGames.name,"required params "+o.yellow("`id/summonerID/playerID` (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.id,r=t.summonerID,s=t.playerID,a=t.name,u=t.options,l=arguments[1];return Number.isInteger(n||r||s)?this._leagueRequest({endUrl:"by-summoner/"+(n||r||s),region:i,options:u},l):"object"===h(arguments[0])&&"string"==typeof a?new Promise(function(t,n){return e.getSummoner({name:a,region:i},function(r,s){return r?void(l?l(r):n(r)):t(e._leagueRequest({endUrl:"by-summoner/"+s.id,region:i,options:u},l))})}):this._logError(this.getLeagues.name,"required params "+o.yellow("`id/summonerID/playerID` (int)")+" or "+o.yellow("`name` (str)")+" not passed in")}},{key:"getLeagueEntries",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=t.region,n=t.id,r=t.summonerID,s=t.playerID,a=t.name,u=arguments[1];return Number.isInteger(n||r||s)?this._leagueRequest({endUrl:"by-summoner/"+(n||r||s)+"/entry",region:i},u):"object"===h(arguments[0])&&"string"==typeof a?new Promise(function(t,n){return e.getSummoner({name:a,region:i},function(r,s){return r?void(u?u(r):n(r)):t(e._leagueRequest({endUrl:"by-summoner/"+s.id+"/entry",region:i},u))})}):void this._logError(this.getLeagueEntries.name,"required params "+o.yellow("`id/summonerID/playerID` (int)")+" or "+o.yellow("`name` (str)")+" not passed in")}},{key:"getChallengers",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.options,n=void 0===i?{type:"RANKED_SOLO_5x5"}:i,r=arguments[1];return this._leagueRequest({endUrl:"challenger",region:t,options:n},r=2===arguments.length?r:arguments[0])}},{key:"getMasters",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.options,n=void 0===i?{type:"RANKED_SOLO_5x5"}:i,r=arguments[1];return this._leagueRequest({endUrl:"master",region:t,options:n},r=2===arguments.length?r:arguments[0])}},{key:"getChampionList",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.options,n=arguments[1];return this._staticRequest({endUrl:"champions",region:t,options:i},n=2===arguments.length?n:arguments[0])}},{key:"getChampion",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.id,n=e.championID,r=e.options,s=arguments[1];return Number.isInteger(i||n)?this._staticRequest({endUrl:"champions/"+(i||n),region:t,options:r},s):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 this._staticRequest({endUrl:"items",region:t,options:i},n=2===arguments.length?n:arguments[0])}},{key:"getItem",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.id,n=e.itemID,r=e.options,s=arguments[1];return Number.isInteger(i||n)?this._staticRequest({endUrl:"items/"+(i||n),region:t,options:r},s):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 this._staticRequest({endUrl:"language-strings",region:t,options:i},n=2===arguments.length?n:arguments[0])}},{key:"getLanguages",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=arguments[1];return this._staticRequest({endUrl:"languages",region:t},i=t?i:arguments[0])}},{key:"getMapData",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.options,n=arguments[1];return this._staticRequest({endUrl:"maps",region:t,options:i},n=2===arguments.length?n:arguments[0])}},{key:"getMasteryList",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.options,n=arguments[1];return this._staticRequest({endUrl:"masteries",region:t,options:i},n=2===arguments.length?n:arguments[0])}},{key:"getMastery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.id,n=e.masteryID,r=e.options,s=arguments[1];return Number.isInteger(i||n)?this._staticRequest({endUrl:"masteries/"+(i||n),region:t,options:r},s):this._logError(this.getMastery.name,"required params "+o.yellow("`id/masteryID` (int)")+" not passed in")}},{key:"getRealmData",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=arguments[1];return this._staticRequest({endUrl:"realms",region:t},i=t?i:arguments[0])}},{key:"getRuneList",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.options,n=arguments[1];return this._staticRequest({endUrl:"runes",region:t,options:i},n=2===arguments.length?n:arguments[0])}},{key:"getRune",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.id,n=e.runeID,r=e.options,s=arguments[1];return Number.isInteger(i||n)?this._staticRequest({endUrl:"runes/"+(i||n),region:t,options:r},s):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 this._staticRequest({endUrl:"summoner-spells",region:t,options:i},n=2===arguments.length?n:arguments[0])}},{key:"getSummonerSpell",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.id,n=e.spellID,r=e.summonerSpellID,s=e.options,a=arguments[1];return Number.isInteger(i||n||r)?this._staticRequest({endUrl:"summoner-spells/"+(i||n||r),region:t,options:s},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 this._staticRequest({endUrl:"versions",region:t,options:i},n=2===arguments.length?n:arguments[0])}},{key:"getShardStatus",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=arguments[1];return this._statusRequest({endUrl:"shard-data",region:t},i=t?i:arguments[0])}},{key:"getMatch",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.id,n=e.matchID,r=e.options,s=void 0===r?{includeTimeline:!0}:r,a=arguments[1];return Number.isInteger(i||n)?this._matchRequest({endUrl:""+(i||n),region:t,options:s},a):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.id,r=t.summonerID,s=t.playerID,a=t.name,u=t.options,l=void 0===u?{rankedQueues:"TEAM_BUILDER_RANKED_SOLO"}:u,g=arguments[1];return Number.isInteger(n||r||s)?this._matchListRequest({endUrl:""+(n||r||s),region:i,options:l},g):"object"===h(arguments[0])&&"string"==typeof a?new Promise(function(t,n){return e.getSummoner({name:a,region:i},function(r,s){return r?void(g?g(r):n(r)):t(e._matchListRequest({endUrl:""+s.id,region:i,options:l},g))})}):this._logError(this.getMatchList.name,"required params "+o.yellow("`id/summonerID/playerID` (int)")+" or "+o.yellow("`name` (str)")+" not passed in")}},{key:"getRunes",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=t.region,n=t.id,r=t.summonerID,s=t.playerID,a=t.name,u=arguments[1];return Number.isInteger(n||r||s)?this._runesMasteriesRequest({endUrl:"runes/by-summoner/"+(n||r||s),region:i},u):"object"===h(arguments[0])&&"string"==typeof a?new Promise(function(t,n){return e.getSummoner({name:a,region:i},function(r,s){return r?void(u?u(r):n(r)):t(e._runesMasteriesRequest({endUrl:"runes/by-summoner/"+s.id,region:i},u))})}):this._logError(this.getRunes.name,"required params "+o.yellow("`id/summonerID/playerID` (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.id,r=t.summonerID,s=t.playerID,a=t.name,u=arguments[1];return Number.isInteger(n||r||s)?this._runesMasteriesRequest({endUrl:"masteries/by-summoner/"+(n||r||s),region:i},u):"object"===h(arguments[0])&&"string"==typeof a?new Promise(function(t,n){return e.getSummoner({name:a,region:i},function(r,s){return r?void(u?u(r):n(r)):t(e._runesMasteriesRequest({endUrl:"masteries/by-summoner/"+s.id,region:i},u))})}):this._logError(this.getMasteries.name,"required params "+o.yellow("`id/summonerID/playerID` (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.id,r=t.summonerID,s=t.playerID,a=t.name,u=t.options,l=arguments[1];return Number.isInteger(n||r||s)?this._statsRequest({endUrl:(n||r||s)+"/ranked",region:i,options:u},l):"object"===h(arguments[0])&&"string"==typeof a?new Promise(function(t,n){return e.getSummoner({name:a,region:i},function(r,s){return r?void(l?l(r):n(r)):t(e._statsRequest({endUrl:s.id+"/ranked",region:i,options:u},l))})}):void this._logError(this.getRankedStats.name,"required params "+o.yellow("`id/summonerID/playerID` (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.id,r=t.summonerID,s=t.playerID,a=t.name,u=t.options,l=arguments[1];return Number.isInteger(n||r||s)?this._statsRequest({endUrl:(n||r||s)+"/summary",region:i,options:u},l):"object"===h(arguments[0])&&"string"==typeof a?new Promise(function(t,n){return e.getSummoner({name:a,region:i},function(r,s){return r?void(l?l(r):n(r)):t(e._statsRequest({endUrl:s.id+"/summary",region:i,options:u},l))})}):void this._logError(this.getRankedStats.name,"required params "+o.yellow("`id/summonerID/playerID` (int)")+" or "+o.yellow("`name` (string)")+" not passed in")}},{key:"getSummoners",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.id,n=e.summonerID,r=e.playerID,s=e.name,a=arguments[1];return Number.isInteger(i||n||r)?this._summonerRequest({endUrl:""+(i||n||r),region:t},a):"object"===h(arguments[0])&&"string"==typeof s?this._summonerRequest({endUrl:"by-name/"+this._sanitizeName(s),region:t},a):void this._logError(this.getSummoners.name,"required params "+o.yellow("`id/summonerID/playerID` (int)")+" or "+o.yellow("`name` (str)")+" 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,r=e.playerID,s=e.name,a=arguments[1];return Number.isInteger(i||n||r)?this._summonerRequest({endUrl:""+(i||n||r),region:t},a):"object"===h(arguments[0])&&"string"==typeof s?this._summonerRequest({endUrl:"by-name/"+this._sanitizeName(s),region:t | ||
},a):this._logError(this.getSummoner.name,"required params "+o.yellow("`id/summonerID/playerID` (int)")+" or "+o.yellow("`name` (string)")+" not passed in")}}]),e}(),L={Kindred:w,REGIONS:b,LIMITS:S,TIME_CONSTANTS:R,CACHE_TYPES:_,QuickStart:l,print:g};e.exports=L}); | ||
!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,r,s,o,a){"use strict";function u(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function l(e,t,i){return new w({key:e,defaultRegion:t,debug:i,limits:f.DEV,cacheOptions:_[0]})}function g(e,t){e?console.log(e):console.log(t)}var h="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},m=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}}(),d=function(){function e(){u(this,e),this.cache={}}return m(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}(),c=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 m(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,i){this.client.setex(this.prefix+e.key,e.ttl,i,t.print),console.log("set for "+e.ttl+" seconds")}}]),e}(),p=function(){function e(t,n){u(this,e),this.allowedRequests=t,this.seconds=n,this.madeRequests=new i}return m(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}(),y={CHAMPION:"platform",CHAMPION_MASTERY:"champion-mastery",GAME:null,LEAGUE:null,STATUS:"status",MASTERIES:"platform",MATCH:null,MATCH_LIST:null,RUNES:"platform",RUNES_MASTERIES:"platform",SPECTATOR:"spectator",STATIC_DATA:"static-data",STATS:null,SUMMONER:"summoner"},R={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:R.MONTH,CHAMPION_MASTERY:R.SIX_HOURS,CURRENT_GAME:R.NONE,FEATURED_GAMES:R.NONE,GAME:R.HOUR,LEAGUE:R.SIX_HOURS,STATIC:R.MONTH,STATUS:R.NONE,MATCH:R.MONTH,MATCH_LIST:R.ONE_HOUR,RUNES_MASTERIES:R.WEEK,SPECTATOR:R.NONE,STATS:R.HOUR,SUMMONER:R.DAY},f={DEV:[[10,10],[500,600]],PROD:[[3e3,10],[18e4,600]]},S={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"},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"},I={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:2.5,STATIC_DATA:3,STATUS:3,MATCH:2.2,MATCH_LIST:2.2,RUNES_MASTERIES:3,SPECTATOR:3,STATS:1.3,SUMMONER:3},_=["in-memory-cache","redis"],A=n("^[0-9\\p{L} _\\.]+$"),M={int:function(e){return e.every(function(e){return Number.isInteger(e)})},string:function(e){return e.every(function(e){return"string"==typeof e})}},T={int:function(e){return e&&Array.isArray(e)&&M.int(e)&&e.length>0},string:function(e){return e&&Array.isArray(e)&&M.string(e)&&e.length>0}},C=function(e){var t=!0,i=!1,n=void 0;try{for(var r,s=Object.keys(b)[Symbol.iterator]();!(t=(r=s.next()).done);t=!0){var o=r.value;if(b[o]===e)return!0}}catch(e){i=!0,n=e}finally{try{!t&&s.return&&s.return()}finally{if(i)throw n}}return!1},U={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=U[e];if(t)return t},N=[200,400,500],D=function(e){return e>=N[0]&&e<N[1]?r.green(e):e>=N[1]&&e<N[2]?r.red(e+" "+q(e)):r.bold.red(e+" "+q(e))},k=function(e){return(Array.isArray(e)&&2!==e.length||!T.int(e[0])||2!==e[0].length||!T.int(e[1])||2!==e[1].length)&&"dev"!==e&&"prod"!==e},O=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()},w=function(){function e(t){var i=t.key,n=t.defaultRegion,r=void 0===n?b.NORTH_AMERICA:n,s=t.debug,a=void 0!==s&&s,l=t.limits,g=t.cacheOptions,h=t.cacheTTL;if(u(this,e),this.key=i,this.defaultRegion=C(r)?r:void 0,this.defaultRegion||(console.log(""+o.red("Initialization of Kindred failed: "+o.yellow(r)+" 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===_[0]?this.cache=new d:g===_[1]?this.cache=new c:this.cache=g,this.CACHE_TIMERS=h?h: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}),l){k(l)&&(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"===l&&(l=f.DEV),"prod"===l&&(l=f.PROD);var m=!0,y=!1,R=void 0;try{for(var S,I=Object.keys(b)[Symbol.iterator]();!(m=(S=I.next()).done);m=!0){var E=S.value;this.limits[b[E]]=[new p(l[0][0],l[0][1]),new p(l[1][0],l[1][1])]}}catch(e){y=!0,R=e}finally{try{!m&&I.return&&I.return()}finally{if(y)throw R}}}this.Champion={getChampions:this.getChamps.bind(this),getAll:this.getChamps.bind(this),all:this.getChamps.bind(this),getChampion:this.getChamp.bind(this),get:this.getChamp.bind(this)},this.ChampionMastery={getChampionMastery:this.getChampMastery.bind(this),get:this.getChampMastery.bind(this),getChampionMasteries:this.getChampMasteries.bind(this),getAll:this.getChampMasteries.bind(this),all:this.getChampMasteries.bind(this),getTotalChampionMasteryScore:this.getTotalChampMasteryScore.bind(this),getTotalScore:this.getTotalChampMasteryScore.bind(this),totalScore:this.getTotalChampMasteryScore.bind(this),total:this.getTotalChampMasteryScore.bind(this),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)},this.Game={getRecentGames:this.getRecentGames.bind(this),getRecent:this.getRecentGames.bind(this),get:this.getRecentGames.bind(this)},this.League={getLeagues:this.getLeagues.bind(this),get:this.getLeagues.bind(this),getLeagueEntries:this.getLeagueEntries.bind(this),getEntries:this.getLeagueEntries.bind(this),entries:this.getLeagueEntries.bind(this),getChallengers:this.getChallengers.bind(this),challengers:this.getChallengers.bind(this),getMasters:this.getMasters.bind(this),masters:this.getMasters.bind(this)},this.Static={getChampions:this.getChampionList.bind(this),champions:this.getChampionList.bind(this),getChampion:this.getChampion.bind(this),champion:this.getChampion.bind(this),getItems:this.getItems.bind(this),items:this.getItems.bind(this),getItem:this.getItem.bind(this),item:this.getItem.bind(this),getLanguageStrings:this.getLanguageStrings.bind(this),languageStrings:this.getLanguageStrings.bind(this),getLanguages:this.getLanguages.bind(this),languages:this.getLanguages.bind(this),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)},this.MatchList={getMatchList:this.getMatchList.bind(this),get:this.getMatchList.bind(this)},this.RunesMasteries={getRunes:this.getRunes.bind(this),runes:this.getRunes.bind(this),getMasteries:this.getMasteries.bind(this),masteries:this.getMasteries.bind(this)},this.Runes={get:this.getRunes.bind(this)},this.Masteries={get:this.getMasteries.bind(this)},this.Stats={getRankedStats:this.getRankedStats.bind(this),ranked:this.getRankedStats.bind(this),getStatsSummary:this.getStatsSummary.bind(this),summary:this.getStatsSummary.bind(this)},this.Summoner={getSummoner:this.getSummoner.bind(this),get:this.getSummoner.bind(this)}}return m(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,r,s){var o=i?"":t+"/",a=n||r||s?"":"api/lol/"+o,u="https://"+t+".api.riotgames.com/"+a+encodeURI(e),l="https://"+S[I[t]].toLowerCase()+".api.riotgames.com/lol/"+encodeURI(e);return l.lastIndexOf("v3")==-1?u:l}},{key:"_baseRequest",value:function(e,t){var i=this,n=e.endUrl,r=e.region,u=void 0===r?this.defaultRegion:r,l=e.status,g=void 0!==l&&l,h=e.observerMode,m=void 0!==h&&h,d=e.staticReq,c=void 0!==d&&d,p=e.championMastery,y=void 0!==p&&p,R=e.options,v=void 0===R?{}:R,f=e.cacheParams,S=void 0===f?{}:f,b=function(){return new Promise(function(e,r){var l=!0,h=!1,d=void 0;try{for(var p,R=Object.keys(v)[Symbol.iterator]();!(l=(p=R.next()).done);l=!0){var f=p.value;Array.isArray(v[f])&&(v[f]=v[f].join(","))}}catch(e){h=!0,d=e}finally{try{!l&&R.return&&R.return()}finally{if(h)throw d}}var b=a.stringify(v).replace(/%2C/,","),I=b?"?"+b:"",E=i._makeUrl(n+I,u,c,g,m,y),_=E+(E.lastIndexOf("?")===-1?"?":"&")+"api_key="+i.key;i.cache.get({key:E},function(n,a){if(a){var l=JSON.parse(a);return t?t(n,l):e(l)}if(i.limits){var g=i;!function t(i){g.canMakeRequest(u)?(c||(g.limits[u][0].addRequest(),g.limits[u][1].addRequest()),s({url:_},function(n,s,a){if(s&&a){var u=s.statusCode,l=D(u);if(g.debug&&O(s,l,_),"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*s.headers["retry-after"]+50)),u>=400?i(l+" : "+o.yellow(E)):(Number.isInteger(S.ttl)&&S.ttl>0&&g.cache.set({key:E,ttl:S.ttl},a),i(n,JSON.parse(a)));if(500===u)g.debug&&console.log("!!! resending promise request !!!"),setTimeout(function(){return r("retry")},1e3);else{if(429!==u)return n||u>=400?r("err:",n,u):(Number.isInteger(S.ttl)&&S.ttl>0&&g.cache.set({key:E,ttl:S.ttl},a),e(JSON.parse(a)));g.debug&&console.log("!!! resending promise request !!!"),setTimeout(function(){return r("retry")},1e3*s.headers["retry-after"]+50)}}else console.log(n,_)})):setTimeout(function(){t.bind(g)(i)},1e3)}(t)}else s({url:_},function(i,n,s){if(n){var a=n.statusCode,u=D(a);return g.debug&&O(n,u,_),"function"==typeof t?a>=400?t(u+" : "+o.yellow(E)):t(i,JSON.parse(s)):i?r("err:",i):e(JSON.parse(s))}console.log(i,E)})})})};return t?b():b().catch(b).catch(b).catch(b).then(function(e){return e})}},{key:"_championMasteryRequest",value:function(e,t){var i=e.endUrl,n=e.region,r=e.options;return this._baseRequest({endUrl:y.CHAMPION_MASTERY+"/v"+E.CHAMPION+"/"+i,region:n,options:r,championMastery:!0,cacheParams:{ttl:this.CACHE_TIMERS.CHAMPION_MASTERY}},t)}},{key:"_championRequest",value:function(e,t){var i=e.endUrl,n=e.region,r=e.options;return this._baseRequest({endUrl:y.CHAMPION+"/v"+E.CHAMPION+"/"+i,region:n,options:r,cacheParams:{ttl:this.CACHE_TIMERS.CHAMPION}},t)}},{key:"_spectatorRequest",value:function(e,t){var i=e.endUrl,n=e.region;return this._baseRequest({endUrl:y.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,r=void 0===n?this.defaultRegion:n,s=e.options;return this._baseRequest({endUrl:y.STATIC_DATA+"/v"+E.STATIC_DATA+"/"+i,staticReq:!0,region:r,options:s,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:y.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,r=e.options;return this._baseRequest({endUrl:"v"+E.LEAGUE+"/league/"+i,region:n,options:r,cacheParams:{ttl:this.CACHE_TIMERS.LEAGUE}},t)}},{key:"_matchRequest",value:function(e,t){var i=e.endUrl,n=e.region,r=e.options;return this._baseRequest({endUrl:"v"+E.MATCH+"/match/"+i,region:n,options:r,cacheParams:{ttl:this.CACHE_TIMERS.MATCH}},t)}},{key:"_matchListRequest",value:function(e,t){var i=e.endUrl,n=e.region,r=e.options;return this._baseRequest({endUrl:"v"+E.MATCH_LIST+"/matchlist/by-summoner/"+i,region:n,options:r,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:y.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,r=e.options;return this._baseRequest({endUrl:"v"+E.STATS+"/stats/by-summoner/"+i,region:n,options:r,cacheParams:{ttl:this.CACHE_TIMERS.STATS}},t)}},{key:"_summonerRequest",value:function(e,t){var i=e.endUrl,n=e.region;return this._baseRequest({endUrl:y.SUMMONER+"/v"+E.SUMMONER+"/summoners/"+i,region:n,cacheParams:{ttl:this.CACHE_TIMERS.SUMMONER}},t)}},{key:"_logError",value:function(e,t){console.log(o.bold.yellow(e),o.red("request"),o.bold.red("FAILED")+o.red("; "+t))}},{key:"setRegion",value:function(e){this.defaultRegion=C(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 this._championRequest({endUrl:"champions",region:t,options:i},n=2===arguments.length?n:arguments[0])}},{key:"getChamp",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.id,n=e.championID,r=arguments[1];return Number.isInteger(i)||Number.isInteger(n)?this._championRequest({endUrl:"champions/"+(i||n),region:t},r):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,r=e.championID,s=e.options,a=arguments[1];return Number.isInteger(n)&&Number.isInteger(r)?this._championMasteryRequest({endUrl:"champion-masteries/by-summoner/"+n+"/by-champion/"+r,region:i,options:s},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,r=t.id,s=t.summonerID,a=t.playerID,u=t.name,l=t.options,g=arguments[1];return Number.isInteger(r||s||a)?this._championMasteryRequest({endUrl:"champion-masteries/by-summoner/"+(r||s||a),region:n,options:l},g):"object"===h(arguments[0])&&"string"==typeof u?new Promise(function(t,i){return e.getSummoner({name:u,region:n},function(r,s){return r?void(g?g(r):i(r)):t(e._championMasteryRequest({endUrl:"champion-masteries/by-summoner/"+s.id,region:n},g))})}):this._logError(this.getChampMasteries.name,"required params "+o.yellow("`id/summonerID/playerID` (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,r=t.id,s=t.summonerID,a=t.playerID,u=t.name,l=t.options,g=arguments[1];return Number.isInteger(r||s||a)?this._championMasteryRequest({endUrl:"scores/by-summoner/"+(r||s||a),region:n,options:l},g):"object"===h(arguments[0])&&"string"==typeof u?new Promise(function(t,i){return e.getSummoner({name:u,region:n},function(r,s){return r?void(g?g(r):i(r)):t(e._championMasteryRequest({endUrl:"scores/by-summoner/"+s.id,region:n},g))})}):this._logError(this.getTotalChampMasteryScore.name,"required params "+o.yellow("`id/summonerID/playerID` (int)")+" or "+o.yellow("`name` (str)")+" not passed in")}},{key:"getCurrentGame",value:function(){var e=this,t=arguments,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=i.region,r=void 0===n?this.defaultRegion:n,s=i.id,a=i.summonerID,u=i.playerID,l=i.name,g=arguments[1];return Number.isInteger(s||a||u)?this._spectatorRequest({endUrl:"active-games/by-summoner/"+(s||a||u),region:r},g=r?g:arguments[0]):"object"===h(arguments[0])&&"string"==typeof l?new Promise(function(i,n){return e.getSummoner({name:l,region:r},function(s,o){return s?void(g?g(s):n(s)):i(e._spectatorRequest({endUrl:"active-games/by-summoner/"+o.id,region:r},g=r?g:t[0]))})}):this._logError(this.getCurrentGame.name,"required params "+o.yellow("`id/summonerID/playerID` (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 this._spectatorRequest({endUrl:"featured-games",region:t},i=t?i:arguments[0])}},{key:"getRecentGames",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=t.region,n=t.id,r=t.summonerID,s=t.playerID,a=t.name,u=arguments[1];return Number.isInteger(n||r||s)?this._gameRequest({endUrl:"by-summoner/"+(n||r||s)+"/recent",region:i},u):"object"===h(arguments[0])&&"string"==typeof a?new Promise(function(t,n){return e.getSummoner({name:a,region:i},function(r,s){return r?void(u?u(r):n(r)):t(e._gameRequest({endUrl:"by-summoner/"+s.id+"/recent",region:i},u))})}):this._logError(this.getRecentGames.name,"required params "+o.yellow("`id/summonerID/playerID` (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.id,r=t.summonerID,s=t.playerID,a=t.name,u=t.options,l=arguments[1];return Number.isInteger(n||r||s)?this._leagueRequest({endUrl:"by-summoner/"+(n||r||s),region:i,options:u},l):"object"===h(arguments[0])&&"string"==typeof a?new Promise(function(t,n){return e.getSummoner({name:a,region:i},function(r,s){return r?void(l?l(r):n(r)):t(e._leagueRequest({endUrl:"by-summoner/"+s.id,region:i,options:u},l))})}):this._logError(this.getLeagues.name,"required params "+o.yellow("`id/summonerID/playerID` (int)")+" or "+o.yellow("`name` (str)")+" not passed in")}},{key:"getLeagueEntries",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=t.region,n=t.id,r=t.summonerID,s=t.playerID,a=t.name,u=arguments[1];return Number.isInteger(n||r||s)?this._leagueRequest({endUrl:"by-summoner/"+(n||r||s)+"/entry",region:i},u):"object"===h(arguments[0])&&"string"==typeof a?new Promise(function(t,n){return e.getSummoner({name:a,region:i},function(r,s){return r?void(u?u(r):n(r)):t(e._leagueRequest({endUrl:"by-summoner/"+s.id+"/entry",region:i},u))})}):void this._logError(this.getLeagueEntries.name,"required params "+o.yellow("`id/summonerID/playerID` (int)")+" or "+o.yellow("`name` (str)")+" not passed in")}},{key:"getChallengers",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.options,n=void 0===i?{type:"RANKED_SOLO_5x5"}:i,r=arguments[1];return this._leagueRequest({endUrl:"challenger",region:t,options:n},r=2===arguments.length?r:arguments[0])}},{key:"getMasters",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.options,n=void 0===i?{type:"RANKED_SOLO_5x5"}:i,r=arguments[1];return this._leagueRequest({endUrl:"master",region:t,options:n},r=2===arguments.length?r:arguments[0])}},{key:"getChampionList",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.options,n=arguments[1];return this._staticRequest({endUrl:"champions",region:t,options:i},n=2===arguments.length?n:arguments[0])}},{key:"getChampion",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.id,n=e.championID,r=e.options,s=arguments[1];return Number.isInteger(i||n)?this._staticRequest({endUrl:"champions/"+(i||n),region:t,options:r},s):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 this._staticRequest({endUrl:"items",region:t,options:i},n=2===arguments.length?n:arguments[0])}},{key:"getItem",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.id,n=e.itemID,r=e.options,s=arguments[1];return Number.isInteger(i||n)?this._staticRequest({endUrl:"items/"+(i||n),region:t,options:r},s):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 this._staticRequest({endUrl:"language-strings",region:t,options:i},n=2===arguments.length?n:arguments[0])}},{key:"getLanguages",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=arguments[1];return this._staticRequest({endUrl:"languages",region:t},i=t?i:arguments[0])}},{key:"getMapData",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.options,n=arguments[1];return this._staticRequest({endUrl:"maps",region:t,options:i},n=2===arguments.length?n:arguments[0])}},{key:"getMasteryList",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.options,n=arguments[1];return this._staticRequest({endUrl:"masteries",region:t,options:i},n=2===arguments.length?n:arguments[0])}},{key:"getMastery",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.id,n=e.masteryID,r=e.options,s=arguments[1];return Number.isInteger(i||n)?this._staticRequest({endUrl:"masteries/"+(i||n),region:t,options:r},s):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 this._staticRequest({endUrl:"profile-icons",region:i,options:n},t=2===arguments.length?t:arguments[0])}},{key:"getRealmData",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=arguments[1];return this._staticRequest({endUrl:"realms",region:t},i=t?i:arguments[0])}},{key:"getRuneList",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.options,n=arguments[1];return this._staticRequest({endUrl:"runes",region:t,options:i},n=2===arguments.length?n:arguments[0])}},{key:"getRune",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.id,n=e.runeID,r=e.options,s=arguments[1];return Number.isInteger(i||n)?this._staticRequest({endUrl:"runes/"+(i||n),region:t,options:r},s):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 this._staticRequest({endUrl:"summoner-spells",region:t,options:i},n=2===arguments.length?n:arguments[0])}},{key:"getSummonerSpell",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.id,n=e.spellID,r=e.summonerSpellID,s=e.options,a=arguments[1];return Number.isInteger(i||n||r)?this._staticRequest({endUrl:"summoner-spells/"+(i||n||r),region:t,options:s},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 this._staticRequest({endUrl:"versions",region:t,options:i},n=2===arguments.length?n:arguments[0])}},{key:"getShardStatus",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=arguments[1];return this._statusRequest({endUrl:"shard-data",region:t},i=t?i:arguments[0])}},{key:"getMatch",value:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=e.region,i=e.id,n=e.matchID,r=e.options,s=void 0===r?{includeTimeline:!0}:r,a=arguments[1];return Number.isInteger(i||n)?this._matchRequest({endUrl:""+(i||n),region:t,options:s},a):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.id,r=t.summonerID,s=t.playerID,a=t.name,u=t.options,l=void 0===u?{rankedQueues:"TEAM_BUILDER_RANKED_SOLO"}:u,g=arguments[1];return Number.isInteger(n||r||s)?this._matchListRequest({endUrl:""+(n||r||s),region:i,options:l},g):"object"===h(arguments[0])&&"string"==typeof a?new Promise(function(t,n){return e.getSummoner({name:a,region:i},function(r,s){return r?void(g?g(r):n(r)):t(e._matchListRequest({endUrl:""+s.id,region:i,options:l},g))})}):this._logError(this.getMatchList.name,"required params "+o.yellow("`id/summonerID/playerID` (int)")+" or "+o.yellow("`name` (str)")+" not passed in")}},{key:"getRunes",value:function(){var e=this,t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=t.region,n=t.id,r=t.summonerID,s=t.playerID,a=t.name,u=arguments[1];return Number.isInteger(n||r||s)?this._runesMasteriesRequest({endUrl:"runes/by-summoner/"+(n||r||s),region:i},u):"object"===h(arguments[0])&&"string"==typeof a?new Promise(function(t,n){return e.getSummoner({name:a,region:i},function(r,s){return r?void(u?u(r):n(r)):t(e._runesMasteriesRequest({endUrl:"runes/by-summoner/"+s.id,region:i},u))})}):this._logError(this.getRunes.name,"required params "+o.yellow("`id/summonerID/playerID` (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.id,r=t.summonerID,s=t.playerID,a=t.name,u=arguments[1];return Number.isInteger(n||r||s)?this._runesMasteriesRequest({endUrl:"masteries/by-summoner/"+(n||r||s),region:i},u):"object"===h(arguments[0])&&"string"==typeof a?new Promise(function(t,n){return e.getSummoner({name:a,region:i},function(r,s){return r?void(u?u(r):n(r)):t(e._runesMasteriesRequest({endUrl:"masteries/by-summoner/"+s.id,region:i},u))})}):this._logError(this.getMasteries.name,"required params "+o.yellow("`id/summonerID/playerID` (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.id,r=t.summonerID,s=t.playerID,a=t.name,u=t.options,l=arguments[1];return Number.isInteger(n||r||s)?this._statsRequest({endUrl:(n||r||s)+"/ranked",region:i,options:u},l):"object"===h(arguments[0])&&"string"==typeof a?new Promise(function(t,n){return e.getSummoner({name:a,region:i},function(r,s){return r?void(l?l(r):n(r)):t(e._statsRequest({endUrl:s.id+"/ranked",region:i,options:u},l))})}):void this._logError(this.getRankedStats.name,"required params "+o.yellow("`id/summonerID/playerID` (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.id,r=t.summonerID,s=t.playerID,a=t.name,u=t.options,l=arguments[1];return Number.isInteger(n||r||s)?this._statsRequest({endUrl:(n||r||s)+"/summary",region:i,options:u},l):"object"===h(arguments[0])&&"string"==typeof a?new Promise(function(t,n){return e.getSummoner({name:a,region:i},function(r,s){return r?void(l?l(r):n(r)):t(e._statsRequest({endUrl:s.id+"/summary",region:i,options:u},l))})}):void this._logError(this.getRankedStats.name,"required params "+o.yellow("`id/summonerID/playerID` (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,r=e.playerID,s=e.accountID,a=e.name,u=arguments[1];return Number.isInteger(i||n||r)?this._summonerRequest({endUrl:""+(i||n||r),region:t},u):"object"===h(arguments[0])&&"string"==typeof a?this._summonerRequest({endUrl:"by-name/"+this._sanitizeName(a),region:t},u):Number.isInteger(s)?this._summonerRequest({endUrl:"by-account/"+s,region:t},u):this._logError(this.getSummoner.name,"required params "+o.yellow("`id/summonerID/playerID` (int)")+", "+o.yellow("`accountID` (int)")+", or "+o.yellow("`name` (string)")+" not passed in")}}]),e}(),L={Kindred:w, | ||
REGIONS:b,LIMITS:f,TIME_CONSTANTS:R,CACHE_TYPES:_,QuickStart:l,print:g};e.exports=L}); |
{ | ||
"name": "kindred-api", | ||
"version": "2.0.6", | ||
"version": "2.0.8", | ||
"description": "Kindred is a thin Node.js wrapper on top of Riot Games API for League of Legends", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
117
README.md
@@ -62,3 +62,3 @@ # Kindred | ||
* Namespaced Functions: *ChampionMastery.getChampionMasteries, ChampionMastery.getAll, ChampionMastery.all* | ||
* Example 1: ```k.ChampionMastery.all({ id: 20026563 }, rprint)``` | ||
* Example 1: ```k.ChampionMastery.all({ id: 20026563 }, KindredAPI.print)``` | ||
* Example 2: ```k.ChampionMastery.all({ id: 20026563 }).then(data => console.log(data))``` | ||
@@ -69,3 +69,3 @@ 2. **/lol/champion-mastery/v3/champion-masteries/by-summoner/{summonerId}/by-champion/{championId}** | ||
* Namespaced Functions: *ChampionMastery.getChampionMastery, ChampionMastery.get* | ||
* Example 1: ```k.ChampionMastery.get({ playerID: 20026563, championID: 203 }, rprint)``` | ||
* Example 1: ```k.ChampionMastery.get({ playerID: 20026563, championID: 203 }, KindredAPI.print)``` | ||
* Example 2: ```k.ChampionMastery.get({ playerID: 20026563, championID: 203 }).then(data => console.log(data))``` | ||
@@ -76,3 +76,3 @@ 3. **/lol/champion-mastery/v3/scores/by-summoner/{summonerId}** | ||
* Namespaced Functions: *ChampionMastery.getTotalChampMasteryScore, ChampionMastery.getTotalScore, ChampionMastery.totalScore, ChampionMastery.total, ChampionMastery.score* | ||
* Example 1: ```k.ChampionMastery.score({ id: 20026563 }, rprint)``` | ||
* Example 1: ```k.ChampionMastery.score({ id: 20026563 }, KindredAPI.print)``` | ||
@@ -86,3 +86,3 @@ ### Champion | ||
* Namespaced Functions: *Champion.getChampions, Champion.getAll, Champion.all* | ||
* Example 1: ```k.Champion.all({ region: REGIONS.KOREA }, rprint)``` | ||
* Example 1: ```k.Champion.all({ region: REGIONS.KOREA }, KindredAPI.print)``` | ||
2. **/lol/platform/v3/champions/{id}** | ||
@@ -92,5 +92,5 @@ * Retrieve champion by ID. | ||
* Namespaced Functions: *Champion.getChampion, Champion.get* | ||
* Example 1: ```k.Champion.get({ championID: 67 }, rprint)``` | ||
* Example 1: ```k.Champion.get({ championID: 67 }, KindredAPI.print)``` | ||
* Example 2: ```k.Champion.get({ championID: 67 }).then(data => console.log(data))``` | ||
* Example 3: ```k.Champion.get({ championID: 67, region: 'kr' }, rprint)``` | ||
* Example 3: ```k.Champion.get({ championID: 67, region: 'kr' }, KindredAPI.print)``` | ||
@@ -104,3 +104,3 @@ ### Game | ||
* Namespaced Functions: *Game.getRecentGames, Game.getRecent, Game.get* | ||
* Example 1: ```k.Game.get({ summonerID: 20026563 }, rprint)``` | ||
* Example 1: ```k.Game.get({ summonerID: 20026563 }, KindredAPI.print)``` | ||
@@ -114,4 +114,4 @@ ### League | ||
* Namespaced Functions: *League.getLeagues, League.get* | ||
* Example 1: ```k.League.getLeagues({ summonerID: 20026563 }, rprint)``` | ||
* Example 2: ```k.League.get({ summonerID: 20026563 }, rprint)``` | ||
* Example 1: ```k.League.getLeagues({ summonerID: 20026563 }, KindredAPI.print)``` | ||
* Example 2: ```k.League.get({ summonerID: 20026563 }, KindredAPI.print)``` | ||
2. **/api/lol/{region}/v2.5/league/by-summoner/{summonerIds}/entry** | ||
@@ -121,3 +121,3 @@ * Get league entries mapped by summoner ID for a given list of summoner IDs. (REST) | ||
* Namespaced Functions: *League.getLeagueEntries, League.getEntries, League.entries* | ||
* Example 1: ```k.League.entries({ summonerID: 20026563 }, rprint)``` | ||
* Example 1: ```k.League.entries({ summonerID: 20026563 }, KindredAPI.print)``` | ||
3. **/api/lol/{region}/v2.5/league/challenger** | ||
@@ -127,5 +127,5 @@ * Get challenger tier leagues. (REST) | ||
* Namespaced Functions: *League.getChallengers, League.challengers* | ||
* Example 1: ```k.League.challengers(rprint)``` | ||
* Example 2: ```k.League.challengers({ region: 'na' }, rprint)``` | ||
* Example 3: ```k.League.challengers({ options: { type: 'RANKED_FLEX_SR' } }, rprint)``` | ||
* Example 1: ```k.League.challengers(KindredAPI.print)``` | ||
* Example 2: ```k.League.challengers({ region: 'na' }, KindredAPI.print)``` | ||
* Example 3: ```k.League.challengers({ options: { type: 'RANKED_FLEX_SR' } }, KindredAPI.print)``` | ||
4. **/api/lol/{region}/v2.5/league/master** | ||
@@ -152,3 +152,3 @@ * Get master tier leagues. (REST) | ||
* Namespaced Functions: *RunesMasteries.getMasteries, RunesMasteries.masteries, Masteries.get* | ||
* Example 1: ```k.Masteries.get({ id: 20026563 }, rprint)``` | ||
* Example 1: ```k.Masteries.get({ id: 20026563 }, KindredAPI.print)``` | ||
@@ -162,4 +162,4 @@ ### Match | ||
* Namespaced Functions: *Match.getMatch, Match.get* | ||
* Example 1: ```k.Match.get({ id: 1912829920 }, rprint)``` | ||
* Example 2: ```k.Match.get({ id: 1912829920, options: { includeTimeline: false } }, rprint)``` | ||
* Example 1: ```k.Match.get({ id: 1912829920 }, KindredAPI.print)``` | ||
* Example 2: ```k.Match.get({ id: 1912829920, options: { includeTimeline: false } }, rprKindredAPI.printint)``` | ||
@@ -173,4 +173,4 @@ ### MatchList | ||
* Namespaced Functions: *MatchList.getMatchList, MatchList.get* | ||
* Example 1: ```k.MatchList.get({ id: 20026563 }, rprint)``` | ||
* Example 2: ```k.MatchList.get({ id: 20026563, options: { rankedQueues: 'RANKED_FLEX_SR' } }, rprint)``` | ||
* Example 1: ```k.MatchList.get({ id: 20026563 }, KindredAPI.print)``` | ||
* Example 2: ```k.MatchList.get({ id: 20026563, options: { rankedQueues: 'RANKED_FLEX_SR' } }, KindredAPI.print)``` | ||
@@ -184,3 +184,3 @@ ### Runes | ||
* Namespaced Functions: *RunesMasteries.getRunes, RunesMasteries.runes, Runes.get* | ||
* Example 1: ```k.Runes.get({ id: 20026563 }, rprint)``` | ||
* Example 1: ```k.Runes.get({ id: 20026563 }, KindredAPI.print)``` | ||
@@ -194,3 +194,3 @@ ### Spectator | ||
* Namespaced Functions: *CurrentGame.getCurrentGame, CurrentGame.get* | ||
* Example 1: ```k.CurrentGame.get({ name: 'Contractz' }, rprint)``` | ||
* Example 1: ```k.CurrentGame.get({ name: 'Contractz' }, KindredAPI.print)``` | ||
2. **/lol/spectator/v3/featured-games** | ||
@@ -201,3 +201,3 @@ * Get list of featured games. (REST) | ||
* Example 1: ```k.FeaturedGames.get().then(data => console.log(data))``` | ||
* Example 2: ```k.FeaturedGames.get({ region: 'na' }, rprint)``` | ||
* Example 2: ```k.FeaturedGames.get({ region: 'na' }, KindredAPI.print)``` | ||
@@ -211,3 +211,3 @@ ### Static Data | ||
* Namespaced Functions: *Static.getChampions, Static.champions* | ||
* Example 1: ```k.Static.champions(rprint)``` | ||
* Example 1: ```k.Static.champions(KindredAPI.print)``` | ||
* Example 2: ```k.Static.champions({ options: { champData: 'all' } }).then(data => console.log(data))``` | ||
@@ -218,4 +218,4 @@ 2. **/lol/static-data/v3/champions/{id}** | ||
* Namespaced Functions: *Static.getChampion, Static.champion* | ||
* Example 1: ```k.Static.champion({ id: 131 }, rprint)``` | ||
* Example 2: ```k.Static.champion({ id: 131, options: { champData: 'enemytips', version: '7.7.1' } }, rprint)``` | ||
* Example 1: ```k.Static.champion({ id: 131 }, KindredAPI.print)``` | ||
* Example 2: ```k.Static.champion({ id: 131, options: { champData: 'enemytips', version: '7.7.1' } }, KindredAPI.print)``` | ||
3. **/lol/static-data/v3/items** | ||
@@ -225,3 +225,3 @@ * Retrieves item list. (REST) | ||
* Namespaced Functions: *Static.getItems, Static.items* | ||
* Example 1: ```k.Static.items({ options: { itemListData: all } }, rprint)``` | ||
* Example 1: ```k.Static.items({ options: { itemListData: all } }, KindredAPI.print)``` | ||
4. **/lol/static-data/v3/items/{id}** | ||
@@ -231,4 +231,4 @@ * Get master tier leagues. (REST) | ||
* Namespaced Functions: *Static.getItem, Static.item* | ||
* Example 1: ```k.Static.item({ id: 3901, options: { itemData: ['image', 'gold'] } }, rprint)``` | ||
* Example 2: ```k.Static.items(rprint)``` | ||
* Example 1: ```k.Static.item({ id: 3901, options: { itemData: ['image', 'gold'] } }, KindredAPI.print)``` | ||
* Example 2: ```k.Static.items(KindredAPI.print)``` | ||
5. **/lol/static-data/v3/language-strings** | ||
@@ -238,3 +238,3 @@ * Retrieve language strings data. (REST) | ||
* Namespaced Functions: *Static.getLanguageStrings, Static.languageStrings* | ||
* Example 1: ```k.Static.languageStrings(rprint)``` | ||
* Example 1: ```k.Static.languageStrings(KindredAPI.print)``` | ||
6. **/lol/static-data/v3/languages** | ||
@@ -254,4 +254,4 @@ * Retrieve supported languages data. (REST) | ||
* Namespaced Functions: *Static.getMasteries, Static.masteries* | ||
* Example 1: ```k.Static.masteries({ options: { masteryListData: 'image' } }, rprint)``` | ||
* Example 2: ```k.Static.masteries(rprint)``` | ||
* Example 1: ```k.Static.masteries({ options: { masteryListData: 'image' } }, KindredAPI.print)``` | ||
* Example 2: ```k.Static.masteries(KindredAPI.print)``` | ||
9. **/lol/static-data/v3/masteries/{id}** | ||
@@ -261,6 +261,10 @@ * Retrieves mastery item by its unique id. (REST) | ||
* Namespaced Functions: *Static.getMastery, Static.mastery* | ||
* Example 1: ```k.Static.mastery({ id: 6361 }, rprint)``` | ||
* Example 2: ```k.Static.mastery({ id: 6361, options: { masteryData: ['image', 'masteryTree'] } }, rprint)``` | ||
* Example 3: ```k.Static.mastery({ id: 6361, options: { masteryData: 'image' } }, rprint)``` | ||
* Example 1: ```k.Static.mastery({ id: 6361 }, KindredAPI.print)``` | ||
* Example 2: ```k.Static.mastery({ id: 6361, options: { masteryData: ['image', 'masteryTree'] } }, KindredAPI.print)``` | ||
* Example 3: ```k.Static.mastery({ id: 6361, options: { masteryData: 'image' } }, KindredAPI.print)``` | ||
10. **/lol/static-data/v3/profile-icons** | ||
* Retrieve profile icons. (REST) | ||
* getProfileIcons({ region, options (object) }, cb) | ||
* Namespaced Functions: *Static.getProfileIcons, Static.profileIcons* | ||
* Example 1: ```k.Static.profileIcons(KindredAPI.print)``` | ||
11. **/lol/static-data/v3/realms** | ||
@@ -276,3 +280,3 @@ * Retrieve realm data. (REST) | ||
* Example 1: ```k.Static.runes().then(data => console.log(data))``` | ||
* Example 2: ```k.Static.runes({ options: { runeListData: 'basic' } }, rprint)``` | ||
* Example 2: ```k.Static.runes({ options: { runeListData: 'basic' } }, KindredAPI.print)``` | ||
13. **/lol/static-data/v3/runes/{id}** | ||
@@ -282,4 +286,4 @@ * Retrieves rune by its unique id. (REST) | ||
* Namespaced Functions: *Static.getRune, Static.rune* | ||
* Example 1: ```k.Static.rune({ id: 10002 }, rprint)``` | ||
* Example 2: ```k.Static.rune({ id: 10001, options: { runeData: 'image' } }, rprint)``` | ||
* Example 1: ```k.Static.rune({ id: 10002 }, KindredAPI.print)``` | ||
* Example 2: ```k.Static.rune({ id: 10001, options: { runeData: 'image' } }, KindredAPI.print)``` | ||
14. **/lol/static-data/v3/summoner-spells** | ||
@@ -289,4 +293,4 @@ * Retrieves summoner spell list. (REST) | ||
* Namespaced Functions: *Static.getSummonerSpells, Static.summonerSpells, Static.spells* | ||
* Example 1: ```k.Static.spells(rprint)``` | ||
* Example 2: ```k.Static.spells({ options: { spellData: 'cost', dataById: true } }, rprint)``` | ||
* Example 1: ```k.Static.spells(KindredAPI.print)``` | ||
* Example 2: ```k.Static.spells({ options: { spellData: 'cost', dataById: true } }, KindredAPI.print)``` | ||
15. **/lol/static-data/v3/summoner-spells/{id}** | ||
@@ -296,7 +300,7 @@ * Retrieves summoner spell by its unique id. (REST) | ||
* Namespaced Functions: *Static.getSummonerSpell, Static.summonerSpell, Static.spell* | ||
* Example 1: ```k.Static.spell({ id: 31 }, rprint)``` | ||
* Example 2: ```k.Static.spell({ id: 31, options: { spellData: 'cooldown' } }, rprint)``` | ||
* Example 1: ```k.Static.spell({ id: 31 }, KindredAPI.print)``` | ||
* Example 2: ```k.Static.spell({ id: 31, options: { spellData: 'cooldown' } }, KindredAPI.print)``` | ||
16. **/lol/static-data/v3/versions** | ||
* Retrieve version data. (REST) | ||
* getVersionData({ region, options (object) }, cb) | ||
* getVersionData({ region }, cb) | ||
* Namespaced Functions: *Static.getVersionData, Static.versionData, Static.version, Static.versions* | ||
@@ -312,4 +316,4 @@ * Example 1: ```k.Static.versions(rprint)``` | ||
* Namespaced Functions: *Stats.getRankedStats, Stats.ranked* | ||
* Example 1: ```k.Stats.ranked({ id: 20026563 }, rprint)``` | ||
* Example 2: ```k.Stats.ranked({ id: 20026563, options: { season: 'SEASON2016' } }, function(err,data){})``` | ||
* Example 1: ```k.Stats.ranked({ id: 20026563 }, KindredAPI.print)``` | ||
* Example 2: ```k.Stats.ranked({ id: 20026563, options: { season: 'SEASON2016' } }, KindredAPI.print)``` | ||
2. **/api/lol/{region}/v1.3/stats/by-summoner/{summonerId}/summary** | ||
@@ -319,3 +323,3 @@ * Get player stats summaries by summoner ID. (REST) | ||
* Namespaced Functions: *Stats.getStatsSummary, Stats.summary* | ||
* Example 1: ```k.Stats.summary({ id: 20026563 }, rprint)``` | ||
* Example 1: ```k.Stats.summary({ id: 20026563 }, KindredAPI.print)``` | ||
@@ -325,12 +329,17 @@ ### Summoner | ||
1. **/api/lol/{region}/v1.4/summoner/by-account/{accountIds}** | ||
* Get a list of summoners by account ids (RPC). | ||
* N/A | ||
2. **/lol/summoner/v3/summoners/by-name/{summonerName}**, **/lol/summoner/v3/summoners/{summonerId}** | ||
* Get a summoner by summoner name, Get a summoner by summoner id | ||
* getSummoners({ region, name (str) }, cb) | ||
* getSummoner({ region, id (int), name (str) }, cb) | ||
* Namespaced Functions: *Summoner.getSummoners, Summoner.getAll, Summoner.all, Summoner.getSummoner, Summoner.get* | ||
* Example 1: ```k.Summoner.get({ name: 'caaaaaaaaarIa' }, rprint)``` | ||
* Example 2: ```k.Summoner.get({ id: 20026563 }, rprint)``` | ||
1. **/lol/summoner/v3/summoners/by-account/{accountId}** | ||
* Get a summoner by account id | ||
* getSummoner({ region, accountID (int), name (str) }, cb) | ||
* Namespaced Functions: *Summoner.getSummoner, Summoner.get* | ||
* Example 1: ```k.Summoner.get({ accountID: 123123 }, KindredAPI.print)``` | ||
2. **/lol/summoner/v3/summoners/by-name/{summonerName}** | ||
* Get a summoner by summoner name | ||
* getSummoner({ region, id/summonerID/playerID (int) }, cb) | ||
* Namespaced Functions: *Summoner.getSummoner, Summoner.get* | ||
* Example 1: ```k.Summoner.get({ name: 'Contractz' }, KindredAPI.print)``` | ||
3. **/lol/summoner/v3/summoners/{summonerId}** | ||
* Get a summoner by summoner id | ||
* getSummoner({ region, id/summonerID/playerID (int) }, cb) | ||
* Namespaced Functions: *Summoner.getSummoner, Summoner.get* | ||
* Example 1: ```k.Summoner.get({ id: 20026563 }, KindredAPI.print)``` | ||
@@ -337,0 +346,0 @@ ## Quickstart |
@@ -184,2 +184,5 @@ const request = require('request') | ||
getProfileIcons: this.getProfileIcons.bind(this), | ||
profileIcons: this.getProfileIcons.bind(this), | ||
getRealmData: this.getRealmData.bind(this), | ||
@@ -856,2 +859,6 @@ realmData: this.getRealmData.bind(this), | ||
getProfileIcons({ region, options }, cb) { | ||
return this._staticRequest({ endUrl: 'profile-icons', region, options }, cb = arguments.length === 2 ? cb : arguments[0]) | ||
} | ||
getRealmData({ region } = {}, cb) { | ||
@@ -1074,5 +1081,6 @@ return this._staticRequest({ endUrl: 'realms', region }, cb = region ? cb : arguments[0]) | ||
/* SUMMONER-V1.4 */ | ||
getSummoners({ | ||
getSummoner({ | ||
region, | ||
id, summonerID, playerID, | ||
accountID, | ||
name | ||
@@ -1090,29 +1098,11 @@ } = {}, cb) { | ||
}, cb) | ||
} else { | ||
this._logError( | ||
this.getSummoners.name, | ||
`required params ${chalk.yellow('`id/summonerID/playerID` (int)')} or ${chalk.yellow('`name` (str)')} not passed in` | ||
) | ||
} | ||
} | ||
getSummoner({ | ||
region, | ||
id, summonerID, playerID, | ||
name | ||
} = {}, cb) { | ||
if (Number.isInteger(id || summonerID || playerID)) { | ||
} else if (Number.isInteger(accountID)) { | ||
return this._summonerRequest({ | ||
endUrl: `${id || summonerID || playerID}`, | ||
endUrl: `by-account/${accountID}`, | ||
region | ||
}, cb) | ||
} else if (typeof arguments[0] === 'object' && typeof name === 'string') { | ||
return this._summonerRequest({ | ||
endUrl: `by-name/${this._sanitizeName(name)}`, | ||
region | ||
}, cb) | ||
} else { | ||
return this._logError( | ||
this.getSummoner.name, | ||
`required params ${chalk.yellow('`id/summonerID/playerID` (int)')} or ${chalk.yellow('`name` (string)')} not passed in` | ||
`required params ${chalk.yellow('`id/summonerID/playerID` (int)')}, ${chalk.yellow('`accountID` (int)')}, or ${chalk.yellow('`name` (string)')} not passed in` | ||
) | ||
@@ -1119,0 +1109,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
339810
674
3308