import 'package:domain/generated/json/base/json_convert_content.dart';
import 'package:domain/entity/payment_page_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? startAt = jsonConvert.convert<String>(json['start_at']);
  if (startAt != null) {
    paymentPageList.startAt = startAt;
  }
  final String? endAt = jsonConvert.convert<String>(json['end_at']);
  if (endAt != null) {
    paymentPageList.endAt = endAt;
  }
  final String? amount = jsonConvert.convert<String>(json['amount']);
  if (amount != null) {
    paymentPageList.amount = amount;
  }
  final dynamic paidBy = json['paid_by'];
  if (paidBy != null) {
    paymentPageList.paidBy = paidBy;
  }
  final String? createdAt = jsonConvert.convert<String>(json['created_at']);
  if (createdAt != null) {
    paymentPageList.createdAt = createdAt;
  }
  return paymentPageList;
}

Map<String, dynamic> $PaymentPageListToJson(PaymentPageList entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['type'] = entity.type;
  data['start_at'] = entity.startAt;
  data['end_at'] = entity.endAt;
  data['amount'] = entity.amount;
  data['paid_by'] = entity.paidBy;
  data['created_at'] = entity.createdAt;
  return data;
}

extension PaymentPageListExtension on PaymentPageList {
  PaymentPageList copyWith({
    String? id,
    String? type,
    String? startAt,
    String? endAt,
    String? amount,
    dynamic paidBy,
    String? createdAt,
  }) {
    return PaymentPageList()
      ..id = id ?? this.id
      ..type = type ?? this.type
      ..startAt = startAt ?? this.startAt
      ..endAt = endAt ?? this.endAt
      ..amount = amount ?? this.amount
      ..paidBy = paidBy ?? this.paidBy
      ..createdAt = createdAt ?? this.createdAt;
  }
}