Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

kindred-api

Package Overview
Dependencies
Maintainers
1
Versions
114
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

kindred-api - npm Package Compare versions

Comparing version 1.1.9 to 1.2.0

3

dist/kindred-api.min.js

@@ -1,1 +0,2 @@

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

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -21,3 +21,3 @@ # Kindred

Hopefully there aren't *too* many bugs! ***I'm a noob after all, so use this library at your own risk.*** I'm currently working on adding namespaced functions.
Hopefully there aren't *too* many bugs! ***I'm a noob after all, so use this library at your own risk.*** I'm currently working on adding namespaced functions. In addition, I'm heavily focusing on refactoring the code now. The docs are not fully updated yet.

@@ -24,0 +24,0 @@ ## Philosophy

@@ -66,5 +66,48 @@ const request = require('request')

getChampions: this.getChamps.bind(this),
getChampion: this.getChamp.bind(this)
getAll: this.getChamps.bind(this),
getChampion: this.getChamp.bind(this),
get: this.getChamp.bind(this)
}
this.ChampionMastery = {
getChampionMastery: this.getChampMastery.bind(this),
get: this.getChampMastery.bind(this),
getChampionMasteries: this.getChampMasteries.bind(this),
getAll: this.getChampMasteries.bind(this),
getTotalChampionMasteryScore: this.getTotalChampMasteryScore.bind(this),
getTopChampions: this.getTopChamps.bind(this)
}
this.CurrentGame = {
getCurrentGame: this.getCurrentGame.bind(this),
get: this.getCurrentGame.bind(this)
}
this.FeaturedGames = {
getFeaturedGames: this.getFeaturedGames.bind(this),
get: this.getFeaturedGames.bind(this)
}
this.Game = {
getRecentGames: this.getRecentGames.bind(this),
get: this.getRecentGames.bind(this)
}
this.League = {
getLeagues: this.getLeagues.bind(this),
get: this.getLeagues.bind(this),
getLeagueEntries: this.getLeagueEntries.bind(this),
getEntries: this.getLeagueEntries.bind(this),
getChallengers: this.getChallengers.bind(this),
challengers: this.getChallengers.bind(this),
getMasters: this.getMasters.bind(this),
masters: this.getMasters.bind(this)
}
this.Static = {

@@ -85,2 +128,54 @@ getChampions: this.getChampionList.bind(this),

}
this.Status = {
getShardStatus: this.getShardStatus.bind(this),
getStatus: this.getShardStatus.bind(this),
get: this.getShardStatus.bind(this),
getShardList: this.getShardList.bind(this),
getShards: this.getShardList.bind(this),
getAll: this.getShardList.bind(this)
}
this.Match = {
getMatch: this.getMatch.bind(this),
get: this.getMatch.bind(this)
}
this.MatchList = {
getMatchList: this.getMatchList.bind(this),
get: this.getMatchList.bind(this)
}
this.RunesMasteries = {
getRunes: this.getRunes.bind(this),
runes: this.getRunes.bind(this),
getMasteries: this.getMasteries.bind(this),
masteries: this.getMasteries.bind(this)
}
this.Stats = {
getRankedStats: this.getRankedStats.bind(this),
ranked: this.getRankedStats.bind(this),
getStatsSummary: this.getStatsSummary.bind(this),
summary: this.getStatsSummary.bind(this)
}
this.Summoner = {
getSummoners: this.getSummoners.bind(this),
getAll: this.getSummoners.bind(this),
getSummoner: this.getSummoner.bind(this),
get: this.getSummoner.bind(this),
getSummonerNames: this.getSummonerNames.bind(this),
getNames: this.getSummonerNames.bind(this),
names: this.getSummonerNames.bind(this),
getSummonerName: this.getSummonerName.bind(this),
getName: this.getSummonerName.bind(this),
name: this.getSummonerName.bind(this)
}
}

@@ -87,0 +182,0 @@

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc