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

HomeListEntity $HomeListEntityFromJson(Map<String, dynamic> json) {
  final HomeListEntity homeListEntity = HomeListEntity();
  final List<HomeListBanners>? banners = (json['banners'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<HomeListBanners>(e) as HomeListBanners).toList();
  if (banners != null) {
    homeListEntity.banners = banners;
  }
  final List<HomeListLatestTransactions>? latestTransactions = (json['latest_transactions'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<HomeListLatestTransactions>(e) as HomeListLatestTransactions).toList();
  if (latestTransactions != null) {
    homeListEntity.latestTransactions = latestTransactions;
  }
  final List<HomeListPropertyNews>? propertyNews = (json['property_news'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<HomeListPropertyNews>(e) as HomeListPropertyNews).toList();
  if (propertyNews != null) {
    homeListEntity.propertyNews = propertyNews;
  }
  final List<HomeListPropertyNews>? strataManagementGuides = (json['strata_management_guides'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<HomeListPropertyNews>(e) as HomeListPropertyNews).toList();
  if (strataManagementGuides != null) {
    homeListEntity.strataManagementGuides = strataManagementGuides;
  }
  return homeListEntity;
}

Map<String, dynamic> $HomeListEntityToJson(HomeListEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['banners'] = entity.banners.map((v) => v.toJson()).toList();
  data['latest_transactions'] = entity.latestTransactions.map((v) => v.toJson()).toList();
  data['property_news'] = entity.propertyNews.map((v) => v.toJson()).toList();
  data['strata_management_guides'] = entity.strataManagementGuides.map((v) => v.toJson()).toList();
  return data;
}

extension HomeListEntityExtension on HomeListEntity {
  HomeListEntity copyWith({
    List<HomeListBanners>? banners,
    List<HomeListLatestTransactions>? latestTransactions,
    List<HomeListPropertyNews>? propertyNews,
    List<HomeListPropertyNews>? strataManagementGuides,
  }) {
    return HomeListEntity()
      ..banners = banners ?? this.banners
      ..latestTransactions = latestTransactions ?? this.latestTransactions
      ..propertyNews = propertyNews ?? this.propertyNews
      ..strataManagementGuides = strataManagementGuides ?? this.strataManagementGuides;
  }
}

HomeListBanners $HomeListBannersFromJson(Map<String, dynamic> json) {
  final HomeListBanners homeListBanners = HomeListBanners();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    homeListBanners.id = id;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    homeListBanners.name = name;
  }
  final String? image = jsonConvert.convert<String>(json['image']);
  if (image != null) {
    homeListBanners.image = image;
  }
  return homeListBanners;
}

Map<String, dynamic> $HomeListBannersToJson(HomeListBanners entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['name'] = entity.name;
  data['image'] = entity.image;
  return data;
}

extension HomeListBannersExtension on HomeListBanners {
  HomeListBanners copyWith({
    String? id,
    String? name,
    String? image,
  }) {
    return HomeListBanners()
      ..id = id ?? this.id
      ..name = name ?? this.name
      ..image = image ?? this.image;
  }
}

HomeListLatestTransactions $HomeListLatestTransactionsFromJson(Map<String, dynamic> json) {
  final HomeListLatestTransactions homeListLatestTransactions = HomeListLatestTransactions();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    homeListLatestTransactions.id = id;
  }
  final int? type = jsonConvert.convert<int>(json['type']);
  if (type != null) {
    homeListLatestTransactions.type = type;
  }
  final String? title = jsonConvert.convert<String>(json['title']);
  if (title != null) {
    homeListLatestTransactions.title = title;
  }
  final String? price = jsonConvert.convert<String>(json['price']);
  if (price != null) {
    homeListLatestTransactions.price = price;
  }
  final String? createdAt = jsonConvert.convert<String>(json['created_at']);
  if (createdAt != null) {
    homeListLatestTransactions.createdAt = createdAt;
  }
  return homeListLatestTransactions;
}

Map<String, dynamic> $HomeListLatestTransactionsToJson(HomeListLatestTransactions 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['created_at'] = entity.createdAt;
  return data;
}

extension HomeListLatestTransactionsExtension on HomeListLatestTransactions {
  HomeListLatestTransactions copyWith({
    String? id,
    int? type,
    String? title,
    String? price,
    String? createdAt,
  }) {
    return HomeListLatestTransactions()
      ..id = id ?? this.id
      ..type = type ?? this.type
      ..title = title ?? this.title
      ..price = price ?? this.price
      ..createdAt = createdAt ?? this.createdAt;
  }
}

HomeListPropertyNews $HomeListPropertyNewsFromJson(Map<String, dynamic> json) {
  final HomeListPropertyNews homeListPropertyNews = HomeListPropertyNews();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    homeListPropertyNews.id = id;
  }
  final String? title = jsonConvert.convert<String>(json['title']);
  if (title != null) {
    homeListPropertyNews.title = title;
  }
  final String? coverImage = jsonConvert.convert<String>(json['cover_image']);
  if (coverImage != null) {
    homeListPropertyNews.coverImage = coverImage;
  }
  final String? createdAt = jsonConvert.convert<String>(json['created_at']);
  if (createdAt != null) {
    homeListPropertyNews.createdAt = createdAt;
  }
  return homeListPropertyNews;
}

Map<String, dynamic> $HomeListPropertyNewsToJson(HomeListPropertyNews entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['title'] = entity.title;
  data['cover_image'] = entity.coverImage;
  data['created_at'] = entity.createdAt;
  return data;
}

extension HomeListPropertyNewsExtension on HomeListPropertyNews {
  HomeListPropertyNews copyWith({
    String? id,
    String? title,
    String? coverImage,
    String? createdAt,
  }) {
    return HomeListPropertyNews()
      ..id = id ?? this.id
      ..title = title ?? this.title
      ..coverImage = coverImage ?? this.coverImage
      ..createdAt = createdAt ?? this.createdAt;
  }
}