trailpack-leagueoflegends
v0.3.0
Published
Add a Trails service to get data from League Of Legends API.
Downloads
21
Maintainers
Readme
trailpack-leagueoflegends
:package: Add a Trails service to get data from League Of Legends API.
Install
With yeoman :
npm install -g yo generator-trails
yo trails:trailpack trailpack-leagueoflegends
With npm (you will have to create config file manually) :
$ npm install --save trailpack-leagueoflegends
Configuration
Enable SrcdsRcon
// config/main.js
module.exports = {
packs: [
// ... other trailpacks
require('trailpack-leagueoflegends')
]
}
Check that leagueoflegends config is loaded on index.js
// config/index.js
...
exports.srcds = require('./leagueoflegends')
Configure
// config/leagueoflegends.js
module.exports = {
// Your Riot Games Api must me set here
apiKey: 'your-league-api-key-here'
}
Usage
/**
* Example of calls possible
* First Parameter is the Api Name, the seconde is method name and the third one contrains parameters needed
* return a Promise that contains the api datas
*/
this.app.services.LeagueOfLegendsService.get('champion', 'getChampions', { region: 'euw' }).then(data => {
console.log(data);
});
// Example for Get Current Summoner Elo
let summonerName = 'WarkAngel'
this.app.services.LeagueOfLegendsService.get('summoner', 'getSummonersByName', { region: 'euw', summonerNames: summonerName }).then(data => {
this.app.services.LeagueOfLegendsService.get('league', 'getLeagueBySummoner', { region: 'euw', summonerIds: data[summonerName.toLowerCase()].id }).then(league =>{
console.log(league);
});
});
Methods and API Available
All methods are available, see method Reference for more information about how to use.