// ignore_for_file: non_constant_identifier_names, camel_case_types, file_namesimport, file_names, unnecessary_null_comparison, prefer_null_aware_operators
// WARNING: This code is auto-generated by Supadart.
// WARNING: Modifications may be overwritten. Please make changes in the Supadart configuration.
import 'package:sigap/supadart/supadart_exports.dart';
import 'package:sigap/supadart/supadart_header.dart';

class UserSupadartModel implements SupadartClass<UserSupadartModel> {
  final String id;
  final String rolesId;
  final String email;
  final String? phone;
  final String? encryptedPassword;
  final DateTime? invitedAt;
  final DateTime? confirmedAt;
  final DateTime? emailConfirmedAt;
  final DateTime? recoverySentAt;
  final DateTime? lastSignInAt;
  final Map<String, dynamic>? appMetadata;
  final Map<String, dynamic>? userMetadata;
  final DateTime createdAt;
  final DateTime updatedAt;
  final DateTime? bannedUntil;
  final bool isAnonymous;
  final String? bannedReason;
  final bool isBanned;
  final int panicStrike;
  final int spoofingAttempts;
  final RoleSupadartModel? role;
  final ProfileSupadartModel? profile;

  const UserSupadartModel({
    required this.id,
    required this.rolesId,
    required this.email,
    this.phone,
    this.encryptedPassword,
    this.invitedAt,
    this.confirmedAt,
    this.emailConfirmedAt,
    this.recoverySentAt,
    this.lastSignInAt,
    this.appMetadata,
    this.userMetadata,
    required this.createdAt,
    required this.updatedAt,
    this.bannedUntil,
    required this.isAnonymous,
    this.bannedReason,
    required this.isBanned,
    required this.panicStrike,
    required this.spoofingAttempts,
    this.role,
    this.profile,
  });

  static String get table_name => 'userSupadartModel';
  static String get c_id => 'id';
  static String get c_rolesId => 'roles_id';
  static String get c_email => 'email';
  static String get c_phone => 'phone';
  static String get c_encryptedPassword => 'encrypted_password';
  static String get c_invitedAt => 'invited_at';
  static String get c_confirmedAt => 'confirmed_at';
  static String get c_emailConfirmedAt => 'email_confirmed_at';
  static String get c_recoverySentAt => 'recovery_sent_at';
  static String get c_lastSignInAt => 'last_sign_in_at';
  static String get c_appMetadata => 'app_metadata';
  static String get c_userMetadata => 'user_metadata';
  static String get c_createdAt => 'created_at';
  static String get c_updatedAt => 'updated_at';
  static String get c_bannedUntil => 'banned_until';
  static String get c_isAnonymous => 'is_anonymous';
  static String get c_bannedReason => 'banned_reason';
  static String get c_isBanned => 'is_banned';
  static String get c_panicStrike => 'panic_strike';
  static String get c_spoofingAttempts => 'spoofing_attempts';

  static List<UserSupadartModel> converter(List<Map<String, dynamic>> data) {
    return data.map(UserSupadartModel.fromJson).toList();
  }

  static UserSupadartModel converterSingle(Map<String, dynamic> data) {
    return UserSupadartModel.fromJson(data);
  }

