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

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

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

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

Map<String, dynamic> $NewsfeedForyouListToJson(NewsfeedForyouList 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 NewsfeedForyouListExtension on NewsfeedForyouList {
  NewsfeedForyouList copyWith({
    int? id,
    String? content,
    List<String>? resources,
    int? likesCount,
    int? commentsCount,
    bool? liked,
    String? createdAt,
    NewsfeedForyouListAccount? account,
  }) {
    return NewsfeedForyouList()
      ..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;
  }
}

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

Map<String, dynamic> $NewsfeedForyouListAccountToJson(NewsfeedForyouListAccount 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 NewsfeedForyouListAccountExtension on NewsfeedForyouListAccount {
  NewsfeedForyouListAccount copyWith({
    int? id,
    String? name,
    String? avatar,
    bool? followed,
  }) {
    return NewsfeedForyouListAccount()
      ..id = id ?? this.id
      ..name = name ?? this.name
      ..avatar = avatar ?? this.avatar
      ..followed = followed ?? this.followed;
  }
}