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

UserMeEntity $UserMeEntityFromJson(Map<String, dynamic> json) {
  final UserMeEntity userMeEntity = UserMeEntity();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    userMeEntity.id = id;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    userMeEntity.name = name;
  }
  final String? avatar = jsonConvert.convert<String>(json['avatar']);
  if (avatar != null) {
    userMeEntity.avatar = avatar;
  }
  final String? phone = jsonConvert.convert<String>(json['phone']);
  if (phone != null) {
    userMeEntity.phone = phone;
  }
  final String? email = jsonConvert.convert<String>(json['email']);
  if (email != null) {
    userMeEntity.email = email;
  }
  final String? followsCount = jsonConvert.convert<String>(json['follows_count']);
  if (followsCount != null) {
    userMeEntity.followsCount = followsCount;
  }
  final String? flowersCount = jsonConvert.convert<String>(json['flowers_count']);
  if (flowersCount != null) {
    userMeEntity.flowersCount = flowersCount;
  }
  final String? postsCount = jsonConvert.convert<String>(json['posts_count']);
  if (postsCount != null) {
    userMeEntity.postsCount = postsCount;
  }
  final String? rewardPoints = jsonConvert.convert<String>(json['reward_points']);
  if (rewardPoints != null) {
    userMeEntity.rewardPoints = rewardPoints;
  }
  final String? unreadNotificationsCount = jsonConvert.convert<String>(json['unread_notifications_count']);
  if (unreadNotificationsCount != null) {
    userMeEntity.unreadNotificationsCount = unreadNotificationsCount;
  }
  final List<UserMeHouseholds>? households = (json['households'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<UserMeHouseholds>(e) as UserMeHouseholds).toList();
  if (households != null) {
    userMeEntity.households = households;
  }
  final List<UserMeEstates>? estates = (json['estates'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<UserMeEstates>(e) as UserMeEstates).toList();
  if (estates != null) {
    userMeEntity.estates = estates;
  }
  final UserMeDefaultUnit? defaultUnit = jsonConvert.convert<UserMeDefaultUnit>(json['default_unit']);
  if (defaultUnit != null) {
    userMeEntity.defaultUnit = defaultUnit;
  }
  final UserMeInformation? information = jsonConvert.convert<UserMeInformation>(json['information']);
  if (information != null) {
    userMeEntity.information = information;
  }
  return userMeEntity;
}

Map<String, dynamic> $UserMeEntityToJson(UserMeEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['name'] = entity.name;
  data['avatar'] = entity.avatar;
  data['phone'] = entity.phone;
  data['email'] = entity.email;
  data['follows_count'] = entity.followsCount;
  data['flowers_count'] = entity.flowersCount;
  data['posts_count'] = entity.postsCount;
  data['reward_points'] = entity.rewardPoints;
  data['unread_notifications_count'] = entity.unreadNotificationsCount;
  data['households'] = entity.households?.map((v) => v.toJson()).toList();
  data['estates'] = entity.estates?.map((v) => v.toJson()).toList();
  data['default_unit'] = entity.defaultUnit?.toJson();
  data['information'] = entity.information?.toJson();
  return data;
}

extension UserMeEntityExtension on UserMeEntity {
  UserMeEntity copyWith({
    String? id,
    String? name,
    String? avatar,
    String? phone,
    String? email,
    String? followsCount,
    String? flowersCount,
    String? postsCount,
    String? rewardPoints,
    String? unreadNotificationsCount,
    List<UserMeHouseholds>? households,
    List<UserMeEstates>? estates,
    UserMeDefaultUnit? defaultUnit,
    UserMeInformation? information,
  }) {
    return UserMeEntity()
      ..id = id ?? this.id
      ..name = name ?? this.name
      ..avatar = avatar ?? this.avatar
      ..phone = phone ?? this.phone
      ..email = email ?? this.email
      ..followsCount = followsCount ?? this.followsCount
      ..flowersCount = flowersCount ?? this.flowersCount
      ..postsCount = postsCount ?? this.postsCount
      ..rewardPoints = rewardPoints ?? this.rewardPoints
      ..unreadNotificationsCount = unreadNotificationsCount ?? this.unreadNotificationsCount
      ..households = households ?? this.households
      ..estates = estates ?? this.estates
      ..defaultUnit = defaultUnit ?? this.defaultUnit
      ..information = information ?? this.information;
  }
}

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

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

extension UserMeHouseholdsExtension on UserMeHouseholds {
  UserMeHouseholds copyWith({
    String? id,
    String? name,
    String? avatar,
  }) {
    return UserMeHouseholds()
      ..id = id ?? this.id
      ..name = name ?? this.name
      ..avatar = avatar ?? this.avatar;
  }
}

UserMeEstates $UserMeEstatesFromJson(Map<String, dynamic> json) {
  final UserMeEstates userMeEstates = UserMeEstates();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    userMeEstates.id = id;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    userMeEstates.name = name;
  }
  final List<UserMeEstatesAccounts>? accounts = (json['accounts'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<UserMeEstatesAccounts>(e) as UserMeEstatesAccounts).toList();
  if (accounts != null) {
    userMeEstates.accounts = accounts;
  }
  return userMeEstates;
}

Map<String, dynamic> $UserMeEstatesToJson(UserMeEstates entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['name'] = entity.name;
  data['accounts'] = entity.accounts?.map((v) => v.toJson()).toList();
  return data;
}

extension UserMeEstatesExtension on UserMeEstates {
  UserMeEstates copyWith({
    String? id,
    String? name,
    List<UserMeEstatesAccounts>? accounts,
  }) {
    return UserMeEstates()
      ..id = id ?? this.id
      ..name = name ?? this.name
      ..accounts = accounts ?? this.accounts;
  }
}

UserMeEstatesAccounts $UserMeEstatesAccountsFromJson(Map<String, dynamic> json) {
  final UserMeEstatesAccounts userMeEstatesAccounts = UserMeEstatesAccounts();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    userMeEstatesAccounts.id = id;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    userMeEstatesAccounts.name = name;
  }
  final String? avatar = jsonConvert.convert<String>(json['avatar']);
  if (avatar != null) {
    userMeEstatesAccounts.avatar = avatar;
  }
  final String? type = jsonConvert.convert<String>(json['type']);
  if (type != null) {
    userMeEstatesAccounts.type = type;
  }
  final int? isDefault = jsonConvert.convert<int>(json['default']);
  if (isDefault != null) {
    userMeEstatesAccounts.isDefault = isDefault;
  }
  final String? status = jsonConvert.convert<String>(json['status']);
  if (status != null) {
    userMeEstatesAccounts.status = status;
  }
  final UserMeEstatesAccountsUnit? unit = jsonConvert.convert<UserMeEstatesAccountsUnit>(json['unit']);
  if (unit != null) {
    userMeEstatesAccounts.unit = unit;
  }
  return userMeEstatesAccounts;
}

