export enum DiscountType { AMOUNT = 'amount', PERCENTAGE = 'percentage', } export function discountTypeFromJson(json: string): DiscountType { switch (json) { case 'amount': return DiscountType.AMOUNT; case 'percentage': return DiscountType.PERCENTAGE; default: throw new Error(`Unsupported DiscountType JSON value: ${json}`); } } export function discountTypeToJson(type: DiscountType): string { return type; }