LeagueStats/server/providers/Jax/src/Jax.js
Valentin Kaelin 8f19e570b7 refactor: start using Cdragon instead of DDragon
Done Endpoints: Items and Perks
2019-11-23 17:34:34 +01:00

58 lines
2 KiB
JavaScript

const RiotRateLimiter = require('riot-ratelimiter')
const LeagueEndpoint = require('./Endpoints/LeagueEndpoint')
const MatchEndpoint = require('./Endpoints/MatchEndpoint')
const MatchlistEndpoint = require('./Endpoints/MatchlistEndpoint')
const SpectatorEndpoint = require('./Endpoints/SpectatorEndpoint')
const SummonerEndpoint = require('./Endpoints/SummonerEndpoint')
const DDragonVersionEndpoint = require('./Endpoints/DDragonEndpoints/DDragonVersionEndpoint')
const DDragonChampionEndpoint = require('./Endpoints/DDragonEndpoints/DDragonChampionEndpoint')
const DDragonRuneEndpoint = require('./Endpoints/DDragonEndpoints/DDragonRuneEndpoint')
const DDragonItemEndpoint = require('./Endpoints/DDragonEndpoints/DDragonItemEndpoint')
const CDragonEndpoint = require('./Endpoints/CDragonEndpoint')
class Jax {
constructor(config) {
this.key = config.key
const limiterOptions = {
strategy: config.requestOptions.strategy
}
this.limiter = new RiotRateLimiter(limiterOptions)
this.config = config
this.League = new LeagueEndpoint(this.config, this.limiter)
this.Match = new MatchEndpoint(this.config, this.limiter)
this.Matchlist = new MatchlistEndpoint(this.config, this.limiter)
this.Spectator = new SpectatorEndpoint(this.config, this.limiter)
this.Summoner = new SummonerEndpoint(this.config, this.limiter)
this.initDDragon()
this.CDragon = new CDragonEndpoint()
}
async initDDragon() {
this.version = (await new DDragonVersionEndpoint().list())[0]
this.DDragon = {
Champion: new DDragonChampionEndpoint(this.version),
Item: new DDragonItemEndpoint(this.version),
Rune: new DDragonRuneEndpoint(this.version),
Version: this.version
}
}
set regionName(regionName) {
this.config.region = regionName
const blacklistedProperties = ['key', 'limiter', 'config', 'version', 'DDragon']
for (const key of Object.getOwnPropertyNames(this)) {
if(blacklistedProperties.includes(key)) continue
this[key].region = regionName
}
}
}
module.exports = Jax