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


ContractPositionAddOptionEntity $ContractPositionAddOptionEntityFromJson(Map<String, dynamic> json) {
  final ContractPositionAddOptionEntity contractPositionAddOptionEntity = ContractPositionAddOptionEntity();
  final String? contractId = jsonConvert.convert<String>(json['contract_id']);
  if (contractId != null) {
    contractPositionAddOptionEntity.contractId = contractId;
  }
  final String? startDate = jsonConvert.convert<String>(json['start_date']);
  if (startDate != null) {
    contractPositionAddOptionEntity.startDate = startDate;
  }
  final String? endDate = jsonConvert.convert<String>(json['end_date']);
  if (endDate != null) {
    contractPositionAddOptionEntity.endDate = endDate;
  }
  final String? agencyName = jsonConvert.convert<String>(json['agency_name']);
  if (agencyName != null) {
    contractPositionAddOptionEntity.agencyName = agencyName;
  }
  final List<IndexOptionEntity>? positionList = (json['position_list'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<IndexOptionEntity>(e) as IndexOptionEntity).toList();
  if (positionList != null) {
    contractPositionAddOptionEntity.positionList = positionList;
  }
  return contractPositionAddOptionEntity;
}

Map<String, dynamic> $ContractPositionAddOptionEntityToJson(ContractPositionAddOptionEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['contract_id'] = entity.contractId;
  data['start_date'] = entity.startDate;
  data['end_date'] = entity.endDate;
  data['agency_name'] = entity.agencyName;
  data['position_list'] = entity.positionList.map((v) => v.toJson()).toList();
  return data;
}

extension ContractPositionAddOptionEntityExtension on ContractPositionAddOptionEntity {
  ContractPositionAddOptionEntity copyWith({
    String? contractId,
    String? startDate,
    String? endDate,
    String? agencyName,
    List<IndexOptionEntity>? positionList,
  }) {
    return ContractPositionAddOptionEntity()
      ..contractId = contractId ?? this.contractId
      ..startDate = startDate ?? this.startDate
      ..endDate = endDate ?? this.endDate
      ..agencyName = agencyName ?? this.agencyName
      ..positionList = positionList ?? this.positionList;
  }
}