UNPKG

lol-js

Version:

Node.js bindings for the Riot API, with caching and rate limiting

61 lines (55 loc) 1.93 kB
// Generated by CoffeeScript 1.9.2 (function() { var api, ld, promiseToCb; ld = require('lodash'); promiseToCb = require('../utils').promiseToCb; api = exports.api = { fullname: "matchhistory-v2.2", name: "matchhistory", version: "v2.2" }; exports.methods = { getMatchHistoryForSummonerAsync: function(summonerId, options) { var cacheParams, queryParams, ref, region, requestParams, toCacheParam; if (options == null) { options = {}; } options = ld.defaults({}, options, { region: this.defaultRegion, championIds: null, rankedQueues: ['RANKED_SOLO_5x5', 'RANKED_TEAM_3x3', 'RANKED_TEAM_5x5'], beginIndex: 0, endIndex: 15 }); region = (ref = options.region) != null ? ref : this.defaultRegion; queryParams = { championIds: options.championIds, rankedQueues: (options.rankedQueues || []).join(","), beginIndex: options.beginIndex, endIndex: options.endIndex }; requestParams = { caller: "getMatchHistoryForSummoner", region: region, url: (this._makeUrl(region, api)) + "/" + summonerId, queryParams: queryParams }; toCacheParam = function(arr) { return arr != null ? arr.sort().join(',') : void 0; }; cacheParams = { key: (api.fullname + "-matchhistory-" + region + "-" + summonerId + "-") + ((toCacheParam(options.championIds)) + "-" + (toCacheParam(options.rankedQueues)) + "-" + options.beginIndex + "-" + options.endIndex), region: region, api: api, ttl: this.cacheTTL.short, objectType: 'matchhistory', params: ld.merge({ summonerId: summonerId }, queryParams, { rankedQueues: options.rankedQueues || [] }) }; return this._riotRequestWithCache(requestParams, cacheParams); } }; }).call(this);