import { TokenInterface } from '../types/token'; const VALID_TOKEN = 'AVAILABLE'; const SINGLE_USE_TOKEN = 'SINGLE_USE'; /** Class representing a RedeemableToken. */ export class RedeemableToken implements TokenInterface { public id?: string; public creationDateTime?: string; public accessDuration?: string | null; public accessLicenceId?: string; public type?: string; public status?: string; public validUntil?: string | null; public redeemability?: string; constructor(tokenData?: Partial) { if (tokenData) { Object.assign(this, tokenData); } } /** * Is this redeemable token still valid. * @returns true|false */ public isValid(): boolean { return (this.status || '').toUpperCase() === VALID_TOKEN; } /** * Is this a single use redeemable token. * @returns true|false */ public isSingleUseToken(): boolean { return (this.redeemability || '').toUpperCase() === SINGLE_USE_TOKEN; } }