// 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_header.dart';

class RoleSupadartModel implements SupadartClass<RoleSupadartModel> {
  final String id;
  final String name;
  final String? description;
  final DateTime createdAt;
  final DateTime updatedAt;

  const RoleSupadartModel({
    required this.id,
    required this.name,
    this.description,
    required this.createdAt,
    required this.updatedAt,
  });

  static String get table_name => 'roleSupadartModel';
  static String get c_id => 'id';
  static String get c_name => 'name';
  static String get c_description => 'description';
  static String get c_createdAt => 'created_at';
  static String get c_updatedAt => 'updated_at';

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

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

  static Map<String, dynamic> _generateMap({
    String? id,
    String? name,
    String? description,
    DateTime? createdAt,
    DateTime? updatedAt,
  }) {
    return {
      if (id != null) 'id': id,
      if (name != null) 'name': name,
      if (description != null) 'description': description,
      if (createdAt != null) 'created_at': createdAt.toUtc().toIso8601String(),
      if (updatedAt != null) 'updated_at': updatedAt.toUtc().toIso8601String(),
    };
  }

  static Map<String, dynamic> insert({
    String? id,
    required String name,
    String? description,
    DateTime? createdAt,
    DateTime? updatedAt,
  }) {
    return _generateMap(
      id: id,
      name: name,
      description: description,
      createdAt: createdAt,
      updatedAt: updatedAt,
    );
  }

  static Map<String, dynamic> update({
    String? id,
    String? name,
    String? description,
    DateTime? createdAt,
    DateTime? updatedAt,
  }) {
    return _generateMap(
      id: id,
      name: name,
      description: description,
      createdAt: createdAt,
      updatedAt: updatedAt,
    );
  }

  factory RoleSupadartModel.fromJson(Map<String, dynamic> jsonn) {
    return RoleSupadartModel(
      id: jsonn['id'] != null ? jsonn['id'].toString() : '',
      name: jsonn['name'] != null ? jsonn['name'].toString() : '',
      description:
          jsonn['description'] != null ? jsonn['description'].toString() : 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),
    );
  }

  Map<String, dynamic> toJson() {
    return _generateMap(
      id: id,
      name: name,
      description: description,
      createdAt: createdAt,
      updatedAt: updatedAt,
    );
  }

  static const _unset = Object();
  RoleSupadartModel copyWith({
    Object? id = _unset,
    Object? name = _unset,
    Object? description = _unset,
    Object? createdAt = _unset,
    Object? updatedAt = _unset,
  }) {
    return RoleSupadartModel(
      id: id == _unset ? this.id : id as String,
      name: name == _unset ? this.name : name as String,
      description:
          description == _unset ? this.description : description as String?,
      createdAt: createdAt == _unset ? this.createdAt : createdAt as DateTime,
      updatedAt: updatedAt == _unset ? this.updatedAt : updatedAt as DateTime,
    );
  }
}
