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

GarageSaleRentDetailEntity $GarageSaleRentDetailEntityFromJson(Map<String, dynamic> json) {
  final GarageSaleRentDetailEntity garageSaleRentDetailEntity = GarageSaleRentDetailEntity();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    garageSaleRentDetailEntity.id = id;
  }
  final String? title = jsonConvert.convert<String>(json['title']);
  if (title != null) {
    garageSaleRentDetailEntity.title = title;
  }
  final int? price = jsonConvert.convert<int>(json['price']);
  if (price != null) {
    garageSaleRentDetailEntity.price = price;
  }
  final String? description = jsonConvert.convert<String>(json['description']);
  if (description != null) {
    garageSaleRentDetailEntity.description = description;
  }
  final List<String>? resources = (json['resources'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<String>(e) as String).toList();
  if (resources != null) {
    garageSaleRentDetailEntity.resources = resources;
  }
  final String? createdAt = jsonConvert.convert<String>(json['created_at']);
  if (createdAt != null) {
    garageSaleRentDetailEntity.createdAt = createdAt;
  }
  final int? likesCount = jsonConvert.convert<int>(json['likes_count']);
  if (likesCount != null) {
    garageSaleRentDetailEntity.likesCount = likesCount;
  }
  final String? contact = jsonConvert.convert<String>(json['contact']);
  if (contact != null) {
    garageSaleRentDetailEntity.contact = contact;
  }
  final GarageSaleRentDetailAccount? account = jsonConvert.convert<GarageSaleRentDetailAccount>(json['account']);
  if (account != null) {
    garageSaleRentDetailEntity.account = account;
  }
  return garageSaleRentDetailEntity;
}

Map<String, dynamic> $GarageSaleRentDetailEntityToJson(GarageSaleRentDetailEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['title'] = entity.title;
  data['price'] = entity.price;
  data['description'] = entity.description;
  data['resources'] = entity.resources;
  data['created_at'] = entity.createdAt;
  data['likes_count'] = entity.likesCount;
  data['contact'] = entity.contact;
  data['account'] = entity.account?.toJson();
  return data;
}

extension GarageSaleRentDetailEntityExtension on GarageSaleRentDetailEntity {
  GarageSaleRentDetailEntity copyWith({
    int? id,
    String? title,
    int? price,
    String? description,
    List<String>? resources,
    String? createdAt,
    int? likesCount,
    String? contact,
    GarageSaleRentDetailAccount? account,
  }) {
    return GarageSaleRentDetailEntity()
      ..id = id ?? this.id
      ..title = title ?? this.title
      ..price = price ?? this.price
      ..description = description ?? this.description
      ..resources = resources ?? this.resources
      ..createdAt = createdAt ?? this.createdAt
      ..likesCount = likesCount ?? this.likesCount
      ..contact = contact ?? this.contact
      ..account = account ?? this.account;
  }
}

GarageSaleRentDetailAccount $GarageSaleRentDetailAccountFromJson(Map<String, dynamic> json) {
  final GarageSaleRentDetailAccount garageSaleRentDetailAccount = GarageSaleRentDetailAccount();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    garageSaleRentDetailAccount.id = id;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    garageSaleRentDetailAccount.name = name;
  }
  final String? avatar = jsonConvert.convert<String>(json['avatar']);
  if (avatar != null) {
    garageSaleRentDetailAccount.avatar = avatar;
  }
  return garageSaleRentDetailAccount;
}

Map<String, dynamic> $GarageSaleRentDetailAccountToJson(GarageSaleRentDetailAccount entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['name'] = entity.name;
  data['avatar'] = entity.avatar;
  return data;
}

extension GarageSaleRentDetailAccountExtension on GarageSaleRentDetailAccount {
  GarageSaleRentDetailAccount copyWith({
    int? id,
    String? name,
    String? avatar,
  }) {
    return GarageSaleRentDetailAccount()
      ..id = id ?? this.id
      ..name = name ?? this.name
      ..avatar = avatar ?? this.avatar;
  }
}