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

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

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

extension AgencyTableEntityExtension on AgencyTableEntity {
  AgencyTableEntity copyWith({
    int? total,
    List<AgencyTableRows>? rows,
  }) {
    return AgencyTableEntity()
      ..total = total ?? this.total
      ..rows = rows ?? this.rows;
  }
}

AgencyTableRows $AgencyTableRowsFromJson(Map<String, dynamic> json) {
  final AgencyTableRows agencyTableRows = AgencyTableRows();
  final String? pivotId = jsonConvert.convert<String>(json['pivot_id']);
  if (pivotId != null) {
    agencyTableRows.pivotId = pivotId;
  }
  final String? agencyName = jsonConvert.convert<String>(json['agency_name']);
  if (agencyName != null) {
    agencyTableRows.agencyName = agencyName;
  }
  final String? uenNo = jsonConvert.convert<String>(json['uen_no']);
  if (uenNo != null) {
    agencyTableRows.uenNo = uenNo;
  }
  final String? contactPerson = jsonConvert.convert<String>(json['contact_person']);
  if (contactPerson != null) {
    agencyTableRows.contactPerson = contactPerson;
  }
  final String? contactNo = jsonConvert.convert<String>(json['contact_no']);
  if (contactNo != null) {
    agencyTableRows.contactNo = contactNo;
  }
  final String? contactEmail = jsonConvert.convert<String>(json['contact_email']);
  if (contactEmail != null) {
    agencyTableRows.contactEmail = contactEmail;
  }
  final String? status = jsonConvert.convert<String>(json['status']);
  if (status != null) {
    agencyTableRows.status = status;
  }
  final String? regUrl = jsonConvert.convert<String>(json['reg_url']);
  if (regUrl != null) {
    agencyTableRows.regUrl = regUrl;
  }
  final String? createdAt = jsonConvert.convert<String>(json['created_at']);
  if (createdAt != null) {
    agencyTableRows.createdAt = createdAt;
  }
  return agencyTableRows;
}

Map<String, dynamic> $AgencyTableRowsToJson(AgencyTableRows entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['pivot_id'] = entity.pivotId;
  data['agency_name'] = entity.agencyName;
  data['uen_no'] = entity.uenNo;
  data['contact_person'] = entity.contactPerson;
  data['contact_no'] = entity.contactNo;
  data['contact_email'] = entity.contactEmail;
  data['status'] = entity.status;
  data['reg_url'] = entity.regUrl;
  data['created_at'] = entity.createdAt;
  return data;
}

extension AgencyTableRowsExtension on AgencyTableRows {
  AgencyTableRows copyWith({
    String? pivotId,
    String? agencyName,
    String? uenNo,
    String? contactPerson,
    String? contactNo,
    String? contactEmail,
    String? status,
    String? regUrl,
    String? createdAt,
  }) {
    return AgencyTableRows()
      ..pivotId = pivotId ?? this.pivotId
      ..agencyName = agencyName ?? this.agencyName
      ..uenNo = uenNo ?? this.uenNo
      ..contactPerson = contactPerson ?? this.contactPerson
      ..contactNo = contactNo ?? this.contactNo
      ..contactEmail = contactEmail ?? this.contactEmail
      ..status = status ?? this.status
      ..regUrl = regUrl ?? this.regUrl
      ..createdAt = createdAt ?? this.createdAt;
  }
}