Map<String, dynamic> $UserMeEstatesAccountsToJson(UserMeEstatesAccounts entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['name'] = entity.name;
  data['avatar'] = entity.avatar;
  data['type'] = entity.type;
  data['default'] = entity.isDefault;
  data['status'] = entity.status;
  data['unit'] = entity.unit?.toJson();
  return data;
}

extension UserMeEstatesAccountsExtension on UserMeEstatesAccounts {
  UserMeEstatesAccounts copyWith({
    String? id,
    String? name,
    String? avatar,
    String? type,
    int? isDefault,
    String? status,
    UserMeEstatesAccountsUnit? unit,
  }) {
    return UserMeEstatesAccounts()
      ..id = id ?? this.id
      ..name = name ?? this.name
      ..avatar = avatar ?? this.avatar
      ..type = type ?? this.type
      ..isDefault = isDefault ?? this.isDefault
      ..status = status ?? this.status
      ..unit = unit ?? this.unit;
  }
}

UserMeEstatesAccountsUnit $UserMeEstatesAccountsUnitFromJson(Map<String, dynamic> json) {
  final UserMeEstatesAccountsUnit userMeEstatesAccountsUnit = UserMeEstatesAccountsUnit();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    userMeEstatesAccountsUnit.id = id;
  }
  final String? block = jsonConvert.convert<String>(json['block']);
  if (block != null) {
    userMeEstatesAccountsUnit.block = block;
  }
  final String? street = jsonConvert.convert<String>(json['street']);
  if (street != null) {
    userMeEstatesAccountsUnit.street = street;
  }
  final String? unit = jsonConvert.convert<String>(json['unit']);
  if (unit != null) {
    userMeEstatesAccountsUnit.unit = unit;
  }
  final String? address = jsonConvert.convert<String>(json['address']);
  if (address != null) {
    userMeEstatesAccountsUnit.address = address;
  }
  return userMeEstatesAccountsUnit;
}

