Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var apiKey = "76refeysxx9xxhdk65hast4vdu9c99nt";
- /**
- * Return data for datasheed, contains name, realm and average equiped ilvl
- *
- * @return Array
- */
- function getMembers() {
- var cache = CacheService.getDocumentCache();
- var array = [];
- try {
- var guildJSON = UrlFetchApp.fetch("https://eu.api.battle.net/wow/guild/Drak'thul/Goodbye%20Kitty?fields=members&locale=en_GB&apikey=" + apiKey);
- if (guildJSON.getResponseCode() === 200) {
- guild = JSON.parse(guildJSON.getContentText());
- for(var i = 1; i < Object.keys(guild).length; i++)
- {
- if(guild.members[i].rank === 8)
- {
- }
- var toonName = guild.members[i].character.name;
- var toonRealm = guild.members[i].character.realm;
- var charIlvl = getCharIlvl(toonName, toonRealm);
- array[i] = [toonName, toonRealm, charIlvl];
- }
- }
- } catch (err) {
- if (err) {
- throw err;
- }
- Utilities.sleep((Math.pow(2,n)*1000) + (Math.round(Math.random() * 1000)));
- }
- return array;
- }
- /**
- * Gets char average equiped ilvl
- *
- * @param string toonName
- * @param string toonRealm
- *
- * @return double
- */
- function getCharIlvl(toonName, toonRealm)
- {
- try {
- var charJson = UrlFetchApp.fetch("https://eu.api.battle.net/wow/character/" + toonRealm + "/" + toonName + "?fields=items&locale=en_GB&apikey=" + apiKey);
- if (charJson.getResponseCode() === 200) {
- char = JSON.parse(charJson.getContentText());
- return char.items.averageItemLevelEquipped;
- }
- } catch (err) {
- if (err) {
- throw err;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement