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

ContractTableEntity $ContractTableEntityFromJson(Map<String, dynamic> json) {
  final ContractTableEntity contractTableEntity = ContractTableEntity();
  final int? total = jsonConvert.convert<int>(json['total']);
  if (total != null) {
    contractTableEntity.total = total;
  }
  final List<ContractTableRows>? rows = (json['rows'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<ContractTableRows>(e) as ContractTableRows).toList();
  if (rows != null) {
    contractTableEntity.rows = rows;
  }
  return contractTableEntity;
}

Map<String, dynamic> $ContractTableEntityToJson(ContractTableEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['total'] = entity.total;
  data['rows'] = entity.rows.map((v) => v.toJson()).toList();
  return data;
}

extension ContractTableEntityExtension on ContractTableEntity {
  ContractTableEntity copyWith({
    int? total,
    List<ContractTableRows>? rows,
  }) {
    return ContractTableEntity()
      ..total = total ?? this.total
      ..rows = rows ?? this.rows;
  }
}

ContractTableRows $ContractTableRowsFromJson(Map<String, dynamic> json) {
  final ContractTableRows contractTableRows = ContractTableRows();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    contractTableRows.id = id;
  }
  final String? agencyName = jsonConvert.convert<String>(json['agency_name']);
  if (agencyName != null) {
    contractTableRows.agencyName = agencyName;
  }
  final String? uenNo = jsonConvert.convert<String>(json['uen_no']);
  if (uenNo != null) {
    contractTableRows.uenNo = uenNo;
  }
  final String? contactPerson = jsonConvert.convert<String>(json['contact_person']);
  if (contactPerson != null) {
    contractTableRows.contactPerson = contactPerson;
  }
  final String? startDate = jsonConvert.convert<String>(json['start_date']);
  if (startDate != null) {
    contractTableRows.startDate = startDate;
  }
  final String? endDate = jsonConvert.convert<String>(json['end_date']);
  if (endDate != null) {
    contractTableRows.endDate = endDate;
  }
  final String? file = jsonConvert.convert<String>(json['file']);
  if (file != null) {
    contractTableRows.file = file;
  }
  final int? positionNum = jsonConvert.convert<int>(json['position_num']);
  if (positionNum != null) {
    contractTableRows.positionNum = positionNum;
  }
  final int? status = jsonConvert.convert<int>(json['status']);
  if (status != null) {
    contractTableRows.status = status;
  }
  final String? createdAt = jsonConvert.convert<String>(json['created_at']);
  if (createdAt != null) {
    contractTableRows.createdAt = createdAt;
  }
  return contractTableRows;
}

Map<String, dynamic> $ContractTableRowsToJson(ContractTableRows entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['agency_name'] = entity.agencyName;
  data['uen_no'] = entity.uenNo;
  data['contact_person'] = entity.contactPerson;
  data['start_date'] = entity.startDate;
  data['end_date'] = entity.endDate;
  data['file'] = entity.file;
  data['position_num'] = entity.positionNum;
  data['status'] = entity.status;
  data['created_at'] = entity.createdAt;
  return data;
}

extension ContractTableRowsExtension on ContractTableRows {
  ContractTableRows copyWith({
    String? id,
    String? agencyName,
    String? uenNo,
    String? contactPerson,
    String? startDate,
    String? endDate,
    String? file,
    int? positionNum,
    int? status,
    String? createdAt,
  }) {
    return ContractTableRows()
      ..id = id ?? this.id
      ..agencyName = agencyName ?? this.agencyName
      ..uenNo = uenNo ?? this.uenNo
      ..contactPerson = contactPerson ?? this.contactPerson
      ..startDate = startDate ?? this.startDate
      ..endDate = endDate ?? this.endDate
      ..file = file ?? this.file
      ..positionNum = positionNum ?? this.positionNum
      ..status = status ?? this.status
      ..createdAt = createdAt ?? this.createdAt;
  }
}