Skip to content

Commit

Permalink
Update for TFT, remove v3
Browse files Browse the repository at this point in the history
  • Loading branch information
MingweiSamuel committed Oct 31, 2019
1 parent f083f1a commit bde8cfb
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ There are three more premade configurations provided:
is the same as `TeemoJS.defaultConfig` but without any `endpoints`.
- [`TeemoJS.championGGConfig`](https://github.com/MingweiSamuel/TeemoJS/blob/master/championGGConfig.json)
is a configuration for the [Champion.GG API](http://api.champion.gg/). Oh, by the way, TeemoJS also supports the Champion.GG API.
- [`TeemoJS.defaultV3Config`](https://github.com/MingweiSamuel/TeemoJS/blob/master/defaultV3Config.json)
for old V3 endpoints being removed at the end of January 2019.
- (`TeemoJS.ddragonConfig` TODO)

Champion.GG Example:
Expand Down
18 changes: 18 additions & 0 deletions defaultConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,24 @@
"getByPUUID": "/lol/summoner/v4/summoners/by-puuid/%s",
"getBySummonerId": "/lol/summoner/v4/summoners/%s"
},
"tftLeague": {
"getChallengerLeague": "/tft/league/v1/challenger",
"getLeagueEntriesForSummoner": "/tft/league/v1/entries/by-summoner/%s",
"getLeagueEntries": "/tft/league/v1/entries/%s/%s",
"getGrandmasterLeague": "/tft/league/v1/grandmaster",
"getLeagueById": "/tft/league/v1/leagues/%s",
"getMasterLeague": "/tft/league/v1/master"
},
"tftMatch": {
"getMatchIdsByPUUID": "/tft/match/v1/matches/by-puuid/%s/ids",
"getMatch": "/tft/match/v1/matches/%s"
},
"tftSummoner": {
"getByAccountId": "/tft/summoner/v1/summoners/by-account/%s",
"getBySummonerName": "/tft/summoner/v1/summoners/by-name/%s",
"getByPUUID": "/tft/summoner/v1/summoners/by-puuid/%s",
"getBySummonerId": "/tft/summoner/v1/summoners/%s"
},
"thirdPartyCode": {
"getThirdPartyCodeBySummonerId": "/lol/platform/v4/third-party-code/by-summoner/%s"
}
Expand Down
13 changes: 3 additions & 10 deletions gen.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ const fs = Promise.promisifyAll(require("fs"));
const { JSDOM } = require("jsdom");

let defaultConfig = require('./emptyConfig.json');
let defaultV3Config = JSON.parse(JSON.stringify(defaultConfig));

req('https://developer.riotgames.com/api-methods/')
.then(body => {
Expand All @@ -25,8 +24,7 @@ req('https://developer.riotgames.com/api-methods/')
return Promise.props(endpoints);
})
.then(endpoints => {
let resV4 = {};
let resV3 = {};
let res = {};
for (let [name, body] of Object.entries(endpoints)) {
let camelName = '';
let tokens = name.split('-');
Expand All @@ -37,10 +35,7 @@ req('https://developer.riotgames.com/api-methods/')
console.log(camelName);

let endpoint = {};
if ('v3' === version) {
resV3[camelName] = endpoint;
}
resV4[camelName] = endpoint;
res[camelName] = endpoint;

let data = JSON.parse(body);
let dom = new JSDOM(data.html);
Expand All @@ -53,11 +48,9 @@ req('https://developer.riotgames.com/api-methods/')
endpoint[opName] = path;
}
}
defaultConfig.endpoints = resV4;
defaultV3Config.endpoints = resV3;
defaultConfig.endpoints = res;
return Promise.all([
fs.writeFileAsync('defaultConfig.json', JSON.stringify(defaultConfig, null, 2)),
fs.writeFileAsync('defaultV3Config.json', JSON.stringify(defaultV3Config, null, 2))
]);
});
// .then(res => fs.writeFileAsync('defaultConfig.json', JSON.stringify(res, null, 2)));

0 comments on commit bde8cfb

Please sign in to comment.