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


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

Map<String, dynamic> $CommPaymentDetailEntityToJson(CommPaymentDetailEntity 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['refund_order_amount'] = entity.refundOrderAmount;
  data['deposit_amount'] = entity.depositAmount;
  data['refund_deposit_amount'] = entity.refundDepositAmount;
  data['payment_status'] = entity.paymentStatus;
  data['refund_status'] = entity.refundStatus;
  data['paid_at'] = entity.paidAt;
  data['refunded_at'] = entity.refundedAt;
  data['created_at'] = entity.createdAt;
  data['account'] = entity.account?.toJson();
  data['orderable'] = entity.orderable?.toJson();
  return data;
}

extension CommPaymentDetailEntityExtension on CommPaymentDetailEntity {
  CommPaymentDetailEntity copyWith({
    String? id,
    String? type,
    String? title,
    String? totalAmount,
    String? orderAmount,
    String? refundOrderAmount,
    String? depositAmount,
    String? refundDepositAmount,
    int? paymentStatus,
    int? refundStatus,
    String? paidAt,
    String? refundedAt,
    String? createdAt,
    IdNameEntity? account,
    CommPaymentDetailOrderable? orderable,
  }) {
    return CommPaymentDetailEntity()
      ..id = id ?? this.id
      ..type = type ?? this.type
      ..title = title ?? this.title
      ..totalAmount = totalAmount ?? this.totalAmount
      ..orderAmount = orderAmount ?? this.orderAmount
      ..refundOrderAmount = refundOrderAmount ?? this.refundOrderAmount
      ..depositAmount = depositAmount ?? this.depositAmount
      ..refundDepositAmount = refundDepositAmount ?? this.refundDepositAmount
      ..paymentStatus = paymentStatus ?? this.paymentStatus
      ..refundStatus = refundStatus ?? this.refundStatus
      ..paidAt = paidAt ?? this.paidAt
      ..refundedAt = refundedAt ?? this.refundedAt
      ..createdAt = createdAt ?? this.createdAt
      ..account = account ?? this.account
      ..orderable = orderable ?? this.orderable;
  }
}

CommPaymentDetailOrderable $CommPaymentDetailOrderableFromJson(Map<String, dynamic> json) {
  final CommPaymentDetailOrderable commPaymentDetailOrderable = CommPaymentDetailOrderable();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    commPaymentDetailOrderable.id = id;
  }
  return commPaymentDetailOrderable;
}

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

extension CommPaymentDetailOrderableExtension on CommPaymentDetailOrderable {
  CommPaymentDetailOrderable copyWith({
    int? id,
  }) {
    return CommPaymentDetailOrderable()
      ..id = id ?? this.id;
  }
}