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


AgencyDetailEntity $AgencyDetailEntityFromJson(Map<String, dynamic> json) {
  final AgencyDetailEntity agencyDetailEntity = AgencyDetailEntity();
  final AgencyDetailPivot? pivot = jsonConvert.convert<AgencyDetailPivot>(json['pivot']);
  if (pivot != null) {
    agencyDetailEntity.pivot = pivot;
  }
  final List<IndexOptionEntity>? statusRadios = (json['status_radios'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<IndexOptionEntity>(e) as IndexOptionEntity).toList();
  if (statusRadios != null) {
    agencyDetailEntity.statusRadios = statusRadios;
  }
  final String? contractStart = jsonConvert.convert<String>(json['contract_start']);
  if (contractStart != null) {
    agencyDetailEntity.contractStart = contractStart;
  }
  final String? contractEnd = jsonConvert.convert<String>(json['contract_end']);
  if (contractEnd != null) {
    agencyDetailEntity.contractEnd = contractEnd;
  }
  return agencyDetailEntity;
}

Map<String, dynamic> $AgencyDetailEntityToJson(AgencyDetailEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['pivot'] = entity.pivot?.toJson();
  data['status_radios'] = entity.statusRadios.map((v) => v.toJson()).toList();
  data['contract_start'] = entity.contractStart;
  data['contract_end'] = entity.contractEnd;
  return data;
}

extension AgencyDetailEntityExtension on AgencyDetailEntity {
  AgencyDetailEntity copyWith({
    AgencyDetailPivot? pivot,
    List<IndexOptionEntity>? statusRadios,
    String? contractStart,
    String? contractEnd,
  }) {
    return AgencyDetailEntity()
      ..pivot = pivot ?? this.pivot
      ..statusRadios = statusRadios ?? this.statusRadios
      ..contractStart = contractStart ?? this.contractStart
      ..contractEnd = contractEnd ?? this.contractEnd;
  }
}

AgencyDetailPivot $AgencyDetailPivotFromJson(Map<String, dynamic> json) {
  final AgencyDetailPivot agencyDetailPivot = AgencyDetailPivot();
  final String? pivotId = jsonConvert.convert<String>(json['id']);
  if (pivotId != null) {
    agencyDetailPivot.pivotId = pivotId;
  }
  final String? employerId = jsonConvert.convert<String>(json['employer_id']);
  if (employerId != null) {
    agencyDetailPivot.employerId = employerId;
  }
  final String? agencyId = jsonConvert.convert<String>(json['agency_id']);
  if (agencyId != null) {
    agencyDetailPivot.agencyId = agencyId;
  }
  final String? agencyName = jsonConvert.convert<String>(json['agency_name']);
  if (agencyName != null) {
    agencyDetailPivot.agencyName = agencyName;
  }
  final String? uenNo = jsonConvert.convert<String>(json['uen_no']);
  if (uenNo != null) {
    agencyDetailPivot.uenNo = uenNo;
  }
  final String? companyNo = jsonConvert.convert<String>(json['company_no']);
  if (companyNo != null) {
    agencyDetailPivot.companyNo = companyNo;
  }
  final String? contactPerson = jsonConvert.convert<String>(json['contact_person']);
  if (contactPerson != null) {
    agencyDetailPivot.contactPerson = contactPerson;
  }
  final String? contactNo = jsonConvert.convert<String>(json['contact_no']);
  if (contactNo != null) {
    agencyDetailPivot.contactNo = contactNo;
  }
  final String? contactEmail = jsonConvert.convert<String>(json['contact_email']);
  if (contactEmail != null) {
    agencyDetailPivot.contactEmail = contactEmail;
  }
  final String? address = jsonConvert.convert<String>(json['address']);
  if (address != null) {
    agencyDetailPivot.address = address;
  }
  final String? contractStart = jsonConvert.convert<String>(json['contract_start']);
  if (contractStart != null) {
    agencyDetailPivot.contractStart = contractStart;
  }
  final String? contractEnd = jsonConvert.convert<String>(json['contract_end']);
  if (contractEnd != null) {
    agencyDetailPivot.contractEnd = contractEnd;
  }
  final String? attachment = jsonConvert.convert<String>(json['attachment']);
  if (attachment != null) {
    agencyDetailPivot.attachment = attachment;
  }
  final int? status = jsonConvert.convert<int>(json['status']);
  if (status != null) {
    agencyDetailPivot.status = status;
  }
  final String? regToken = jsonConvert.convert<String>(json['reg_token']);
  if (regToken != null) {
    agencyDetailPivot.regToken = regToken;
  }
  final String? createdAt = jsonConvert.convert<String>(json['created_at']);
  if (createdAt != null) {
    agencyDetailPivot.createdAt = createdAt;
  }
  final String? updatedAt = jsonConvert.convert<String>(json['updated_at']);
  if (updatedAt != null) {
    agencyDetailPivot.updatedAt = updatedAt;
  }
  return agencyDetailPivot;
}

Map<String, dynamic> $AgencyDetailPivotToJson(AgencyDetailPivot entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.pivotId;
  data['employer_id'] = entity.employerId;
  data['agency_id'] = entity.agencyId;
  data['agency_name'] = entity.agencyName;
  data['uen_no'] = entity.uenNo;
  data['company_no'] = entity.companyNo;
  data['contact_person'] = entity.contactPerson;
  data['contact_no'] = entity.contactNo;
  data['contact_email'] = entity.contactEmail;
  data['address'] = entity.address;
  data['contract_start'] = entity.contractStart;
  data['contract_end'] = entity.contractEnd;
  data['attachment'] = entity.attachment;
  data['status'] = entity.status;
  data['reg_token'] = entity.regToken;
  data['created_at'] = entity.createdAt;
  data['updated_at'] = entity.updatedAt;
  return data;
}

extension AgencyDetailPivotExtension on AgencyDetailPivot {
  AgencyDetailPivot copyWith({
    String? pivotId,
    String? employerId,
    String? agencyId,
    String? agencyName,
    String? uenNo,
    String? companyNo,
    String? contactPerson,
    String? contactNo,
    String? contactEmail,
    String? address,
    String? contractStart,
    String? contractEnd,
    String? attachment,
    int? status,
    String? regToken,
    String? createdAt,
    String? updatedAt,
  }) {
    return AgencyDetailPivot()
      ..pivotId = pivotId ?? this.pivotId
      ..employerId = employerId ?? this.employerId
      ..agencyId = agencyId ?? this.agencyId
      ..agencyName = agencyName ?? this.agencyName
      ..uenNo = uenNo ?? this.uenNo
      ..companyNo = companyNo ?? this.companyNo
      ..contactPerson = contactPerson ?? this.contactPerson
      ..contactNo = contactNo ?? this.contactNo
      ..contactEmail = contactEmail ?? this.contactEmail
      ..address = address ?? this.address
      ..contractStart = contractStart ?? this.contractStart
      ..contractEnd = contractEnd ?? this.contractEnd
      ..attachment = attachment ?? this.attachment
      ..status = status ?? this.status
      ..regToken = regToken ?? this.regToken
      ..createdAt = createdAt ?? this.createdAt
      ..updatedAt = updatedAt ?? this.updatedAt;
  }
}