UNPKG

supercell-coc

Version:

This is an API for Supercell's game [Clash of Clans](https://clashofclans.com) implemented into Node.JS by z3db0y.

556 lines (554 loc) 21.9 kB
function purgeUndefined(obj) { for (var prop in obj) { if (obj.hasOwnProperty(prop) && obj[prop] === undefined) { delete obj[prop]; } } return obj; } module.exports = { WarLeagueList: class extends Array { constructor(...args) { super(...args); if(!args.every(arg => arg instanceof module.exports.WarLeague)) throw new Error('Invalid argument type'); purgeUndefined(this); Object.freeze(this); } }, WarLeague: class { constructor(name, id) { this.name = name; this.id = id; purgeUndefined(this); Object.freeze(this); } }, ServiceVersion: class { constructor(major, minor, content) { this.major = major; this.minor = minor; this.content = content; purgeUndefined(this); Object.freeze(this); } }, LabelList: class extends Array { constructor(...args) { super(...args); if(!args.every(arg => arg instanceof module.exports.Label)) throw new Error('Invalid argument type'); purgeUndefined(this); Object.freeze(this); } }, Label: class { constructor(name, id, iconUrls) { this.name = name; this.id = id; this.iconUrls = iconUrls; purgeUndefined(this); Object.freeze(this); } }, Location: class { constructor(localizedName, id, name, isCountry, countryCode) { this.localizedName = localizedName; this.id = id; this.name = name; this.isCountry = isCountry; this.countryCode = countryCode; purgeUndefined(this); Object.freeze(this); } }, Replay: class { constructor(replayData, replayTag) { this.replayData = replayData; this.replayTag = replayTag; purgeUndefined(this); Object.freeze(this); } }, WarStatusList: class extends Array { constructor(...args) { super(...args); if(!args.every(arg => arg instanceof module.exports.WarStatus)) throw new Error('Invalid argument type'); purgeUndefined(this); Object.freeze(this); } }, WarStatus: class { constructor(statusCode, clanTag, enemyClanTag, warState, timestamp) { this.statusCode = statusCode; this.clanTag = clanTag; this.enemyClanTag = enemyClanTag; this.warState = warState; this.timestamp = timestamp; purgeUndefined(this); Object.freeze(this); } }, LocationList: class extends Array { constructor(...args) { super(...args); if(!args.every(arg => arg instanceof module.exports.Location)) throw new Error('Invalid argument type'); purgeUndefined(this); Object.freeze(this); } }, ClanMemberList: class extends Array { constructor(...args) { super(...args); if(!args.every(arg => arg instanceof module.exports.ClanMember)) throw new Error('Invalid argument type'); purgeUndefined(this); Object.freeze(this); } }, ClanMember: class { constructor(league, tag, name, role, expLevel, clanRank, previousClanRank, donations, donationsReceived, trophies, versusTrophies) { this.league = league; this.tag = tag; this.name = name; this.role = role; this.expLevel = expLevel; this.clanRank = clanRank; this.previousClanRank = previousClanRank; this.donations = donations; this.donationsReceived = donationsReceived; this.trophies = trophies; this.versusTrophies = versusTrophies; purgeUndefined(this); Object.freeze(this); } }, League: class { constructor(name, id, iconUrls) { this.name = name; this.id = id; this.iconUrls = iconUrls; purgeUndefined(this); Object.freeze(this); } }, LeagueSeasonList: class extends Array { constructor(...args) { super(...args); if(!args.every(arg => arg instanceof module.exports.LeagueSeason)) throw new Error('Invalid argument type'); purgeUndefined(this); Object.freeze(this); } }, LeagueSeason: class { constructor(id) { this.id = id; purgeUndefined(this); Object.freeze(this); } }, PlayerVersusRankingList: class extends Array { constructor(...args) { super(...args); if(!args.every(arg => arg instanceof module.exports.PlayerVersusRanking)) throw new Error('Invalid argument type'); purgeUndefined(this); Object.freeze(this); } }, PlayerVersusRanking: class { constructor(clan, versusBattleWins, tag, name, expLevel, rank, previousRank, versusTrophies) { this.clan = clan; this.versusBattleWins = versusBattleWins; this.tag = tag; this.name = name; this.expLevel = expLevel; this.rank = rank; this.previousRank = previousRank; this.versusTrophies = versusTrophies; purgeUndefined(this); Object.freeze(this); } }, PlayerRankingClan: class { constructor(tag, name, badgeUrls) { this.tag = tag; this.name = name; this.badgeUrls = badgeUrls; purgeUndefined(this); Object.freeze(this); } }, VerifyTokenRequest: class { constructor(token) { this.token = token; purgeUndefined(this); Object.freeze(this); } }, VerifyTokenResponse: class { constructor(tag, token, status) { this.tag = tag; this.token = token; this.status = status; purgeUndefined(this); Object.freeze(this); } }, Clan: class { constructor(memberList, warLeague, tag, warWinStreak, clanVersusPoints, requiredTrophies, requiredVersusTrophies, requiredTownhallLevel, isWarLogPublic, warWins, clanLevel, warFrequency, warTies, warLosses, clanPoints, chatLanguage, labels, name, location, type, members, description, badgeUrls) { this.memberList = memberList; this.warLeague = warLeague; this.warWinStreak = warWinStreak; this.tag = tag; this.clanVersusPoints = clanVersusPoints; this.requiredTrophies = requiredTrophies; this.requiredVersusTrophies = requiredVersusTrophies; this.requiredTownhallLevel = requiredTownhallLevel; this.isWarLogPublic = isWarLogPublic; this.warWins = warWins; this.clanLevel = clanLevel; this.warFrequency = warFrequency; this.warTies = warTies; this.warLosses = warLosses; this.clanPoints = clanPoints; this.chatLanguage = chatLanguage; this.labels = labels; this.name = name; this.location = location; this.type = type; this.members = members; this.description = description; this.badgeUrls = badgeUrls; purgeUndefined(this); Object.freeze(this); } }, Language: class { constructor(name, id, languageCode) { this.name = name; this.id = id; this.languageCode = languageCode; purgeUndefined(this); Object.freeze(this); } }, ClanWar: class { constructor(clan, teamSize, attacksPerMember, opponent, startTime, state, endTime, preparationStartTime) { this.clan = clan; this.teamSize = teamSize; this.attacksPerMember = attacksPerMember; this.opponent = opponent; this.startTime = startTime; this.state = state; this.endTime = endTime; this.preparationStartTime = preparationStartTime; purgeUndefined(this); Object.freeze(this); } }, WarClan: class { constructor(destructionPercentage, tag, name, badgeUrls, clanLevel, attacks, stars, expEarned, members) { this.destructionPercentage = destructionPercentage; this.tag = tag; this.name = name; this.badgeUrls = badgeUrls; this.clanLevel = clanLevel; this.attacks = attacks; this.stars = stars; this.expEarned = expEarned; this.members = members; purgeUndefined(this); Object.freeze(this); } }, ClanWarMemberList: class extends Array { constructor(...args) { super(...args); if(!args.every(arg => arg instanceof module.exports.ClanWarMember)) throw new Error('Invalid argument type'); purgeUndefined(this); Object.freeze(this); } }, ClanWarMember: class { constructor(tag, name, mapPosition, townhallLevel, opponentAttacks, bestOpponentAttack, attacks) { this.tag = tag; this.name = name; this.mapPosition = mapPosition; this.townhallLevel = townhallLevel; this.opponentAttacks = opponentAttacks; this.bestOpponentAttack = bestOpponentAttack; this.attacks = attacks; purgeUndefined(this); Object.freeze(this); } }, ClanWarAttackList: class extends Array { constructor(...args) { super(...args); if(!args.every(arg => arg instanceof module.exports.ClanWarAttack)) throw new Error('Invalid argument type'); purgeUndefined(this); Object.freeze(this); } }, ClanWarAttack: class { constructor(order, attackerTag, defenderTag, stars, destructionPercentage, duration) { this.order = order; this.attackerTag = attackerTag; this.defenderTag = defenderTag; this.stars = stars; this.destructionPercentage = destructionPercentage; this.duration = duration; purgeUndefined(this); Object.freeze(this); } }, ClanList: class extends Array { constructor(...args) { super(...args); if(!args.every(arg => arg instanceof module.exports.Clan)) throw new Error('Invalid argument type'); purgeUndefined(this); Object.freeze(this); } }, ClanVersusRankingList: class extends Array { constructor(...args) { super(...args); if(!args.every(arg => arg instanceof module.exports.ClanVersusRanking)) throw new Error('Invalid argument type'); purgeUndefined(this); Object.freeze(this); } }, ClanVersusRanking: class { constructor(tag, name, location, badgeUrls, clanLevel, members, rank, previousRank, clanVersusPoints) { this.tag = tag; this.name = name; this.location = location; this.badgeUrls = badgeUrls; this.clanLevel = clanLevel; this.members = members; this.rank = rank; this.previousRank = previousRank; this.clanVersusPoints = clanVersusPoints; purgeUndefined(this); Object.freeze(this); } }, PlayerRankingList: class extends Array { constructor(...args) { super(...args); if(!args.every(arg => arg instanceof module.exports.PlayerRanking)) throw new Error('Invalid argument type'); purgeUndefined(this); Object.freeze(this); } }, PlayerRanking: class { constructor(clan, league, defenseWins, attackWins, tag, name, expLevel, rank, previousRank, trophies) { this.clan = clan; this.league = league; this.defenseWins = defenseWins; this.attackWins = attackWins; this.tag = tag; this.name = name; this.expLevel = expLevel; this.rank = rank; this.previousRank = previousRank; this.trophies = trophies; purgeUndefined(this); Object.freeze(this); } }, LeagueList: class extends Array { constructor(...args) { super(...args); if(!args.every(arg => arg instanceof module.exports.League)) throw new Error('Invalid argument type'); purgeUndefined(this); Object.freeze(this); } }, ClanWarLog: class extends Array { constructor(...args) { super(...args); if(!args.every(arg => arg instanceof module.exports.ClanWarLogEntry)) throw new Error('Invalid argument type'); purgeUndefined(this); Object.freeze(this); } }, ClanWarLogEntry: class { constructor(clan, teamSize, attacksPerMember, opponent, endTime, result) { this.clan = clan; this.teamSize = teamSize; this.attacksPerMember = attacksPerMember; this.opponent = opponent; this.endTime = endTime; this.result = result; purgeUndefined(this); Object.freeze(this); } }, GoldPassSeason: class { constructor(startTime, endTime) { this.startTime = startTime; this.endTime = endTime; purgeUndefined(this); Object.freeze(this); } }, DeepLinkCreationRequest: class { constructor(playerTags, clanTag, opponentClanTag) { this.playerTags = playerTags; this.clanTag = clanTag; this.opponentClanTag = opponentClanTag; purgeUndefined(this); Object.freeze(this); } }, DeepLinkCreationResponse: class { constructor(link) { this.link = link; purgeUndefined(this); Object.freeze(this); } }, ClanWarLeagueGroup: class { constructor(tag, state, season, clans, rounds) { this.tag = tag; this.state = state; this.season = season; this.clans = clans; this.rounds = rounds; purgeUndefined(this); Object.freeze(this); } }, ClanWarLeagueRoundList: class extends Array { constructor(...args) { super(...args); if(!args.every(arg => arg instanceof module.exports.ClanWarLeagueRound)) throw new Error('Invalid argument type'); purgeUndefined(this); Object.freeze(this); } }, ClanWarLeagueRound: class { constructor(warTags) { this.warTags = warTags; purgeUndefined(this); Object.freeze(this); } }, ClanWarLeagueClanList: class extends Array { constructor(...args) { super(...args); if(!args.every(arg => arg instanceof module.exports.ClanWarLeagueClan)) throw new Error('Invalid argument type'); purgeUndefined(this); Object.freeze(this); } }, ClanWarLeagueClan: class { constructor(tag, clanLevel, name, members, badgeUrls) { this.tag = tag; this.clanLevel = clanLevel; this.name = name; this.members = members; this.badgeUrls = badgeUrls; purgeUndefined(this); Object.freeze(this); } }, ClanWarLeagueClanMemberList: class extends Array { constructor(...args) { super(...args); if(!args.every(arg => arg instanceof module.exports.ClanWarLeagueClanMember)) throw new Error('Invalid argument type'); purgeUndefined(this); Object.freeze(this); } }, ClanWarLeagueClanMember: class { constructor(tag, townHallLevel, name) { this.tag = tag; this.townHallLevel = townHallLevel; this.name = name; purgeUndefined(this); Object.freeze(this); } }, ClanRankingList: class extends Array { constructor(...args) { super(...args); if(!args.every(arg => arg instanceof module.exports.ClanRanking)) throw new Error('Invalid argument type'); purgeUndefined(this); Object.freeze(this); } }, ClanRanking: class { constructor(clanPoints, clanLevel, location, members, tag, name, rank, previousRank, badgeUrls) { this.clanPoints = clanPoints; this.clanLevel = clanLevel; this.location = location; this.members = members; this.tag = tag; this.name = name; this.rank = rank; this.previousRank = previousRank; this.badgeUrls = badgeUrls; purgeUndefined(this); Object.freeze(this); } }, Player: class { constructor(clan, league, townHallLevel, townHallWeaponLevel, versusBattleWins, legendStatistics, troops, heroes, spells, role, warPreference, attackWins, defenseWins, labels, tag, name, expLevel, trophies, bestTrophies, donations, donationsReceived, builderHallLevel, versusTrophies, bestVersusTrophies, warStars, achievements, versusBattleWinCount) { this.clan = clan; this.league = league; this.townHallLevel = townHallLevel; this.townHallWeaponLevel = townHallWeaponLevel; this.versusBattleWins = versusBattleWins; this.legendStatistics = legendStatistics; this.troops = troops; this.heroes = heroes; this.spells = spells; this.role = role; this.warPreference = warPreference; this.attackWins = attackWins; this.defenseWins = defenseWins; this.labels = labels; this.tag = tag; this.name = name; this.expLevel = expLevel; this.trophies = trophies; this.bestTrophies = bestTrophies; this.donations = donations; this.donationsReceived = donationsReceived; this.builderHallLevel = builderHallLevel; this.versusTrophies = versusTrophies; this.bestVersusTrophies = bestVersusTrophies; this.warStars = warStars; this.achievements = achievements; this.versusBattleWinCount = versusBattleWinCount; purgeUndefined(this); Object.freeze(this); } }, PlayerAchievementProgressList: class extends Array { constructor(...args) { super(...args); if(!args.every(arg => arg instanceof module.exports.PlayerAchievementProgress)) throw new Error('Invalid argument type'); purgeUndefined(this); Object.freeze(this); } }, PlayerAchievementProgress: class { constructor(stars, value, name, target, info, completionInfo, village) { this.stars = stars; this.value = value; this.name = name; this.target = target; this.info = info; this.completionInfo = completionInfo; this.village = village; purgeUndefined(this); Object.freeze(this); } }, PlayerItemLevelList: class extends Array { constructor(...args) { super(...args); if(!args.every(arg => arg instanceof module.exports.PlayerItemLevel)) throw new Error('Invalid argument type'); purgeUndefined(this); Object.freeze(this); } }, PlayerItemLevel: class { constructor(level, name, maxLevel, village, superTroopIsActive) { this.level = level; this.name = name; this.maxLevel = maxLevel; this.village = village; this.superTroopIsActive = superTroopIsActive; purgeUndefined(this); Object.freeze(this); } }, PlayerLegendStatistics: class { constructor(bestSeason, currentSeason, previousSeason, previousVersusSeason, bestVersusSeason, legendTrophies) { this.bestSeason = bestSeason; this.currentSeason = currentSeason; this.previousSeason = previousSeason; this.previousVersusSeason = previousVersusSeason; this.bestVersusSeason = bestVersusSeason; this.legendTrophies = legendTrophies; purgeUndefined(this); Object.freeze(this); } }, LegendLeagueTournamentSeasonResult: class { constructor(trophies, id, rank) { this.trophies = trophies; this.id = id; this.rank = rank; purgeUndefined(this); Object.freeze(this); } }, PlayerClan: class { constructor(tag, clanLevel, name, badgeUrls) { this.tag = tag; this.clanLevel = clanLevel; this.name = name; this.badgeUrls = badgeUrls; purgeUndefined(this); Object.freeze(this); } }, ClientError: class { constructor(reason, message, type, detail) { this.reason = reason; this.message = message; this.type = type; this.detail = detail; purgeUndefined(this); Object.freeze(this); } } } for(let key in module.exports) { Object.freeze(module.exports[key]); }