export enum IntentStatus { Processed = 'PROCESSED', UnProcessed = 'UNPROCESSED', TimeExpired = 'TIME_EXPIRED', Closed = 'CLOSED', } type IntentStatusType = | 'PROCESSED' | 'processed' | 'UNPROCESSED' | 'unprocessed' | 'TIME_EXPIRED' | 'timeExpired' | 'CLOSED' | 'closed'; export function intentStatusFromJson(json: IntentStatusType): IntentStatus { const _jsonMap: Record = { PROCESSED: IntentStatus.Processed, processed: IntentStatus.Processed, UNPROCESSED: IntentStatus.UnProcessed, unprocessed: IntentStatus.UnProcessed, TIME_EXPIRED: IntentStatus.TimeExpired, timeExpired: IntentStatus.TimeExpired, CLOSED: IntentStatus.Closed, closed: IntentStatus.Closed, }; const status = _jsonMap[json]; if (status !== undefined) { return status; } throw new Error(`Unsupported IntentStatus JSON value: ${json}`); }