import { AccessToken, priviledges } from './AccessToken';

export enum Role {
  Rtm_User = 1,
}

export class RtmTokenBuilder {
  /**
   * Build RTM token
   * @param appID - The App ID issued to you by Agora.
   * @param appCertificate - Certificate of the application that you registered in the Agora Dashboard.
   * @param account - The user account.
   * @param role - User role
   * @param privilegeExpiredTs - represented by the number of seconds elapsed since 1/1/1970.
   * @returns token
   */
  public static buildToken(appID: string, appCertificate: string, account: string, role: Role, privilegeExpiredTs: number): string {
    const key = new AccessToken(appID, appCertificate, account, '');
    key.addPriviledge(priviledges.kRtmLogin, privilegeExpiredTs);
    return key.build();
  }
}
