lol-js
Version:
Node.js bindings for the Riot API, with caching and rate limiting
56 lines (49 loc) • 1.91 kB
JavaScript
// Generated by CoffeeScript 1.9.2
(function() {
var api, arrayToList, ld, paramsToCacheKey, pb, ref;
ld = require('lodash');
pb = require('promise-breaker');
ref = require('../utils'), arrayToList = ref.arrayToList, paramsToCacheKey = ref.paramsToCacheKey;
api = exports.api = {
fullname: "matchlist-v2.2",
name: "matchlist",
version: "v2.2"
};
exports.methods = {
getMatchlistBySummoner: pb["break"](function(region, summonerId, options) {
var cacheParams, queryParams, ref1, ref2, ref3, requestParams, toCacheParam;
if (options == null) {
options = {};
}
queryParams = {
championIds: arrayToList(options.championIds),
rankedQueues: arrayToList((ref1 = options.rankedQueues) != null ? ref1 : ['RANKED_SOLO_5x5', 'RANKED_TEAM_3x3', 'RANKED_TEAM_5x5', 'TEAM_BUILDER_DRAFT_RANKED_5x5']),
seasons: arrayToList(options.seasons),
beginIndex: options.beginIndex,
endIndex: options.endIndex,
beginTime: (ref2 = options.beginTime) != null ? ref2.valueOf() : void 0,
endTime: (ref3 = options.endTime) != null ? ref3.valueOf() : void 0
};
requestParams = {
caller: "getMatchListForSummoner",
region: region,
url: (this._makeUrl(region, api)) + "/by-summoner/" + summonerId,
queryParams: queryParams
};
toCacheParam = function(arr) {
return arr != null ? arr.sort().join(',') : void 0;
};
cacheParams = {
key: (api.fullname + "-matchlist-" + region + "-" + summonerId + "-") + paramsToCacheKey(queryParams),
region: region,
api: api,
ttl: this.cacheTTL.short,
objectType: 'matchhistory',
params: ld.merge({
summonerId: summonerId
}, queryParams)
};
return this._riotRequestWithCache(requestParams, cacheParams);
})
};
}).call(this);