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

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

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

extension UKTemplateEntityExtension on UKTemplateEntity {
  UKTemplateEntity copyWith({
    int? total,
    List<UKTemplateRows>? rows,
  }) {
    return UKTemplateEntity()
      ..total = total ?? this.total
      ..rows = rows ?? this.rows;
  }
}

UKTemplateRows $UKTemplateRowsFromJson(Map<String, dynamic> json) {
  final UKTemplateRows uKTemplateRows = UKTemplateRows();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    uKTemplateRows.id = id;
  }
  final String? jobTitle = jsonConvert.convert<String>(json['job_title']);
  if (jobTitle != null) {
    uKTemplateRows.jobTitle = jobTitle;
  }
  final String? vehicle = jsonConvert.convert<String>(json['vehicle']);
  if (vehicle != null) {
    uKTemplateRows.vehicle = vehicle;
  }
  final String? certificate = jsonConvert.convert<String>(json['certificate']);
  if (certificate != null) {
    uKTemplateRows.certificate = certificate;
  }
  final String? createdBy = jsonConvert.convert<String>(json['created_by']);
  if (createdBy != null) {
    uKTemplateRows.createdBy = createdBy;
  }
  final String? createdAt = jsonConvert.convert<String>(json['created_at']);
  if (createdAt != null) {
    uKTemplateRows.createdAt = createdAt;
  }
  return uKTemplateRows;
}

Map<String, dynamic> $UKTemplateRowsToJson(UKTemplateRows entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['job_title'] = entity.jobTitle;
  data['vehicle'] = entity.vehicle;
  data['certificate'] = entity.certificate;
  data['created_by'] = entity.createdBy;
  data['created_at'] = entity.createdAt;
  return data;
}

extension UKTemplateRowsExtension on UKTemplateRows {
  UKTemplateRows copyWith({
    String? id,
    String? jobTitle,
    String? vehicle,
    String? certificate,
    String? createdBy,
    String? createdAt,
  }) {
    return UKTemplateRows()
      ..id = id ?? this.id
      ..jobTitle = jobTitle ?? this.jobTitle
      ..vehicle = vehicle ?? this.vehicle
      ..certificate = certificate ?? this.certificate
      ..createdBy = createdBy ?? this.createdBy
      ..createdAt = createdAt ?? this.createdAt;
  }
}