import { TokenInterface } from '../types/token'; interface PersonalisedTokenData { id: string; accessLicenceId: string; emailAddress: string; creationDateTime: string; externalUserId?: string; } /** Class representing a PersonalisedToken. */ export class PersonalisedToken implements TokenInterface { public emailAddress: string; public accessLicenceId: string; public creationDateTime: string; public id: string; public externalUserId?: string; constructor(tokenData: PersonalisedTokenData) { this.id = tokenData.id; this.accessLicenceId = tokenData.accessLicenceId; this.emailAddress = tokenData.emailAddress; this.creationDateTime = tokenData.creationDateTime; this.externalUserId = tokenData.externalUserId; } /** * Is this redeemable token still valid. * @returns true|false */ public isValid(): boolean { // A personalised token, by virtue of existing, is valid all the time // otherwise it doesn’t exist return true; } /** * Is the redeemable token for the provided email address. * @param email - the email address to match against * @returns true|false */ public matchesEmail(email: string): boolean { return email.trim().toLowerCase() === this.emailAddress.toLowerCase(); } }