// 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 EvidenceSupadartModel implements SupadartClass<EvidenceSupadartModel> {
  final String incidentId;
  final String type;
  final String url;
  final DateTime? uploadedAt;
  final String? caption;
  final String? description;
  final Map<String, dynamic>? metadata;
  final String id;
  final IncidentLogSupadartModel? incident;

  const EvidenceSupadartModel({
    required this.incidentId,
    required this.type,
    required this.url,
    this.uploadedAt,
    this.caption,
    this.description,
    this.metadata,
    required this.id,
    this.incident,
  });

  static String get table_name => 'evidenceSupadartModel';
  static String get c_incidentId => 'incident_id';
  static String get c_type => 'type';
  static String get c_url => 'url';
  static String get c_uploadedAt => 'uploaded_at';
  static String get c_caption => 'caption';
  static String get c_description => 'description';
  static String get c_metadata => 'metadata';
  static String get c_id => 'id';

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

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

  static Map<String, dynamic> _generateMap({
    String? incidentId,
    String? type,
    String? url,
    DateTime? uploadedAt,
    String? caption,
    String? description,
    Map<String, dynamic>? metadata,
    String? id,
  }) {
    return {
      if (incidentId != null) 'incident_id': incidentId,
      if (type != null) 'type': type,
      if (url != null) 'url': url,
      if (uploadedAt != null)
        'uploaded_at': uploadedAt.toUtc().toIso8601String(),
      if (caption != null) 'caption': caption,
      if (description != null) 'description': description,
      if (metadata != null) 'metadata': metadata,
      if (id != null) 'id': id,
    };
  }

  static Map<String, dynamic> insert({
    required String incidentId,
    required String type,
    required String url,
    DateTime? uploadedAt,
    String? caption,
    String? description,
    Map<String, dynamic>? metadata,
    String? id,
  }) {
    return _generateMap(
      incidentId: incidentId,
      type: type,
      url: url,
      uploadedAt: uploadedAt,
      caption: caption,
      description: description,
      metadata: metadata,
      id: id,
    );
  }

  static Map<String, dynamic> update({
    String? incidentId,
    String? type,
    String? url,
    DateTime? uploadedAt,
    String? caption,
    String? description,
    Map<String, dynamic>? metadata,
    String? id,
  }) {
    return _generateMap(
      incidentId: incidentId,
      type: type,
      url: url,
      uploadedAt: uploadedAt,
      caption: caption,
      description: description,
      metadata: metadata,
      id: id,
    );
  }

  factory EvidenceSupadartModel.fromJson(Map<String, dynamic> jsonn) {
    return EvidenceSupadartModel(
      incidentId:
          jsonn['incident_id'] != null ? jsonn['incident_id'].toString() : '',
      type: jsonn['type'] != null ? jsonn['type'].toString() : '',
      url: jsonn['url'] != null ? jsonn['url'].toString() : '',
      uploadedAt:
          jsonn['uploaded_at'] != null
              ? DateTime.parse(jsonn['uploaded_at'].toString())
              : null,
      caption: jsonn['caption'] != null ? jsonn['caption'].toString() : null,
      description:
          jsonn['description'] != null ? jsonn['description'].toString() : null,
      metadata:
          jsonn['metadata'] != null
              ? jsonn['metadata'] as Map<String, dynamic>
              : null,
      id: jsonn['id'] != null ? jsonn['id'].toString() : '',
      incident:
          jsonn['incident_logs'] != null
              ? IncidentLogSupadartModel.fromJson(
                jsonn['incident_logs'] as Map<String, dynamic>,
              )
              : null,
    );
  }

  Map<String, dynamic> toJson() {
    return _generateMap(
      incidentId: incidentId,
      type: type,
      url: url,
      uploadedAt: uploadedAt,
      caption: caption,
      description: description,
      metadata: metadata,
      id: id,
      // 'incident_logs': incident?.toJson(),
    );
  }

  static const _unset = Object();
  EvidenceSupadartModel copyWith({
    Object? incidentId = _unset,
    Object? type = _unset,
    Object? url = _unset,
    Object? uploadedAt = _unset,
    Object? caption = _unset,
    Object? description = _unset,
    Object? metadata = _unset,
    Object? id = _unset,
    Object? incident = _unset,
  }) {
    return EvidenceSupadartModel(
      incidentId: incidentId == _unset ? this.incidentId : incidentId as String,
      type: type == _unset ? this.type : type as String,
      url: url == _unset ? this.url : url as String,
      uploadedAt:
          uploadedAt == _unset ? this.uploadedAt : uploadedAt as DateTime?,
      caption: caption == _unset ? this.caption : caption as String?,
      description:
          description == _unset ? this.description : description as String?,
      metadata:
          metadata == _unset
              ? this.metadata
              : metadata as Map<String, dynamic>?,
      id: id == _unset ? this.id : id as String,
      incident:
          incident == _unset
              ? this.incident
              : incident as IncidentLogSupadartModel?,
    );
  }
}