  static Map<String, dynamic> _generateMap({
    String? id,
    String? rolesId,
    String? email,
    String? phone,
    String? encryptedPassword,
    DateTime? invitedAt,
    DateTime? confirmedAt,
    DateTime? emailConfirmedAt,
    DateTime? recoverySentAt,
    DateTime? lastSignInAt,
    Map<String, dynamic>? appMetadata,
    Map<String, dynamic>? userMetadata,
    DateTime? createdAt,
    DateTime? updatedAt,
    DateTime? bannedUntil,
    bool? isAnonymous,
    String? bannedReason,
    bool? isBanned,
    int? panicStrike,
    int? spoofingAttempts,
  }) {
    return {
      if (id != null) 'id': id,
      if (rolesId != null) 'roles_id': rolesId,
      if (email != null) 'email': email,
      if (phone != null) 'phone': phone,
      if (encryptedPassword != null) 'encrypted_password': encryptedPassword,
      if (invitedAt != null) 'invited_at': invitedAt.toUtc().toIso8601String(),
      if (confirmedAt != null)
        'confirmed_at': confirmedAt.toUtc().toIso8601String(),
      if (emailConfirmedAt != null)
        'email_confirmed_at': emailConfirmedAt.toUtc().toIso8601String(),
      if (recoverySentAt != null)
        'recovery_sent_at': recoverySentAt.toUtc().toIso8601String(),
      if (lastSignInAt != null)
        'last_sign_in_at': lastSignInAt.toUtc().toIso8601String(),
      if (appMetadata != null) 'app_metadata': appMetadata,
      if (userMetadata != null) 'user_metadata': userMetadata,
      if (createdAt != null) 'created_at': createdAt.toUtc().toIso8601String(),
      if (updatedAt != null) 'updated_at': updatedAt.toUtc().toIso8601String(),
      if (bannedUntil != null)
        'banned_until': bannedUntil.toUtc().toIso8601String(),
      if (isAnonymous != null) 'is_anonymous': isAnonymous,
      if (bannedReason != null) 'banned_reason': bannedReason,
      if (isBanned != null) 'is_banned': isBanned,
      if (panicStrike != null) 'panic_strike': panicStrike,
      if (spoofingAttempts != null) 'spoofing_attempts': spoofingAttempts,
    };
  }

  static Map<String, dynamic> insert({
    String? id,
    required String rolesId,
    required String email,
    String? phone,
    String? encryptedPassword,
    DateTime? invitedAt,
    DateTime? confirmedAt,
    DateTime? emailConfirmedAt,
    DateTime? recoverySentAt,
    DateTime? lastSignInAt,
    Map<String, dynamic>? appMetadata,
    Map<String, dynamic>? userMetadata,
    DateTime? createdAt,
    DateTime? updatedAt,
    DateTime? bannedUntil,
    bool? isAnonymous,
    String? bannedReason,
    bool? isBanned,
    int? panicStrike,
    int? spoofingAttempts,
  }) {
    return _generateMap(
      id: id,
      rolesId: rolesId,
      email: email,
      phone: phone,
      encryptedPassword: encryptedPassword,
      invitedAt: invitedAt,
      confirmedAt: confirmedAt,
      emailConfirmedAt: emailConfirmedAt,
      recoverySentAt: recoverySentAt,
      lastSignInAt: lastSignInAt,
      appMetadata: appMetadata,
      userMetadata: userMetadata,
      createdAt: createdAt,
      updatedAt: updatedAt,
      bannedUntil: bannedUntil,
      isAnonymous: isAnonymous,
      bannedReason: bannedReason,
      isBanned: isBanned,
      panicStrike: panicStrike,
      spoofingAttempts: spoofingAttempts,
    );
  }

  static Map<String, dynamic> update({
    String? id,
    String? rolesId,
    String? email,
    String? phone,
    String? encryptedPassword,
    DateTime? invitedAt,
    DateTime? confirmedAt,
    DateTime? emailConfirmedAt,
    DateTime? recoverySentAt,
    DateTime? lastSignInAt,
    Map<String, dynamic>? appMetadata,
    Map<String, dynamic>? userMetadata,
    DateTime? createdAt,
    DateTime? updatedAt,
    DateTime? bannedUntil,
    bool? isAnonymous,
    String? bannedReason,
    bool? isBanned,
    int? panicStrike,
    int? spoofingAttempts,
  }) {
    return _generateMap(
      id: id,
      rolesId: rolesId,
      email: email,
      phone: phone,
      encryptedPassword: encryptedPassword,
      invitedAt: invitedAt,
      confirmedAt: confirmedAt,
      emailConfirmedAt: emailConfirmedAt,
      recoverySentAt: recoverySentAt,
      lastSignInAt: lastSignInAt,
      appMetadata: appMetadata,
      userMetadata: userMetadata,
      createdAt: createdAt,
      updatedAt: updatedAt,
      bannedUntil: bannedUntil,
      isAnonymous: isAnonymous,
      bannedReason: bannedReason,
      isBanned: isBanned,
      panicStrike: panicStrike,
      spoofingAttempts: spoofingAttempts,
    );
  }

