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


PaymentPageEntity $PaymentPageEntityFromJson(Map<String, dynamic> json) {
  final PaymentPageEntity paymentPageEntity = PaymentPageEntity();
  final int? count = jsonConvert.convert<int>(json['count']);
  if (count != null) {
    paymentPageEntity.count = count;
  }
  final int? page = jsonConvert.convert<int>(json['page']);
  if (page != null) {
    paymentPageEntity.page = page;
  }
  final int? limit = jsonConvert.convert<int>(json['limit']);
  if (limit != null) {
    paymentPageEntity.limit = limit;
  }
  final int? countPage = jsonConvert.convert<int>(json['count_page']);
  if (countPage != null) {
    paymentPageEntity.countPage = countPage;
  }
  final List<PaymentPageList>? list = (json['list'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<PaymentPageList>(e) as PaymentPageList).toList();
  if (list != null) {
    paymentPageEntity.list = list;
  }
  return paymentPageEntity;
}

Map<String, dynamic> $PaymentPageEntityToJson(PaymentPageEntity 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['list'] = entity.list.map((v) => v.toJson()).toList();
  return data;
}

extension PaymentPageEntityExtension on PaymentPageEntity {
  PaymentPageEntity copyWith({
    int? count,
    int? page,
    int? limit,
    int? countPage,
    List<PaymentPageList>? list,
  }) {
    return PaymentPageEntity()
      ..count = count ?? this.count
      ..page = page ?? this.page
      ..limit = limit ?? this.limit
      ..countPage = countPage ?? this.countPage
      ..list = list ?? this.list;
  }
}

PaymentPageList $PaymentPageListFromJson(Map<String, dynamic> json) {
  final PaymentPageList paymentPageList = PaymentPageList();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    paymentPageList.id = id;
  }
  final String? type = jsonConvert.convert<String>(json['type']);
  if (type != null) {
    paymentPageList.type = type;
  }
  final String? title = jsonConvert.convert<String>(json['title']);
  if (title != null) {
    paymentPageList.title = title;
  }
  final String? totalAmount = jsonConvert.convert<String>(json['total_amount']);
  if (totalAmount != null) {
    paymentPageList.totalAmount = totalAmount;
  }
  final String? orderAmount = jsonConvert.convert<String>(json['order_amount']);
  if (orderAmount != null) {
    paymentPageList.orderAmount = orderAmount;
  }
  final String? depositAmount = jsonConvert.convert<String>(json['deposit_amount']);
  if (depositAmount != null) {
    paymentPageList.depositAmount = depositAmount;
  }
  final String? refundOrderAmount = jsonConvert.convert<String>(json['refund_order_amount']);
  if (refundOrderAmount != null) {
    paymentPageList.refundOrderAmount = refundOrderAmount;
  }
  final String? refundDepositAmount = jsonConvert.convert<String>(json['refund_deposit_amount']);
  if (refundDepositAmount != null) {
    paymentPageList.refundDepositAmount = refundDepositAmount;
  }
  final int? paymentStatus = jsonConvert.convert<int>(json['payment_status']);
  if (paymentStatus != null) {
    paymentPageList.paymentStatus = paymentStatus;
  }
  final int? refundStatus = jsonConvert.convert<int>(json['refund_status']);
  if (refundStatus != null) {
    paymentPageList.refundStatus = refundStatus;
  }
  final String? paidAt = jsonConvert.convert<String>(json['paid_at']);
  if (paidAt != null) {
    paymentPageList.paidAt = paidAt;
  }
  final String? refundAt = jsonConvert.convert<String>(json['refund_at']);
  if (refundAt != null) {
    paymentPageList.refundAt = refundAt;
  }
  final String? createdAt = jsonConvert.convert<String>(json['created_at']);
  if (createdAt != null) {
    paymentPageList.createdAt = createdAt;
  }
  final IdNameEntity? account = jsonConvert.convert<IdNameEntity>(json['account']);
  if (account != null) {
    paymentPageList.account = account;
  }
  final OrderableEntity? orderable = jsonConvert.convert<OrderableEntity>(json['orderable']);
  if (orderable != null) {
    paymentPageList.orderable = orderable;
  }
  return paymentPageList;
}

