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

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

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

NewsfeedFollowingList $NewsfeedFollowingListFromJson(Map<String, dynamic> json) {
  final NewsfeedFollowingList newsfeedFollowingList = NewsfeedFollowingList();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    newsfeedFollowingList.id = id;
  }
  final String? content = jsonConvert.convert<String>(json['content']);
  if (content != null) {
    newsfeedFollowingList.content = content;
  }
  final List<String>? resources = (json['resources'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<String>(e) as String).toList();
  if (resources != null) {
    newsfeedFollowingList.resources = resources;
  }
  final int? likesCount = jsonConvert.convert<int>(json['likes_count']);
  if (likesCount != null) {
    newsfeedFollowingList.likesCount = likesCount;
  }
  final int? commentsCount = jsonConvert.convert<int>(json['comments_count']);
  if (commentsCount != null) {
    newsfeedFollowingList.commentsCount = commentsCount;
  }
  final bool? liked = jsonConvert.convert<bool>(json['liked']);
  if (liked != null) {
    newsfeedFollowingList.liked = liked;
  }
  final String? createdAt = jsonConvert.convert<String>(json['created_at']);
  if (createdAt != null) {
    newsfeedFollowingList.createdAt = createdAt;
  }
  final NewsfeedFollowingListAccount? account = jsonConvert.convert<NewsfeedFollowingListAccount>(json['account']);
  if (account != null) {
    newsfeedFollowingList.account = account;
  }
  return newsfeedFollowingList;
}

Map<String, dynamic> $NewsfeedFollowingListToJson(NewsfeedFollowingList entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['content'] = entity.content;
  data['resources'] = entity.resources;
  data['likes_count'] = entity.likesCount;
  data['comments_count'] = entity.commentsCount;
  data['liked'] = entity.liked;
  data['created_at'] = entity.createdAt;
  data['account'] = entity.account?.toJson();
  return data;
}

extension NewsfeedFollowingListExtension on NewsfeedFollowingList {
  NewsfeedFollowingList copyWith({
    int? id,
    String? content,
    List<String>? resources,
    int? likesCount,
    int? commentsCount,
    bool? liked,
    String? createdAt,
    NewsfeedFollowingListAccount? account,
  }) {
    return NewsfeedFollowingList()
      ..id = id ?? this.id
      ..content = content ?? this.content
      ..resources = resources ?? this.resources
      ..likesCount = likesCount ?? this.likesCount
      ..commentsCount = commentsCount ?? this.commentsCount
      ..liked = liked ?? this.liked
      ..createdAt = createdAt ?? this.createdAt
      ..account = account ?? this.account;
  }
}

NewsfeedFollowingListAccount $NewsfeedFollowingListAccountFromJson(Map<String, dynamic> json) {
  final NewsfeedFollowingListAccount newsfeedFollowingListAccount = NewsfeedFollowingListAccount();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    newsfeedFollowingListAccount.id = id;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    newsfeedFollowingListAccount.name = name;
  }
  final String? avatar = jsonConvert.convert<String>(json['avatar']);
  if (avatar != null) {
    newsfeedFollowingListAccount.avatar = avatar;
  }
  final bool? followed = jsonConvert.convert<bool>(json['followed']);
  if (followed != null) {
    newsfeedFollowingListAccount.followed = followed;
  }
  return newsfeedFollowingListAccount;
}

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

extension NewsfeedFollowingListAccountExtension on NewsfeedFollowingListAccount {
  NewsfeedFollowingListAccount copyWith({
    int? id,
    String? name,
    String? avatar,
    bool? followed,
  }) {
    return NewsfeedFollowingListAccount()
      ..id = id ?? this.id
      ..name = name ?? this.name
      ..avatar = avatar ?? this.avatar
      ..followed = followed ?? this.followed;
  }
}