Map<String, dynamic> $UserMeEstatesAccountsUnitToJson(UserMeEstatesAccountsUnit entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['block'] = entity.block;
  data['street'] = entity.street;
  data['unit'] = entity.unit;
  data['address'] = entity.address;
  return data;
}

extension UserMeEstatesAccountsUnitExtension on UserMeEstatesAccountsUnit {
  UserMeEstatesAccountsUnit copyWith({
    String? id,
    String? block,
    String? street,
    String? unit,
    String? address,
  }) {
    return UserMeEstatesAccountsUnit()
      ..id = id ?? this.id
      ..block = block ?? this.block
      ..street = street ?? this.street
      ..unit = unit ?? this.unit
      ..address = address ?? this.address;
  }
}

UserMeDefaultUnit $UserMeDefaultUnitFromJson(Map<String, dynamic> json) {
  final UserMeDefaultUnit userMeDefaultUnit = UserMeDefaultUnit();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    userMeDefaultUnit.id = id;
  }
  final String? estateId = jsonConvert.convert<String>(json['estate_id']);
  if (estateId != null) {
    userMeDefaultUnit.estateId = estateId;
  }
  final String? block = jsonConvert.convert<String>(json['block']);
  if (block != null) {
    userMeDefaultUnit.block = block;
  }
  final String? street = jsonConvert.convert<String>(json['street']);
  if (street != null) {
    userMeDefaultUnit.street = street;
  }
  final String? unit = jsonConvert.convert<String>(json['unit']);
  if (unit != null) {
    userMeDefaultUnit.unit = unit;
  }
  final String? address = jsonConvert.convert<String>(json['address']);
  if (address != null) {
    userMeDefaultUnit.address = address;
  }
  final int? type = jsonConvert.convert<int>(json['type']);
  if (type != null) {
    userMeDefaultUnit.type = type;
  }
  return userMeDefaultUnit;
}

Map<String, dynamic> $UserMeDefaultUnitToJson(UserMeDefaultUnit entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['estate_id'] = entity.estateId;
  data['block'] = entity.block;
  data['street'] = entity.street;
  data['unit'] = entity.unit;
  data['address'] = entity.address;
  data['type'] = entity.type;
  return data;
}

extension UserMeDefaultUnitExtension on UserMeDefaultUnit {
  UserMeDefaultUnit copyWith({
    String? id,
    String? estateId,
    String? block,
    String? street,
    String? unit,
    String? address,
    int? type,
  }) {
    return UserMeDefaultUnit()
      ..id = id ?? this.id
      ..estateId = estateId ?? this.estateId
      ..block = block ?? this.block
      ..street = street ?? this.street
      ..unit = unit ?? this.unit
      ..address = address ?? this.address
      ..type = type ?? this.type;
  }
}

UserMeInformation $UserMeInformationFromJson(Map<String, dynamic> json) {
  final UserMeInformation userMeInformation = UserMeInformation();
  final String? firstName = jsonConvert.convert<String>(json['first_name']);
  if (firstName != null) {
    userMeInformation.firstName = firstName;
  }
  final String? lastName = jsonConvert.convert<String>(json['last_name']);
  if (lastName != null) {
    userMeInformation.lastName = lastName;
  }
  final String? countryCode = jsonConvert.convert<String>(json['country_code']);
  if (countryCode != null) {
    userMeInformation.countryCode = countryCode;
  }
  final String? phone = jsonConvert.convert<String>(json['phone']);
  if (phone != null) {
    userMeInformation.phone = phone;
  }
  return userMeInformation;
}

Map<String, dynamic> $UserMeInformationToJson(UserMeInformation entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['first_name'] = entity.firstName;
  data['last_name'] = entity.lastName;
  data['country_code'] = entity.countryCode;
  data['phone'] = entity.phone;
  return data;
}

extension UserMeInformationExtension on UserMeInformation {
  UserMeInformation copyWith({
    String? firstName,
    String? lastName,
    String? countryCode,
    String? phone,
  }) {
    return UserMeInformation()
      ..firstName = firstName ?? this.firstName
      ..lastName = lastName ?? this.lastName
      ..countryCode = countryCode ?? this.countryCode
      ..phone = phone ?? this.phone;
  }
}