Map<String, dynamic> $PaymentPageListToJson(PaymentPageList entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['type'] = entity.type;
  data['title'] = entity.title;
  data['total_amount'] = entity.totalAmount;
  data['order_amount'] = entity.orderAmount;
  data['deposit_amount'] = entity.depositAmount;
  data['refund_order_amount'] = entity.refundOrderAmount;
  data['refund_deposit_amount'] = entity.refundDepositAmount;
  data['payment_status'] = entity.paymentStatus;
  data['refund_status'] = entity.refundStatus;
  data['paid_at'] = entity.paidAt;
  data['refund_at'] = entity.refundAt;
  data['created_at'] = entity.createdAt;
  data['account'] = entity.account?.toJson();
  data['orderable'] = entity.orderable?.toJson();
  return data;
}

extension PaymentPageListExtension on PaymentPageList {
  PaymentPageList copyWith({
    String? id,
    String? type,
    String? title,
    String? totalAmount,
    String? orderAmount,
    String? depositAmount,
    String? refundOrderAmount,
    String? refundDepositAmount,
    int? paymentStatus,
    int? refundStatus,
    String? paidAt,
    String? refundAt,
    String? createdAt,
    IdNameEntity? account,
    OrderableEntity? orderable,
  }) {
    return PaymentPageList()
      ..id = id ?? this.id
      ..type = type ?? this.type
      ..title = title ?? this.title
      ..totalAmount = totalAmount ?? this.totalAmount
      ..orderAmount = orderAmount ?? this.orderAmount
      ..depositAmount = depositAmount ?? this.depositAmount
      ..refundOrderAmount = refundOrderAmount ?? this.refundOrderAmount
      ..refundDepositAmount = refundDepositAmount ?? this.refundDepositAmount
      ..paymentStatus = paymentStatus ?? this.paymentStatus
      ..refundStatus = refundStatus ?? this.refundStatus
      ..paidAt = paidAt ?? this.paidAt
      ..refundAt = refundAt ?? this.refundAt
      ..createdAt = createdAt ?? this.createdAt
      ..account = account ?? this.account
      ..orderable = orderable ?? this.orderable;
  }
}

OrderableEntity $OrderableEntityFromJson(Map<String, dynamic> json) {
  final OrderableEntity orderableEntity = OrderableEntity();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    orderableEntity.id = id;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    orderableEntity.name = name;
  }
  final String? estateOnlineFormId = jsonConvert.convert<String>(json['estate_online_form_id']);
  if (estateOnlineFormId != null) {
    orderableEntity.estateOnlineFormId = estateOnlineFormId;
  }
  final String? onlineFormTypeId = jsonConvert.convert<String>(json['online_form_type_id']);
  if (onlineFormTypeId != null) {
    orderableEntity.onlineFormTypeId = onlineFormTypeId;
  }
  final String? startAt = jsonConvert.convert<String>(json['start_at']);
  if (startAt != null) {
    orderableEntity.startAt = startAt;
  }
  final String? endAt = jsonConvert.convert<String>(json['end_at']);
  if (endAt != null) {
    orderableEntity.endAt = endAt;
  }
  return orderableEntity;
}

Map<String, dynamic> $OrderableEntityToJson(OrderableEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['name'] = entity.name;
  data['estate_online_form_id'] = entity.estateOnlineFormId;
  data['online_form_type_id'] = entity.onlineFormTypeId;
  data['start_at'] = entity.startAt;
  data['end_at'] = entity.endAt;
  return data;
}

extension OrderableEntityExtension on OrderableEntity {
  OrderableEntity copyWith({
    String? id,
    String? name,
    String? estateOnlineFormId,
    String? onlineFormTypeId,
    String? startAt,
    String? endAt,
  }) {
    return OrderableEntity()
      ..id = id ?? this.id
      ..name = name ?? this.name
      ..estateOnlineFormId = estateOnlineFormId ?? this.estateOnlineFormId
      ..onlineFormTypeId = onlineFormTypeId ?? this.onlineFormTypeId
      ..startAt = startAt ?? this.startAt
      ..endAt = endAt ?? this.endAt;
  }
}