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

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

Map<String, dynamic> $PropertySaleRentEntityToJson(PropertySaleRentEntity 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 PropertySaleRentEntityExtension on PropertySaleRentEntity {
  PropertySaleRentEntity copyWith({
    int? count,
    int? page,
    int? limit,
    int? countPage,
    List<PropertySaleRentList>? list,
  }) {
    return PropertySaleRentEntity()
      ..count = count ?? this.count
      ..page = page ?? this.page
      ..limit = limit ?? this.limit
      ..countPage = countPage ?? this.countPage
      ..list = list ?? this.list;
  }
}

PropertySaleRentList $PropertySaleRentListFromJson(Map<String, dynamic> json) {
  final PropertySaleRentList propertySaleRentList = PropertySaleRentList();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    propertySaleRentList.id = id;
  }
  final int? type = jsonConvert.convert<int>(json['type']);
  if (type != null) {
    propertySaleRentList.type = type;
  }
  final String? title = jsonConvert.convert<String>(json['title']);
  if (title != null) {
    propertySaleRentList.title = title;
  }
  final String? price = jsonConvert.convert<String>(json['price']);
  if (price != null) {
    propertySaleRentList.price = price;
  }
  final String? priceShow = jsonConvert.convert<String>(json['price_show']);
  if (priceShow != null) {
    propertySaleRentList.priceShow = priceShow;
  }
  final String? units = jsonConvert.convert<String>(json['units']);
  if (units != null) {
    propertySaleRentList.units = units;
  }
  final String? createdAt = jsonConvert.convert<String>(json['created_at']);
  if (createdAt != null) {
    propertySaleRentList.createdAt = createdAt;
  }
  return propertySaleRentList;
}

Map<String, dynamic> $PropertySaleRentListToJson(PropertySaleRentList entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['type'] = entity.type;
  data['title'] = entity.title;
  data['price'] = entity.price;
  data['price_show'] = entity.priceShow;
  data['units'] = entity.units;
  data['created_at'] = entity.createdAt;
  return data;
}

extension PropertySaleRentListExtension on PropertySaleRentList {
  PropertySaleRentList copyWith({
    int? id,
    int? type,
    String? title,
    String? price,
    String? priceShow,
    String? units,
    String? createdAt,
  }) {
    return PropertySaleRentList()
      ..id = id ?? this.id
      ..type = type ?? this.type
      ..title = title ?? this.title
      ..price = price ?? this.price
      ..priceShow = priceShow ?? this.priceShow
      ..units = units ?? this.units
      ..createdAt = createdAt ?? this.createdAt;
  }
}