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

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

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

extension JobTemplateSGEntityExtension on JobTemplateSGEntity {
  JobTemplateSGEntity copyWith({
    int? total,
    List<JobTemplateSGRows>? rows,
  }) {
    return JobTemplateSGEntity()
      ..total = total ?? this.total
      ..rows = rows ?? this.rows;
  }
}

JobTemplateSGRows $JobTemplateSGRowsFromJson(Map<String, dynamic> json) {
  final JobTemplateSGRows jobTemplateSGRows = JobTemplateSGRows();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    jobTemplateSGRows.id = id;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    jobTemplateSGRows.name = name;
  }
  final String? contact = jsonConvert.convert<String>(json['contact']);
  if (contact != null) {
    jobTemplateSGRows.contact = contact;
  }
  final String? createdBy = jsonConvert.convert<String>(json['created_by']);
  if (createdBy != null) {
    jobTemplateSGRows.createdBy = createdBy;
  }
  final String? contactNo = jsonConvert.convert<String>(json['contact_no']);
  if (contactNo != null) {
    jobTemplateSGRows.contactNo = contactNo;
  }
  final String? createdAt = jsonConvert.convert<String>(json['created_at']);
  if (createdAt != null) {
    jobTemplateSGRows.createdAt = createdAt;
  }
  final String? updatedAt = jsonConvert.convert<String>(json['updated_at']);
  if (updatedAt != null) {
    jobTemplateSGRows.updatedAt = updatedAt;
  }
  final List<String>? actionList = (json['action_list'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<String>(e) as String).toList();
  if (actionList != null) {
    jobTemplateSGRows.actionList = actionList;
  }
  final String? note = jsonConvert.convert<String>(json['note']);
  if (note != null) {
    jobTemplateSGRows.note = note;
  }
  return jobTemplateSGRows;
}

Map<String, dynamic> $JobTemplateSGRowsToJson(JobTemplateSGRows entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['name'] = entity.name;
  data['contact'] = entity.contact;
  data['created_by'] = entity.createdBy;
  data['contact_no'] = entity.contactNo;
  data['created_at'] = entity.createdAt;
  data['updated_at'] = entity.updatedAt;
  data['action_list'] = entity.actionList;
  data['note'] = entity.note;
  return data;
}

extension JobTemplateSGRowsExtension on JobTemplateSGRows {
  JobTemplateSGRows copyWith({
    int? id,
    String? name,
    String? contact,
    String? createdBy,
    String? contactNo,
    String? createdAt,
    String? updatedAt,
    List<String>? actionList,
    String? note,
  }) {
    return JobTemplateSGRows()
      ..id = id ?? this.id
      ..name = name ?? this.name
      ..contact = contact ?? this.contact
      ..createdBy = createdBy ?? this.createdBy
      ..contactNo = contactNo ?? this.contactNo
      ..createdAt = createdAt ?? this.createdAt
      ..updatedAt = updatedAt ?? this.updatedAt
      ..actionList = actionList ?? this.actionList
      ..note = note ?? this.note;
  }
}