  factory UserSupadartModel.fromJson(Map<String, dynamic> jsonn) {
    return UserSupadartModel(
      id: jsonn['id'] != null ? jsonn['id'].toString() : '',
      rolesId: jsonn['roles_id'] != null ? jsonn['roles_id'].toString() : '',
      email: jsonn['email'] != null ? jsonn['email'].toString() : '',
      phone: jsonn['phone'] != null ? jsonn['phone'].toString() : null,
      encryptedPassword:
          jsonn['encrypted_password'] != null
              ? jsonn['encrypted_password'].toString()
              : null,
      invitedAt:
          jsonn['invited_at'] != null
              ? DateTime.parse(jsonn['invited_at'].toString())
              : null,
      confirmedAt:
          jsonn['confirmed_at'] != null
              ? DateTime.parse(jsonn['confirmed_at'].toString())
              : null,
      emailConfirmedAt:
          jsonn['email_confirmed_at'] != null
              ? DateTime.parse(jsonn['email_confirmed_at'].toString())
              : null,
      recoverySentAt:
          jsonn['recovery_sent_at'] != null
              ? DateTime.parse(jsonn['recovery_sent_at'].toString())
              : null,
      lastSignInAt:
          jsonn['last_sign_in_at'] != null
              ? DateTime.parse(jsonn['last_sign_in_at'].toString())
              : null,
      appMetadata:
          jsonn['app_metadata'] != null
              ? jsonn['app_metadata'] as Map<String, dynamic>
              : null,
      userMetadata:
          jsonn['user_metadata'] != null
              ? jsonn['user_metadata'] as Map<String, dynamic>
              : null,
      createdAt:
          jsonn['created_at'] != null
              ? DateTime.parse(jsonn['created_at'].toString())
              : DateTime.fromMillisecondsSinceEpoch(0),
      updatedAt:
          jsonn['updated_at'] != null
              ? DateTime.parse(jsonn['updated_at'].toString())
              : DateTime.fromMillisecondsSinceEpoch(0),
      bannedUntil:
          jsonn['banned_until'] != null
              ? DateTime.parse(jsonn['banned_until'].toString())
              : null,
      isAnonymous:
          jsonn['is_anonymous'] != null ? jsonn['is_anonymous'] as bool : false,
      bannedReason:
          jsonn['banned_reason'] != null
              ? jsonn['banned_reason'].toString()
              : null,
      isBanned: jsonn['is_banned'] != null ? jsonn['is_banned'] as bool : false,
      panicStrike:
          jsonn['panic_strike'] != null
              ? int.parse(jsonn['panic_strike'].toString())
              : 0,
      spoofingAttempts:
          jsonn['spoofing_attempts'] != null
              ? int.parse(jsonn['spoofing_attempts'].toString())
              : 0,
      role:
          jsonn['roles'] != null
              ? RoleSupadartModel.fromJson(
                jsonn['roles'] as Map<String, dynamic>,
              )
              : null,
      profile:
          jsonn['profiles'] != null
              ? ProfileSupadartModel.fromJson(
                jsonn['profiles'] as Map<String, dynamic>,
              )
              : null,
    );
  }

