// 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 OfficerSupadartModel implements SupadartClass<OfficerSupadartModel> {
  final String unitId;
  final String roleId;
  final String nrp;
  final String name;
  final String? rank;
  final String? position;
  final String? phone;
  final String? email;
  final String? avatar;
  final DateTime? validUntil;
  final String? qrCode;
  final DateTime? createdAt;
  final DateTime? updatedAt;
  final String patrolUnitId;
  final String id;
  final String? bannedReason;
  final DateTime? bannedUntil;
  final bool isBanned;
  final int panicStrike;
  final int spoofingAttempts;
  final PatrolUnitSupadartModel? patrolUnit;
  final RoleSupadartModel? role;
  final UnitSupadartModel? unit;

  const OfficerSupadartModel({
    required this.unitId,
    required this.roleId,
    required this.nrp,
    required this.name,
    this.rank,
    this.position,
    this.phone,
    this.email,
    this.avatar,
    this.validUntil,
    this.qrCode,
    this.createdAt,
    this.updatedAt,
    required this.patrolUnitId,
    required this.id,
    this.bannedReason,
    this.bannedUntil,
    required this.isBanned,
    required this.panicStrike,
    required this.spoofingAttempts,
    this.patrolUnit,
    this.role,
    this.unit,
  });

  static String get table_name => 'officerSupadartModel';
  static String get c_unitId => 'unit_id';
  static String get c_roleId => 'role_id';
  static String get c_nrp => 'nrp';
  static String get c_name => 'name';
  static String get c_rank => 'rank';
  static String get c_position => 'position';
  static String get c_phone => 'phone';
  static String get c_email => 'email';
  static String get c_avatar => 'avatar';
  static String get c_validUntil => 'valid_until';
  static String get c_qrCode => 'qr_code';
  static String get c_createdAt => 'created_at';
  static String get c_updatedAt => 'updated_at';
  static String get c_patrolUnitId => 'patrol_unit_id';
  static String get c_id => 'id';
  static String get c_bannedReason => 'banned_reason';
  static String get c_bannedUntil => 'banned_until';
  static String get c_isBanned => 'is_banned';
  static String get c_panicStrike => 'panic_strike';
  static String get c_spoofingAttempts => 'spoofing_attempts';

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

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

  static Map<String, dynamic> _generateMap({
    String? unitId,
    String? roleId,
    String? nrp,
    String? name,
    String? rank,
    String? position,
    String? phone,
    String? email,
    String? avatar,
    DateTime? validUntil,
    String? qrCode,
    DateTime? createdAt,
    DateTime? updatedAt,
    String? patrolUnitId,
    String? id,
    String? bannedReason,
    DateTime? bannedUntil,
    bool? isBanned,
    int? panicStrike,
    int? spoofingAttempts,
  }) {
    return {
      if (unitId != null) 'unit_id': unitId,
      if (roleId != null) 'role_id': roleId,
      if (nrp != null) 'nrp': nrp,
      if (name != null) 'name': name,
      if (rank != null) 'rank': rank,
      if (position != null) 'position': position,
      if (phone != null) 'phone': phone,
      if (email != null) 'email': email,
      if (avatar != null) 'avatar': avatar,
      if (validUntil != null) 'valid_until': validUntil.toIso8601String(),
      if (qrCode != null) 'qr_code': qrCode,
      if (createdAt != null) 'created_at': createdAt.toUtc().toIso8601String(),
      if (updatedAt != null) 'updated_at': updatedAt.toUtc().toIso8601String(),
      if (patrolUnitId != null) 'patrol_unit_id': patrolUnitId,
      if (id != null) 'id': id,
      if (bannedReason != null) 'banned_reason': bannedReason,
      if (bannedUntil != null) 'banned_until': bannedUntil.toIso8601String(),
      if (isBanned != null) 'is_banned': isBanned,
      if (panicStrike != null) 'panic_strike': panicStrike,
      if (spoofingAttempts != null) 'spoofing_attempts': spoofingAttempts,
    };
  }

  static Map<String, dynamic> insert({
    required String unitId,
    required String roleId,
    required String nrp,
    required String name,
    String? rank,
    String? position,
    String? phone,
    String? email,
    String? avatar,
    DateTime? validUntil,
    String? qrCode,
    DateTime? createdAt,
    DateTime? updatedAt,
    required String patrolUnitId,
    String? id,
    String? bannedReason,
    DateTime? bannedUntil,
    bool? isBanned,
    int? panicStrike,
    int? spoofingAttempts,
  }) {
    return _generateMap(
      unitId: unitId,
      roleId: roleId,
      nrp: nrp,
      name: name,
      rank: rank,
      position: position,
      phone: phone,
      email: email,
      avatar: avatar,
      validUntil: validUntil,
      qrCode: qrCode,
      createdAt: createdAt,
      updatedAt: updatedAt,
      patrolUnitId: patrolUnitId,
      id: id,
      bannedReason: bannedReason,
      bannedUntil: bannedUntil,
      isBanned: isBanned,
      panicStrike: panicStrike,
      spoofingAttempts: spoofingAttempts,
    );
  }

  static Map<String, dynamic> update({
    String? unitId,
    String? roleId,
    String? nrp,
    String? name,
    String? rank,
    String? position,
    String? phone,
    String? email,
    String? avatar,
    DateTime? validUntil,
    String? qrCode,
    DateTime? createdAt,
    DateTime? updatedAt,
    String? patrolUnitId,
    String? id,
    String? bannedReason,
    DateTime? bannedUntil,
    bool? isBanned,
    int? panicStrike,
    int? spoofingAttempts,
  }) {
    return _generateMap(
      unitId: unitId,
      roleId: roleId,
      nrp: nrp,
      name: name,
      rank: rank,
      position: position,
      phone: phone,
      email: email,
      avatar: avatar,
      validUntil: validUntil,
      qrCode: qrCode,
      createdAt: createdAt,
      updatedAt: updatedAt,
      patrolUnitId: patrolUnitId,
      id: id,
      bannedReason: bannedReason,
      bannedUntil: bannedUntil,
      isBanned: isBanned,
      panicStrike: panicStrike,
      spoofingAttempts: spoofingAttempts,
    );
  }

  factory OfficerSupadartModel.fromJson(Map<String, dynamic> jsonn) {
    return OfficerSupadartModel(
      unitId: jsonn['unit_id'] != null ? jsonn['unit_id'].toString() : '',
      roleId: jsonn['role_id'] != null ? jsonn['role_id'].toString() : '',
      nrp: jsonn['nrp'] != null ? jsonn['nrp'].toString() : '',
      name: jsonn['name'] != null ? jsonn['name'].toString() : '',
      rank: jsonn['rank'] != null ? jsonn['rank'].toString() : null,
      position: jsonn['position'] != null ? jsonn['position'].toString() : null,
      phone: jsonn['phone'] != null ? jsonn['phone'].toString() : null,
      email: jsonn['email'] != null ? jsonn['email'].toString() : null,
      avatar: jsonn['avatar'] != null ? jsonn['avatar'].toString() : null,
      validUntil:
          jsonn['valid_until'] != null
              ? DateTime.parse(jsonn['valid_until'].toString())
              : null,
      qrCode: jsonn['qr_code'] != null ? jsonn['qr_code'].toString() : null,
      createdAt:
          jsonn['created_at'] != null
              ? DateTime.parse(jsonn['created_at'].toString())
              : null,
      updatedAt:
          jsonn['updated_at'] != null
              ? DateTime.parse(jsonn['updated_at'].toString())
              : null,
      patrolUnitId:
          jsonn['patrol_unit_id'] != null
              ? jsonn['patrol_unit_id'].toString()
              : '',
      id: jsonn['id'] != null ? jsonn['id'].toString() : '',
      bannedReason:
          jsonn['banned_reason'] != null
              ? jsonn['banned_reason'].toString()
              : null,
      bannedUntil:
          jsonn['banned_until'] != null
              ? DateTime.parse(jsonn['banned_until'].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,
      patrolUnit:
          jsonn['patrol_units'] != null
              ? PatrolUnitSupadartModel.fromJson(
                jsonn['patrol_units'] as Map<String, dynamic>,
              )
              : null,
      role:
          jsonn['roles'] != null
              ? RoleSupadartModel.fromJson(
                jsonn['roles'] as Map<String, dynamic>,
              )
              : null,
      unit:
          jsonn['unitSupadartModel'] != null
              ? UnitSupadartModel.fromJson(
                jsonn['unitSupadartModel'] as Map<String, dynamic>,
              )
              : null,
    );
  }

  Map<String, dynamic> toJson() {
    return _generateMap(
      unitId: unitId,
      roleId: roleId,
      nrp: nrp,
      name: name,
      rank: rank,
      position: position,
      phone: phone,
      email: email,
      avatar: avatar,
      validUntil: validUntil,
      qrCode: qrCode,
      createdAt: createdAt,
      updatedAt: updatedAt,
      patrolUnitId: patrolUnitId,
      id: id,
      bannedReason: bannedReason,
      bannedUntil: bannedUntil,
      isBanned: isBanned,
      panicStrike: panicStrike,
      spoofingAttempts: spoofingAttempts,
      // 'patrol_units': patrolUnit?.toJson(),
      // 'roles': role?.toJson(),
      // 'unitSupadartModel': unit?.toJson(),
    );
  }

  static const _unset = Object();
  OfficerSupadartModel copyWith({
    Object? unitId = _unset,
    Object? roleId = _unset,
    Object? nrp = _unset,
    Object? name = _unset,
    Object? rank = _unset,
    Object? position = _unset,
    Object? phone = _unset,
    Object? email = _unset,
    Object? avatar = _unset,
    Object? validUntil = _unset,
    Object? qrCode = _unset,
    Object? createdAt = _unset,
    Object? updatedAt = _unset,
    Object? patrolUnitId = _unset,
    Object? id = _unset,
    Object? bannedReason = _unset,
    Object? bannedUntil = _unset,
    Object? isBanned = _unset,
    Object? panicStrike = _unset,
    Object? spoofingAttempts = _unset,
    Object? patrolUnit = _unset,
    Object? role = _unset,
    Object? unit = _unset,
  }) {
    return OfficerSupadartModel(
      unitId: unitId == _unset ? this.unitId : unitId as String,
      roleId: roleId == _unset ? this.roleId : roleId as String,
      nrp: nrp == _unset ? this.nrp : nrp as String,
      name: name == _unset ? this.name : name as String,
      rank: rank == _unset ? this.rank : rank as String?,
      position: position == _unset ? this.position : position as String?,
      phone: phone == _unset ? this.phone : phone as String?,
      email: email == _unset ? this.email : email as String?,
      avatar: avatar == _unset ? this.avatar : avatar as String?,
      validUntil:
          validUntil == _unset ? this.validUntil : validUntil as DateTime?,
      qrCode: qrCode == _unset ? this.qrCode : qrCode as String?,
      createdAt: createdAt == _unset ? this.createdAt : createdAt as DateTime?,
      updatedAt: updatedAt == _unset ? this.updatedAt : updatedAt as DateTime?,
      patrolUnitId:
          patrolUnitId == _unset ? this.patrolUnitId : patrolUnitId as String,
      id: id == _unset ? this.id : id as String,
      bannedReason:
          bannedReason == _unset ? this.bannedReason : bannedReason as String?,
      bannedUntil:
          bannedUntil == _unset ? this.bannedUntil : bannedUntil as DateTime?,
      isBanned: isBanned == _unset ? this.isBanned : isBanned as bool,
      panicStrike:
          panicStrike == _unset ? this.panicStrike : panicStrike as int,
      spoofingAttempts:
          spoofingAttempts == _unset
              ? this.spoofingAttempts
              : spoofingAttempts as int,
      patrolUnit:
          patrolUnit == _unset
              ? this.patrolUnit
              : patrolUnit as PatrolUnitSupadartModel?,
      role: role == _unset ? this.role : role as RoleSupadartModel?,
      unit: unit == _unset ? this.unit : unit as UnitSupadartModel?,
    );
  }
}
