UNPKG

sprcl

Version:

Simple API client for Clash of Clans, Clash Royale, and Brawl Stars

69 lines (63 loc) 1.57 kB
class ClanMember { constructor(tag, name, nameColor, role, trophies, icon) { this.tag = tag; this.name = name; this.nameColor = nameColor; this.role = role; this.trophies = trophies; this.icon = icon; } static fromJSON(jsonObject) { return new ClanMember( jsonObject.tag, jsonObject.name, jsonObject.nameColor, jsonObject.role, jsonObject.trophies, jsonObject.icon ); } toString() { return this.name; } } class Clan { constructor( tag, name, description, type, badgeId, requiredTrophies, trophies, memberCount, memberList ) { this.tag = tag; this.name = name; this.description = description; this.type = type; this.badgeId = badgeId; this.requiredTrophies = requiredTrophies; this.trophies = trophies; this.members = memberCount; this.memberList = memberList; } static fromJSON(jsonObject) { return new Clan( jsonObject.tag, jsonObject.name, jsonObject.description, jsonObject.type, jsonObject.badgeId, jsonObject.requiredTrophies, jsonObject.trophies, jsonObject.members, jsonObject.memberList?.map(ClanMember.fromJSON) || [] ); } toString() { return this.name; } } module.exports = { Clan };