  Map<String, dynamic> toJson() {
    return _generateMap(
      id: id,
      rolesId: rolesId,
      email: email,
      phone: phone,
      encryptedPassword: encryptedPassword,
      invitedAt: invitedAt,
      confirmedAt: confirmedAt,
      emailConfirmedAt: emailConfirmedAt,
      recoverySentAt: recoverySentAt,
      lastSignInAt: lastSignInAt,
      appMetadata: appMetadata,
      userMetadata: userMetadata,
      createdAt: createdAt,
      updatedAt: updatedAt,
      bannedUntil: bannedUntil,
      isAnonymous: isAnonymous,
      bannedReason: bannedReason,
      isBanned: isBanned,
      panicStrike: panicStrike,
      spoofingAttempts: spoofingAttempts,
      // 'roles': role?.toJson(),
      // 'profiles': profile?.toJson(),
    );
  }

  static const _unset = Object();
  UserSupadartModel copyWith({
    Object? id = _unset,
    Object? rolesId = _unset,
    Object? email = _unset,
    Object? phone = _unset,
    Object? encryptedPassword = _unset,
    Object? invitedAt = _unset,
    Object? confirmedAt = _unset,
    Object? emailConfirmedAt = _unset,
    Object? recoverySentAt = _unset,
    Object? lastSignInAt = _unset,
    Object? appMetadata = _unset,
    Object? userMetadata = _unset,
    Object? createdAt = _unset,
    Object? updatedAt = _unset,
    Object? bannedUntil = _unset,
    Object? isAnonymous = _unset,
    Object? bannedReason = _unset,
    Object? isBanned = _unset,
    Object? panicStrike = _unset,
    Object? spoofingAttempts = _unset,
    Object? role = _unset,
    Object? profile = _unset,
  }) {
    return UserSupadartModel(
      id: id == _unset ? this.id : id as String,
      rolesId: rolesId == _unset ? this.rolesId : rolesId as String,
      email: email == _unset ? this.email : email as String,
      phone: phone == _unset ? this.phone : phone as String?,
      encryptedPassword:
          encryptedPassword == _unset
              ? this.encryptedPassword
              : encryptedPassword as String?,
      invitedAt: invitedAt == _unset ? this.invitedAt : invitedAt as DateTime?,
      confirmedAt:
          confirmedAt == _unset ? this.confirmedAt : confirmedAt as DateTime?,
      emailConfirmedAt:
          emailConfirmedAt == _unset
              ? this.emailConfirmedAt
              : emailConfirmedAt as DateTime?,
      recoverySentAt:
          recoverySentAt == _unset
              ? this.recoverySentAt
              : recoverySentAt as DateTime?,
      lastSignInAt:
          lastSignInAt == _unset
              ? this.lastSignInAt
              : lastSignInAt as DateTime?,
      appMetadata:
          appMetadata == _unset
              ? this.appMetadata
              : appMetadata as Map<String, dynamic>?,
      userMetadata:
          userMetadata == _unset
              ? this.userMetadata
              : userMetadata as Map<String, dynamic>?,
      createdAt: createdAt == _unset ? this.createdAt : createdAt as DateTime,
      updatedAt: updatedAt == _unset ? this.updatedAt : updatedAt as DateTime,
      bannedUntil:
          bannedUntil == _unset ? this.bannedUntil : bannedUntil as DateTime?,
      isAnonymous:
          isAnonymous == _unset ? this.isAnonymous : isAnonymous as bool,
      bannedReason:
          bannedReason == _unset ? this.bannedReason : bannedReason as String?,
      isBanned: isBanned == _unset ? this.isBanned : isBanned as bool,
      panicStrike:
          panicStrike == _unset ? this.panicStrike : panicStrike as int,
      spoofingAttempts:
          spoofingAttempts == _unset
              ? this.spoofingAttempts
              : spoofingAttempts as int,
      role: role == _unset ? this.role : role as RoleSupadartModel?,
      profile:
          profile == _unset ? this.profile : profile as ProfileSupadartModel?,
    );
  }
}
