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

FormOrderEntity $FormOrderEntityFromJson(Map<String, dynamic> json) {
  final FormOrderEntity formOrderEntity = FormOrderEntity();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    formOrderEntity.id = id;
  }
  final String? userId = jsonConvert.convert<String>(json['user_id']);
  if (userId != null) {
    formOrderEntity.userId = userId;
  }
  final int? status = jsonConvert.convert<int>(json['status']);
  if (status != null) {
    formOrderEntity.status = status;
  }
  final FormOrderOrder? order = jsonConvert.convert<FormOrderOrder>(json['order']);
  if (order != null) {
    formOrderEntity.order = order;
  }
  return formOrderEntity;
}

Map<String, dynamic> $FormOrderEntityToJson(FormOrderEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['user_id'] = entity.userId;
  data['status'] = entity.status;
  data['order'] = entity.order?.toJson();
  return data;
}

extension FormOrderEntityExtension on FormOrderEntity {
  FormOrderEntity copyWith({
    String? id,
    String? userId,
    int? status,
    FormOrderOrder? order,
  }) {
    return FormOrderEntity()
      ..id = id ?? this.id
      ..userId = userId ?? this.userId
      ..status = status ?? this.status
      ..order = order ?? this.order;
  }
}

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

Map<String, dynamic> $FormOrderOrderToJson(FormOrderOrder 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 FormOrderOrderExtension on FormOrderOrder {
  FormOrderOrder copyWith({
    String? id,
    String? totalAmount,
    String? orderAmount,
    String? depositAmount,
    String? paymentStatus,
    String? refundStatus,
  }) {
    return FormOrderOrder()
      ..id = id ?? this.id
      ..totalAmount = totalAmount ?? this.totalAmount
      ..orderAmount = orderAmount ?? this.orderAmount
      ..depositAmount = depositAmount ?? this.depositAmount
      ..paymentStatus = paymentStatus ?? this.paymentStatus
      ..refundStatus = refundStatus ?? this.refundStatus;
  }
}