class SchoolSettings { final int portalPurchasesEnabled; final String allowedProductTypes; final String paymentMethods; final String currencyCode; final int enableNotifications; final int allowFreezeGlobal; final int freezeMaxDaysGlobal; final int autoPropagateOnPurchase; final int allowFullAccessRebooking; final List paymentMethodsArray; final List allowedProductTypesArray; const SchoolSettings({ required this.portalPurchasesEnabled, required this.allowedProductTypes, required this.paymentMethods, required this.currencyCode, required this.enableNotifications, required this.allowFreezeGlobal, required this.freezeMaxDaysGlobal, required this.autoPropagateOnPurchase, required this.allowFullAccessRebooking, required this.paymentMethodsArray, required this.allowedProductTypesArray, }); factory SchoolSettings.fromMap(Map m) { int i(dynamic v) => (v is num) ? v.toInt() : int.tryParse('$v') ?? 0; String s(dynamic v, [String def = '']) => (v ?? def).toString(); List list(dynamic v) { if (v is List) return v.map((e) => e.toString()).toList(); return []; } return SchoolSettings( portalPurchasesEnabled: i(m['portal_purchases_enabled']), allowedProductTypes: s(m['allowed_product_types']), paymentMethods: s(m['payment_methods']), currencyCode: s(m['currency_code'], 'EUR'), enableNotifications: i(m['enable_notifications']), allowFreezeGlobal: i(m['allow_freeze_global']), freezeMaxDaysGlobal: i(m['freeze_max_days_global']), autoPropagateOnPurchase: i(m['auto_propagate_on_purchase']), allowFullAccessRebooking: i(m['allow_full_access_rebooking']), paymentMethodsArray: list(m['payment_methods_array']), allowedProductTypesArray: list(m['allowed_product_types_array']), ); } Map toMap() => { 'portal_purchases_enabled': portalPurchasesEnabled, 'allowed_product_types': allowedProductTypes, 'payment_methods': paymentMethods, 'currency_code': currencyCode, 'enable_notifications': enableNotifications, 'allow_freeze_global': allowFreezeGlobal, 'freeze_max_days_global': freezeMaxDaysGlobal, 'auto_propagate_on_purchase': autoPropagateOnPurchase, 'allow_full_access_rebooking': allowFullAccessRebooking, 'payment_methods_array': paymentMethodsArray, 'allowed_product_types_array': allowedProductTypesArray, }; }