// 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 ProfileSupadartModel implements SupadartClass<ProfileSupadartModel> {
  final String id;
  final String userId;
  final String? avatar;
  final String? username;
  final String? firstName;
  final String? lastName;
  final String? bio;
  final Map<String, dynamic>? address;
  final DateTime? birthDate;
  final String nik;
  final UserSupadartModel? user;

  const ProfileSupadartModel({
    required this.id,
    required this.userId,
    this.avatar,
    this.username,
    this.firstName,
    this.lastName,
    this.bio,
    this.address,
    this.birthDate,
    required this.nik,
    this.user,
  });

  static String get table_name => 'profileSupadartModel';
  static String get c_id => 'id';
  static String get c_userId => 'user_id';
  static String get c_avatar => 'avatar';
  static String get c_username => 'username';
  static String get c_firstName => 'first_name';
  static String get c_lastName => 'last_name';
  static String get c_bio => 'bio';
  static String get c_address => 'address';
  static String get c_birthDate => 'birth_date';
  static String get c_nik => 'nik';

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

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

  static Map<String, dynamic> _generateMap({
    String? id,
    String? userId,
    String? avatar,
    String? username,
    String? firstName,
    String? lastName,
    String? bio,
    Map<String, dynamic>? address,
    DateTime? birthDate,
    String? nik,
  }) {
    return {
      if (id != null) 'id': id,
      if (userId != null) 'user_id': userId,
      if (avatar != null) 'avatar': avatar,
      if (username != null) 'username': username,
      if (firstName != null) 'first_name': firstName,
      if (lastName != null) 'last_name': lastName,
      if (bio != null) 'bio': bio,
      if (address != null) 'address': address,
      if (birthDate != null) 'birth_date': birthDate.toIso8601String(),
      if (nik != null) 'nik': nik,
    };
  }

  static Map<String, dynamic> insert({
    String? id,
    required String userId,
    String? avatar,
    String? username,
    String? firstName,
    String? lastName,
    String? bio,
    Map<String, dynamic>? address,
    DateTime? birthDate,
    String? nik,
  }) {
    return _generateMap(
      id: id,
      userId: userId,
      avatar: avatar,
      username: username,
      firstName: firstName,
      lastName: lastName,
      bio: bio,
      address: address,
      birthDate: birthDate,
      nik: nik,
    );
  }

  static Map<String, dynamic> update({
    String? id,
    String? userId,
    String? avatar,
    String? username,
    String? firstName,
    String? lastName,
    String? bio,
    Map<String, dynamic>? address,
    DateTime? birthDate,
    String? nik,
  }) {
    return _generateMap(
      id: id,
      userId: userId,
      avatar: avatar,
      username: username,
      firstName: firstName,
      lastName: lastName,
      bio: bio,
      address: address,
      birthDate: birthDate,
      nik: nik,
    );
  }

  factory ProfileSupadartModel.fromJson(Map<String, dynamic> jsonn) {
    return ProfileSupadartModel(
      id: jsonn['id'] != null ? jsonn['id'].toString() : '',
      userId: jsonn['user_id'] != null ? jsonn['user_id'].toString() : '',
      avatar: jsonn['avatar'] != null ? jsonn['avatar'].toString() : null,
      username: jsonn['username'] != null ? jsonn['username'].toString() : null,
      firstName:
          jsonn['first_name'] != null ? jsonn['first_name'].toString() : null,
      lastName:
          jsonn['last_name'] != null ? jsonn['last_name'].toString() : null,
      bio: jsonn['bio'] != null ? jsonn['bio'].toString() : null,
      address:
          jsonn['address'] != null
              ? jsonn['address'] as Map<String, dynamic>
              : null,
      birthDate:
          jsonn['birth_date'] != null
              ? DateTime.parse(jsonn['birth_date'].toString())
              : null,
      nik: jsonn['nik'] != null ? jsonn['nik'].toString() : '',
      user:
          jsonn['users'] != null
              ? UserSupadartModel.fromJson(
                jsonn['users'] as Map<String, dynamic>,
              )
              : null,
    );
  }

  Map<String, dynamic> toJson() {
    return _generateMap(
      id: id,
      userId: userId,
      avatar: avatar,
      username: username,
      firstName: firstName,
      lastName: lastName,
      bio: bio,
      address: address,
      birthDate: birthDate,
      nik: nik,
      // 'users': user?.toJson(),
    );
  }

  static const _unset = Object();
  ProfileSupadartModel copyWith({
    Object? id = _unset,
    Object? userId = _unset,
    Object? avatar = _unset,
    Object? username = _unset,
    Object? firstName = _unset,
    Object? lastName = _unset,
    Object? bio = _unset,
    Object? address = _unset,
    Object? birthDate = _unset,
    Object? nik = _unset,
    Object? user = _unset,
  }) {
    return ProfileSupadartModel(
      id: id == _unset ? this.id : id as String,
      userId: userId == _unset ? this.userId : userId as String,
      avatar: avatar == _unset ? this.avatar : avatar as String?,
      username: username == _unset ? this.username : username as String?,
      firstName: firstName == _unset ? this.firstName : firstName as String?,
      lastName: lastName == _unset ? this.lastName : lastName as String?,
      bio: bio == _unset ? this.bio : bio as String?,
      address:
          address == _unset ? this.address : address as Map<String, dynamic>?,
      birthDate: birthDate == _unset ? this.birthDate : birthDate as DateTime?,
      nik: nik == _unset ? this.nik : nik as String,
      user: user == _unset ? this.user : user as UserSupadartModel?,
    );
  }
}
