import 'package:domain/generated/json/base/json_convert_content.dart';
import 'package:domain/entity/response/contract_detail_entity.dart';
import 'package:domain/entity/response/index_option_entity.dart';


ContractDetailEntity $ContractDetailEntityFromJson(Map<String, dynamic> json) {
  final ContractDetailEntity contractDetailEntity = ContractDetailEntity();
  final ContractDetailRow? row = jsonConvert.convert<ContractDetailRow>(json['row']);
  if (row != null) {
    contractDetailEntity.row = row;
  }
  final List<IndexOptionEntity>? agencyList = (json['agency_list'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<IndexOptionEntity>(e) as IndexOptionEntity).toList();
  if (agencyList != null) {
    contractDetailEntity.agencyList = agencyList;
  }
  return contractDetailEntity;
}

Map<String, dynamic> $ContractDetailEntityToJson(ContractDetailEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['row'] = entity.row?.toJson();
  data['agency_list'] = entity.agencyList.map((v) => v.toJson()).toList();
  return data;
}

extension ContractDetailEntityExtension on ContractDetailEntity {
  ContractDetailEntity copyWith({
    ContractDetailRow? row,
    List<IndexOptionEntity>? agencyList,
  }) {
    return ContractDetailEntity()
      ..row = row ?? this.row
      ..agencyList = agencyList ?? this.agencyList;
  }
}

ContractDetailRow $ContractDetailRowFromJson(Map<String, dynamic> json) {
  final ContractDetailRow contractDetailRow = ContractDetailRow();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    contractDetailRow.id = id;
  }
  final String? employerId = jsonConvert.convert<String>(json['employer_id']);
  if (employerId != null) {
    contractDetailRow.employerId = employerId;
  }
  final String? agencyId = jsonConvert.convert<String>(json['agency_id']);
  if (agencyId != null) {
    contractDetailRow.agencyId = agencyId;
  }
  final String? startDate = jsonConvert.convert<String>(json['start_date']);
  if (startDate != null) {
    contractDetailRow.startDate = startDate;
  }
  final String? endDate = jsonConvert.convert<String>(json['end_date']);
  if (endDate != null) {
    contractDetailRow.endDate = endDate;
  }
  final String? file = jsonConvert.convert<String>(json['file']);
  if (file != null) {
    contractDetailRow.file = file;
  }
  final int? status = jsonConvert.convert<int>(json['status']);
  if (status != null) {
    contractDetailRow.status = status;
  }
  final String? createdAt = jsonConvert.convert<String>(json['created_at']);
  if (createdAt != null) {
    contractDetailRow.createdAt = createdAt;
  }
  final String? updatedAt = jsonConvert.convert<String>(json['updated_at']);
  if (updatedAt != null) {
    contractDetailRow.updatedAt = updatedAt;
  }
  final String? deletedAt = jsonConvert.convert<String>(json['deleted_at']);
  if (deletedAt != null) {
    contractDetailRow.deletedAt = deletedAt;
  }
  return contractDetailRow;
}

Map<String, dynamic> $ContractDetailRowToJson(ContractDetailRow entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['employer_id'] = entity.employerId;
  data['agency_id'] = entity.agencyId;
  data['start_date'] = entity.startDate;
  data['end_date'] = entity.endDate;
  data['file'] = entity.file;
  data['status'] = entity.status;
  data['created_at'] = entity.createdAt;
  data['updated_at'] = entity.updatedAt;
  data['deleted_at'] = entity.deletedAt;
  return data;
}

extension ContractDetailRowExtension on ContractDetailRow {
  ContractDetailRow copyWith({
    String? id,
    String? employerId,
    String? agencyId,
    String? startDate,
    String? endDate,
    String? file,
    int? status,
    String? createdAt,
    String? updatedAt,
    String? deletedAt,
  }) {
    return ContractDetailRow()
      ..id = id ?? this.id
      ..employerId = employerId ?? this.employerId
      ..agencyId = agencyId ?? this.agencyId
      ..startDate = startDate ?? this.startDate
      ..endDate = endDate ?? this.endDate
      ..file = file ?? this.file
      ..status = status ?? this.status
      ..createdAt = createdAt ?? this.createdAt
      ..updatedAt = updatedAt ?? this.updatedAt
      ..deletedAt = deletedAt ?? this.deletedAt;
  }
}