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