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

FacilityPageEntity $FacilityPageEntityFromJson(Map<String, dynamic> json) {
  final FacilityPageEntity facilityPageEntity = FacilityPageEntity();
  final int? count = jsonConvert.convert<int>(json['count']);
  if (count != null) {
    facilityPageEntity.count = count;
  }
  final int? page = jsonConvert.convert<int>(json['page']);
  if (page != null) {
    facilityPageEntity.page = page;
  }
  final int? limit = jsonConvert.convert<int>(json['limit']);
  if (limit != null) {
    facilityPageEntity.limit = limit;
  }
  final int? countPage = jsonConvert.convert<int>(json['count_page']);
  if (countPage != null) {
    facilityPageEntity.countPage = countPage;
  }
  final String? totalDeposit = jsonConvert.convert<String>(
      json['total_deposit']);
  if (totalDeposit != null) {
    facilityPageEntity.totalDeposit = totalDeposit;
  }
  final List<FacilityDetail>? list = (json['list'] as List<dynamic>?)
      ?.map(
          (e) => jsonConvert.convert<FacilityDetail>(e) as FacilityDetail)
      .toList();
  if (list != null) {
    facilityPageEntity.list = list;
  }
  return facilityPageEntity;
}

Map<String, dynamic> $FacilityPageEntityToJson(FacilityPageEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['count'] = entity.count;
  data['page'] = entity.page;
  data['limit'] = entity.limit;
  data['count_page'] = entity.countPage;
  data['total_deposit'] = entity.totalDeposit;
  data['list'] = entity.list?.map((v) => v.toJson()).toList();
  return data;
}

extension FacilityPageEntityExtension on FacilityPageEntity {
  FacilityPageEntity copyWith({
    int? count,
    int? page,
    int? limit,
    int? countPage,
    String? totalDeposit,
    List<FacilityDetail>? list,
  }) {
    return FacilityPageEntity()
      ..count = count ?? this.count
      ..page = page ?? this.page
      ..limit = limit ?? this.limit
      ..countPage = countPage ?? this.countPage
      ..totalDeposit = totalDeposit ?? this.totalDeposit
      ..list = list ?? this.list;
  }
}

FacilityDetail $FacilityDetailFromJson(Map<String, dynamic> json) {
  final FacilityDetail facilityDetail = FacilityDetail();
  final FacilityPageListBooking? booking = jsonConvert.convert<
      FacilityPageListBooking>(json['booking']);
  if (booking != null) {
    facilityDetail.booking = booking;
  }
  final FacilityPageListFacility? facility = jsonConvert.convert<
      FacilityPageListFacility>(json['facility']);
  if (facility != null) {
    facilityDetail.facility = facility;
  }
  final FacilityPageListTimePeriod? timePeriod = jsonConvert.convert<
      FacilityPageListTimePeriod>(json['time_period']);
  if (timePeriod != null) {
    facilityDetail.timePeriod = timePeriod;
  }
  final FacilityPageListAccount? account = jsonConvert.convert<
      FacilityPageListAccount>(json['account']);
  if (account != null) {
    facilityDetail.account = account;
  }
  return facilityDetail;
}

Map<String, dynamic> $FacilityDetailToJson(FacilityDetail entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['booking'] = entity.booking?.toJson();
  data['facility'] = entity.facility?.toJson();
  data['time_period'] = entity.timePeriod?.toJson();
  data['account'] = entity.account?.toJson();
  return data;
}

extension FacilityDetailExtension on FacilityDetail {
  FacilityDetail copyWith({
    FacilityPageListBooking? booking,
    FacilityPageListFacility? facility,
    FacilityPageListTimePeriod? timePeriod,
    FacilityPageListAccount? account,
  }) {
    return FacilityDetail()
      ..booking = booking ?? this.booking
      ..facility = facility ?? this.facility
      ..timePeriod = timePeriod ?? this.timePeriod
      ..account = account ?? this.account;
  }
}

FacilityPageListBooking $FacilityPageListBookingFromJson(
    Map<String, dynamic> json) {
  final FacilityPageListBooking facilityPageListBooking = FacilityPageListBooking();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    facilityPageListBooking.id = id;
  }
  final String? date = jsonConvert.convert<String>(json['date']);
  if (date != null) {
    facilityPageListBooking.date = date;
  }
  final String? start = jsonConvert.convert<String>(json['start']);
  if (start != null) {
    facilityPageListBooking.start = start;
  }
  final String? end = jsonConvert.convert<String>(json['end']);
  if (end != null) {
    facilityPageListBooking.end = end;
  }
  final String? depositPaid = jsonConvert.convert<String>(json['deposit_paid']);
  if (depositPaid != null) {
    facilityPageListBooking.depositPaid = depositPaid;
  }
  final String? depositRefund = jsonConvert.convert<String>(
      json['deposit_refund']);
  if (depositRefund != null) {
    facilityPageListBooking.depositRefund = depositRefund;
  }
  final String? depositRefundAt = jsonConvert.convert<String>(
      json['deposit_refund_at']);
  if (depositRefundAt != null) {
    facilityPageListBooking.depositRefundAt = depositRefundAt;
  }
  return facilityPageListBooking;
}

