/** * Represents the status of a saved bank account. */ export enum BankAccountStatus { /** Bank account is pending */ PENDING = 'PENDING', /** Bank account is active */ ACTIVE = 'ACTIVE', /** Bank account is inactive */ INACTIVE = 'INACTIVE', } /** * Creates a BankAccountStatus from a string value * @param statusString The status string to convert * @returns The corresponding BankAccountStatus, or undefined if no match found */ export function bankAccountStatusFromString( statusString: string ): BankAccountStatus | undefined { const upperStatus = statusString.toUpperCase(); return Object.values(BankAccountStatus).find( (status) => status === upperStatus ); } /** * Converts a BankAccountStatus to its JSON representation * @param status The status to convert * @returns The status string value */ export function bankAccountStatusToJson(status: BankAccountStatus): string { return status; } /** * Creates a BankAccountStatus from JSON * @param json The JSON string to parse * @returns The parsed BankAccountStatus */ export function bankAccountStatusFromJson(json: any): BankAccountStatus { if (typeof json === 'string') { const status = bankAccountStatusFromString(json); if (status) { return status; } } throw new Error(`Invalid BankAccountStatus: ${json}`); }