import 'package:domain/generated/json/base/json_convert_content.dart';
import 'package:domain/entity/facility_page_entity.dart';
import 'package:domain/entity/id_name_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 IdNameEntity? account = jsonConvert.convert<IdNameEntity>(json['account']);
  if (account != null) {
    facilityDetail.account = account;
  }
  final FacilityOrder? order = jsonConvert.convert<FacilityOrder>(json['order']);
  if (order != null) {
    facilityDetail.order = order;
  }
  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();
  data['order'] = entity.order?.toJson();
  return data;
}

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

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? deposit = jsonConvert.convert<String>(json['deposit']);
  if (deposit != null) {
    facilityPageListBooking.deposit = deposit;
  }
  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'] = entity.deposit;
  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? deposit,
    String? depositRefund,
    String? depositRefundAt,
  }) {
    return FacilityPageListBooking()
      ..id = id ?? this.id
      ..date = date ?? this.date
      ..start = start ?? this.start
      ..end = end ?? this.end
      ..deposit = deposit ?? this.deposit
      ..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 IdNameEntity? type = jsonConvert.convert<IdNameEntity>(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,
    IdNameEntity? type,
  }) {
    return FacilityPageListFacility()
      ..id = id ?? this.id
      ..name = name ?? this.name
      ..type = type ?? this.type;
  }
}

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;
  }
}

FacilityOrder $FacilityOrderFromJson(Map<String, dynamic> json) {
  final FacilityOrder facilityOrder = FacilityOrder();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    facilityOrder.id = id;
  }
  final String? totalAmount = jsonConvert.convert<String>(json['total_amount']);
  if (totalAmount != null) {
    facilityOrder.totalAmount = totalAmount;
  }
  final String? orderAmount = jsonConvert.convert<String>(json['order_amount']);
  if (orderAmount != null) {
    facilityOrder.orderAmount = orderAmount;
  }
  final String? depositAmount = jsonConvert.convert<String>(json['deposit_amount']);
  if (depositAmount != null) {
    facilityOrder.depositAmount = depositAmount;
  }
  final int? paymentStatus = jsonConvert.convert<int>(json['payment_status']);
  if (paymentStatus != null) {
    facilityOrder.paymentStatus = paymentStatus;
  }
  final int? refundStatus = jsonConvert.convert<int>(json['refund_status']);
  if (refundStatus != null) {
    facilityOrder.refundStatus = refundStatus;
  }
  return facilityOrder;
}

Map<String, dynamic> $FacilityOrderToJson(FacilityOrder entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['total_amount'] = entity.totalAmount;
  data['order_amount'] = entity.orderAmount;
  data['deposit_amount'] = entity.depositAmount;
  data['payment_status'] = entity.paymentStatus;
  data['refund_status'] = entity.refundStatus;
  return data;
}

extension FacilityOrderExtension on FacilityOrder {
  FacilityOrder copyWith({
    String? id,
    String? totalAmount,
    String? orderAmount,
    String? depositAmount,
    int? paymentStatus,
    int? refundStatus,
  }) {
    return FacilityOrder()
      ..id = id ?? this.id
      ..totalAmount = totalAmount ?? this.totalAmount
      ..orderAmount = orderAmount ?? this.orderAmount
      ..depositAmount = depositAmount ?? this.depositAmount
      ..paymentStatus = paymentStatus ?? this.paymentStatus
      ..refundStatus = refundStatus ?? this.refundStatus;
  }
}