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

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

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

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

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

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

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