Map<String, dynamic> $FacilityPageListBookingToJson(
    FacilityPageListBooking entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['date'] = entity.date;
  data['start'] = entity.start;
  data['end'] = entity.end;
  data['deposit_paid'] = entity.depositPaid;
  data['deposit_refund'] = entity.depositRefund;
  data['deposit_refund_at'] = entity.depositRefundAt;
  return data;
}

extension FacilityPageListBookingExtension on FacilityPageListBooking {
  FacilityPageListBooking copyWith({
    String? id,
    String? date,
    String? start,
    String? end,
    String? depositPaid,
    String? depositRefund,
    String? depositRefundAt,
  }) {
    return FacilityPageListBooking()
      ..id = id ?? this.id
      ..date = date ?? this.date
      ..start = start ?? this.start
      ..end = end ?? this.end
      ..depositPaid = depositPaid ?? this.depositPaid
      ..depositRefund = depositRefund ?? this.depositRefund
      ..depositRefundAt = depositRefundAt ?? this.depositRefundAt;
  }
}

FacilityPageListFacility $FacilityPageListFacilityFromJson(
    Map<String, dynamic> json) {
  final FacilityPageListFacility facilityPageListFacility = FacilityPageListFacility();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    facilityPageListFacility.id = id;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    facilityPageListFacility.name = name;
  }
  final FacilityPageListFacilityType? type = jsonConvert.convert<
      FacilityPageListFacilityType>(json['type']);
  if (type != null) {
    facilityPageListFacility.type = type;
  }
  return facilityPageListFacility;
}

Map<String, dynamic> $FacilityPageListFacilityToJson(
    FacilityPageListFacility entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['name'] = entity.name;
  data['type'] = entity.type?.toJson();
  return data;
}

extension FacilityPageListFacilityExtension on FacilityPageListFacility {
  FacilityPageListFacility copyWith({
    String? id,
    String? name,
    FacilityPageListFacilityType? type,
  }) {
    return FacilityPageListFacility()
      ..id = id ?? this.id
      ..name = name ?? this.name
      ..type = type ?? this.type;
  }
}

FacilityPageListFacilityType $FacilityPageListFacilityTypeFromJson(
    Map<String, dynamic> json) {
  final FacilityPageListFacilityType facilityPageListFacilityType = FacilityPageListFacilityType();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    facilityPageListFacilityType.id = id;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    facilityPageListFacilityType.name = name;
  }
  return facilityPageListFacilityType;
}

Map<String, dynamic> $FacilityPageListFacilityTypeToJson(
    FacilityPageListFacilityType entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['name'] = entity.name;
  return data;
}

extension FacilityPageListFacilityTypeExtension on FacilityPageListFacilityType {
  FacilityPageListFacilityType copyWith({
    String? id,
    String? name,
  }) {
    return FacilityPageListFacilityType()
      ..id = id ?? this.id
      ..name = name ?? this.name;
  }
}

FacilityPageListTimePeriod $FacilityPageListTimePeriodFromJson(
    Map<String, dynamic> json) {
  final FacilityPageListTimePeriod facilityPageListTimePeriod = FacilityPageListTimePeriod();
  final String? price = jsonConvert.convert<String>(json['price']);
  if (price != null) {
    facilityPageListTimePeriod.price = price;
  }
  final String? deposit = jsonConvert.convert<String>(json['deposit']);
  if (deposit != null) {
    facilityPageListTimePeriod.deposit = deposit;
  }
  return facilityPageListTimePeriod;
}

Map<String, dynamic> $FacilityPageListTimePeriodToJson(
    FacilityPageListTimePeriod entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['price'] = entity.price;
  data['deposit'] = entity.deposit;
  return data;
}

extension FacilityPageListTimePeriodExtension on FacilityPageListTimePeriod {
  FacilityPageListTimePeriod copyWith({
    String? price,
    String? deposit,
  }) {
    return FacilityPageListTimePeriod()
      ..price = price ?? this.price
      ..deposit = deposit ?? this.deposit;
  }
}

FacilityPageListAccount $FacilityPageListAccountFromJson(
    Map<String, dynamic> json) {
  final FacilityPageListAccount facilityPageListAccount = FacilityPageListAccount();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    facilityPageListAccount.id = id;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    facilityPageListAccount.name = name;
  }
  return facilityPageListAccount;
}

Map<String, dynamic> $FacilityPageListAccountToJson(
    FacilityPageListAccount entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['name'] = entity.name;
  return data;
}

extension FacilityPageListAccountExtension on FacilityPageListAccount {
  FacilityPageListAccount copyWith({
    String? id,
    String? name,
  }) {
    return FacilityPageListAccount()
      ..id = id ?? this.id
      ..name = name ?? this.name;
  }
}