YogiBook_App/lib/models/user_settings.dart

68 lines
2.2 KiB
Dart

class UserSettings {
final int notifyEmail;
final int notifyWhatsapp;
final int notifyPush;
final int notifyBookingConfirm;
final int notifyBookingCancel;
final int notifySessionCancel;
final int notifyPaymentReceipt;
final int notifyExpirationReminder;
final int newsletterOptIn;
final int marketingOptIn;
final String locale;
final String timezone;
const UserSettings({
required this.notifyEmail,
required this.notifyWhatsapp,
required this.notifyPush,
required this.notifyBookingConfirm,
required this.notifyBookingCancel,
required this.notifySessionCancel,
required this.notifyPaymentReceipt,
required this.notifyExpirationReminder,
required this.newsletterOptIn,
required this.marketingOptIn,
required this.locale,
required this.timezone,
});
factory UserSettings.fromMap(Map<String, dynamic> m) {
int i(dynamic v) => (v is num) ? v.toInt() : int.tryParse('$v') ?? 0;
String s(dynamic v, [String def = '']) => (v ?? def).toString();
return UserSettings(
notifyEmail: i(m['notify_email']),
notifyWhatsapp: i(m['notify_whatsapp']),
notifyPush: i(m['notify_push']),
notifyBookingConfirm: i(m['notify_booking_confirm']),
notifyBookingCancel: i(m['notify_booking_cancel']),
notifySessionCancel: i(m['notify_session_cancel']),
notifyPaymentReceipt: i(m['notify_payment_receipt']),
notifyExpirationReminder: i(m['notify_expiration_reminder']),
newsletterOptIn: i(m['newsletter_opt_in']),
marketingOptIn: i(m['marketing_opt_in']),
locale: s(m['locale'], 'it'),
timezone: s(m['timezone'], 'Europe/Rome'),
);
}
Map<String, dynamic> toMap() => {
'notify_email': notifyEmail,
'notify_whatsapp': notifyWhatsapp,
'notify_push': notifyPush,
'notify_booking_confirm': notifyBookingConfirm,
'notify_booking_cancel': notifyBookingCancel,
'notify_session_cancel': notifySessionCancel,
'notify_payment_receipt': notifyPaymentReceipt,
'notify_expiration_reminder': notifyExpirationReminder,
'newsletter_opt_in': newsletterOptIn,
'marketing_opt_in': marketingOptIn,
'locale': locale,
'timezone': timezone,
};
}