import { Gift } from "./Gift"; import { Message } from "./Message"; /** * The possible roles of a follower */ export enum FollowerRole { NONE = 0, FOLLOWER = 1, FRIEND = 2, } /** * The User class represents a user in the TikTok Live chat */ export class User { private userId: string; private displayName: string; private username: string; private isFollower: boolean; private isSubscriber: boolean; private messages: Message[]; private gifts: Gift[]; /** * Create a new User object * @param data { userId: string, displayName: string, username: string, isFollower: boolean, isSubscriber: boolean } */ constructor(data: { userId: string, displayName: string, username: string, isFollower: boolean, isSubscriber: boolean }) { this.userId = data.userId; this.displayName = data.displayName; this.username = data.username; this.isFollower = data.isFollower; this.isSubscriber = data.isSubscriber; this.messages = []; } /** * Get the unique identifier for the user * @returns {string} The unique identifier for the user */ public getUserId(): string { return this.userId; } /** * Get the display name for the user * @returns {string} The display name for the user */ public getDisplayName(): string { return this.displayName; } /** * Get the username for the user * @returns {string} The username for the user */ public getUsername(): string { return this.username; } /** * Get the role of the follower * @returns {FollowerRole} The role of the follower */ public getIsFollower(): boolean { return this.isFollower; } /** * Get the role of the subscriber * @returns {boolean} The role of the subscriber */ public getIsSubscriber(): boolean { return this.isSubscriber; } /** * Get the messages for the user * @returns {Message[]} The messages for the user */ public getMessages(): Message[] { return this.messages; } /** * Add a message to the user * @param {Message} message The message to add to the user */ public addMessage(message: Message): void { this.messages.push(message); } /** * Get the gifts for the user * @returns {Gift[]} The gifts for the user */ public getGifts(): Gift[] { return this.gifts; } /** * Add a gift to the user * @param {Gift} gift The gift to add to the user */ public addGift(gift: Gift): void { this.gifts.push(gift); } }