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

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

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

extension ContractPositionTableEntityExtension on ContractPositionTableEntity {
  ContractPositionTableEntity copyWith({
    int? total,
    List<ContractPositionTableRows>? rows,
  }) {
    return ContractPositionTableEntity()
      ..total = total ?? this.total
      ..rows = rows ?? this.rows;
  }
}

ContractPositionTableRows $ContractPositionTableRowsFromJson(Map<String, dynamic> json) {
  final ContractPositionTableRows contractPositionTableRows = ContractPositionTableRows();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    contractPositionTableRows.id = id;
  }
  final String? agencyName = jsonConvert.convert<String>(json['agency_name']);
  if (agencyName != null) {
    contractPositionTableRows.agencyName = agencyName;
  }
  final String? positionId = jsonConvert.convert<String>(json['position_id']);
  if (positionId != null) {
    contractPositionTableRows.positionId = positionId;
  }
  final String? position = jsonConvert.convert<String>(json['position']);
  if (position != null) {
    contractPositionTableRows.position = position;
  }
  final String? hourlyRate = jsonConvert.convert<String>(json['hourly_rate']);
  if (hourlyRate != null) {
    contractPositionTableRows.hourlyRate = hourlyRate;
  }
  final String? contract = jsonConvert.convert<String>(json['contract']);
  if (contract != null) {
    contractPositionTableRows.contract = contract;
  }
  final String? createdAt = jsonConvert.convert<String>(json['created_at']);
  if (createdAt != null) {
    contractPositionTableRows.createdAt = createdAt;
  }
  return contractPositionTableRows;
}

Map<String, dynamic> $ContractPositionTableRowsToJson(ContractPositionTableRows entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['agency_name'] = entity.agencyName;
  data['position_id'] = entity.positionId;
  data['position'] = entity.position;
  data['hourly_rate'] = entity.hourlyRate;
  data['contract'] = entity.contract;
  data['created_at'] = entity.createdAt;
  return data;
}

extension ContractPositionTableRowsExtension on ContractPositionTableRows {
  ContractPositionTableRows copyWith({
    String? id,
    String? agencyName,
    String? positionId,
    String? position,
    String? hourlyRate,
    String? contract,
    String? createdAt,
  }) {
    return ContractPositionTableRows()
      ..id = id ?? this.id
      ..agencyName = agencyName ?? this.agencyName
      ..positionId = positionId ?? this.positionId
      ..position = position ?? this.position
      ..hourlyRate = hourlyRate ?? this.hourlyRate
      ..contract = contract ?? this.contract
      ..createdAt = createdAt ?? this.createdAt;
  }
}