export default class Label {
/**
* Creates a new Label
*
* @constructor Label
* @param {object} labelMap - Label parameters
* @param {string} labelMap.name - Name
* @param {number} [labelMap.followersCount=0] - Amount of followers
* @param {number} [labelMap.activitiesCount=0] - Amount of activities
* @param {boolean} [labelMap.isFollowedByMe=false] - True if current user is following the label
* @param {number} [labelMap.popularity=0] - Popularity
*/
constructor(labelMap) {
this.name = labelMap.name;
this.followersCount = labelMap.followersCount || 0;
this.activitiesCount = labelMap.activitiesCount || 0;
this.isFollowedByMe = labelMap.isFollowedByMe || false;
this.popularity = labelMap.popularity || 0;
Object.freeze(this);
}
/**
* Create Label from SGLabel
*
* @memberof Label
* @param {Object} label - SGLabel
* @returns {Label} Label instance
* @ignore
*/
static create(label) {
return new Label({
...label,
isFollowedByMe: label.isFollower,
popularity: label.score
});
}
}