// 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';

enum STATUS_CONTACT_MESSAGES { PENDING, IN_PROGRESS, RESOLVED, CLOSED }

class ContactMessages implements SupadartClass<ContactMessages> {
  final String id;
  final String? name;
  final String? email;
  final String? phone;
  final String? messageType;
  final String? messageTypeLabel;
  final String? message;
  final STATUS_CONTACT_MESSAGES status;
  final DateTime createdAt;
  final DateTime updatedAt;

  const ContactMessages({
    required this.id,
    this.name,
    this.email,
    this.phone,
    this.messageType,
    this.messageTypeLabel,
    this.message,
    required this.status,
    required this.createdAt,
    required this.updatedAt,
  });

  static String get table_name => 'contact_messages';
  static String get c_id => 'id';
  static String get c_name => 'name';
  static String get c_email => 'email';
  static String get c_phone => 'phone';
  static String get c_messageType => 'message_type';
  static String get c_messageTypeLabel => 'message_type_label';
  static String get c_message => 'message';
  static String get c_status => 'status';
  static String get c_createdAt => 'created_at';
  static String get c_updatedAt => 'updated_at';

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

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

  static Map<String, dynamic> _generateMap({
    String? id,
    String? name,
    String? email,
    String? phone,
    String? messageType,
    String? messageTypeLabel,
    String? message,
    STATUS_CONTACT_MESSAGES? status,
    DateTime? createdAt,
    DateTime? updatedAt,
  }) {
    return {
      if (id != null) 'id': id,
      if (name != null) 'name': name,
      if (email != null) 'email': email,
      if (phone != null) 'phone': phone,
      if (messageType != null) 'message_type': messageType,
      if (messageTypeLabel != null) 'message_type_label': messageTypeLabel,
      if (message != null) 'message': message,
      if (status != null) 'status': status.toString().split('.').last,
      if (createdAt != null) 'created_at': createdAt.toUtc().toIso8601String(),
      if (updatedAt != null) 'updated_at': updatedAt.toUtc().toIso8601String(),
    };
  }

  static Map<String, dynamic> insert({
    String? id,
    String? name,
    String? email,
    String? phone,
    String? messageType,
    String? messageTypeLabel,
    String? message,
    STATUS_CONTACT_MESSAGES? status,
    DateTime? createdAt,
    required DateTime updatedAt,
  }) {
    return _generateMap(
      id: id,
      name: name,
      email: email,
      phone: phone,
      messageType: messageType,
      messageTypeLabel: messageTypeLabel,
      message: message,
      status: status,
      createdAt: createdAt,
      updatedAt: updatedAt,
    );
  }

  static Map<String, dynamic> update({
    String? id,
    String? name,
    String? email,
    String? phone,
    String? messageType,
    String? messageTypeLabel,
    String? message,
    STATUS_CONTACT_MESSAGES? status,
    DateTime? createdAt,
    DateTime? updatedAt,
  }) {
    return _generateMap(
      id: id,
      name: name,
      email: email,
      phone: phone,
      messageType: messageType,
      messageTypeLabel: messageTypeLabel,
      message: message,
      status: status,
      createdAt: createdAt,
      updatedAt: updatedAt,
    );
  }

  factory ContactMessages.fromJson(Map<String, dynamic> jsonn) {
    return ContactMessages(
      id: jsonn['id'] != null ? jsonn['id'].toString() : '',
      name: jsonn['name'] != null ? jsonn['name'].toString() : null,
      email: jsonn['email'] != null ? jsonn['email'].toString() : null,
      phone: jsonn['phone'] != null ? jsonn['phone'].toString() : null,
      messageType:
          jsonn['message_type'] != null
              ? jsonn['message_type'].toString()
              : null,
      messageTypeLabel:
          jsonn['message_type_label'] != null
              ? jsonn['message_type_label'].toString()
              : null,
      message: jsonn['message'] != null ? jsonn['message'].toString() : null,
      status:
          jsonn['status'] != null
              ? STATUS_CONTACT_MESSAGES.values.byName(
                jsonn['status'].toString(),
              )
              : STATUS_CONTACT_MESSAGES.values.first,
      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,
      email: email,
      phone: phone,
      messageType: messageType,
      messageTypeLabel: messageTypeLabel,
      message: message,
      status: status,
      createdAt: createdAt,
      updatedAt: updatedAt,
    );
  }

  static const _unset = Object();
  ContactMessages copyWith({
    Object? id = _unset,
    Object? name = _unset,
    Object? email = _unset,
    Object? phone = _unset,
    Object? messageType = _unset,
    Object? messageTypeLabel = _unset,
    Object? message = _unset,
    Object? status = _unset,
    Object? createdAt = _unset,
    Object? updatedAt = _unset,
  }) {
    return ContactMessages(
      id: id == _unset ? this.id : id as String,
      name: name == _unset ? this.name : name as String?,
      email: email == _unset ? this.email : email as String?,
      phone: phone == _unset ? this.phone : phone as String?,
      messageType:
          messageType == _unset ? this.messageType : messageType as String?,
      messageTypeLabel:
          messageTypeLabel == _unset
              ? this.messageTypeLabel
              : messageTypeLabel as String?,
      message: message == _unset ? this.message : message as String?,
      status:
          status == _unset ? this.status : status as STATUS_CONTACT_MESSAGES,
      createdAt: createdAt == _unset ? this.createdAt : createdAt as DateTime,
      updatedAt: updatedAt == _unset ? this.updatedAt : updatedAt as DateTime,
    );
  }
}
