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

NewsfeedDetailEntity $NewsfeedDetailEntityFromJson(Map<String, dynamic> json) {
  final NewsfeedDetailEntity newsfeedDetailEntity = NewsfeedDetailEntity();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    newsfeedDetailEntity.id = id;
  }
  final String? content = jsonConvert.convert<String>(json['content']);
  if (content != null) {
    newsfeedDetailEntity.content = content;
  }
  final List<String>? resources = (json['resources'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<String>(e) as String).toList();
  if (resources != null) {
    newsfeedDetailEntity.resources = resources;
  }
  final int? clicks = jsonConvert.convert<int>(json['clicks']);
  if (clicks != null) {
    newsfeedDetailEntity.clicks = clicks;
  }
  final int? share = jsonConvert.convert<int>(json['share']);
  if (share != null) {
    newsfeedDetailEntity.share = share;
  }
  final String? createdAt = jsonConvert.convert<String>(json['created_at']);
  if (createdAt != null) {
    newsfeedDetailEntity.createdAt = createdAt;
  }
  final int? likesCount = jsonConvert.convert<int>(json['likes_count']);
  if (likesCount != null) {
    newsfeedDetailEntity.likesCount = likesCount;
  }
  final int? commentsCount = jsonConvert.convert<int>(json['comments_count']);
  if (commentsCount != null) {
    newsfeedDetailEntity.commentsCount = commentsCount;
  }
  final bool? liked = jsonConvert.convert<bool>(json['liked']);
  if (liked != null) {
    newsfeedDetailEntity.liked = liked;
  }
  final NewsfeedDetailAccount? account = jsonConvert.convert<NewsfeedDetailAccount>(json['account']);
  if (account != null) {
    newsfeedDetailEntity.account = account;
  }
  final List<NewsfeedDetailComments>? comments = (json['comments'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<NewsfeedDetailComments>(e) as NewsfeedDetailComments).toList();
  if (comments != null) {
    newsfeedDetailEntity.comments = comments;
  }
  return newsfeedDetailEntity;
}

Map<String, dynamic> $NewsfeedDetailEntityToJson(NewsfeedDetailEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['content'] = entity.content;
  data['resources'] = entity.resources;
  data['clicks'] = entity.clicks;
  data['share'] = entity.share;
  data['created_at'] = entity.createdAt;
  data['likes_count'] = entity.likesCount;
  data['comments_count'] = entity.commentsCount;
  data['liked'] = entity.liked;
  data['account'] = entity.account?.toJson();
  data['comments'] = entity.comments?.map((v) => v.toJson()).toList();
  return data;
}

extension NewsfeedDetailEntityExtension on NewsfeedDetailEntity {
  NewsfeedDetailEntity copyWith({
    int? id,
    String? content,
    List<String>? resources,
    int? clicks,
    int? share,
    String? createdAt,
    int? likesCount,
    int? commentsCount,
    bool? liked,
    NewsfeedDetailAccount? account,
    List<NewsfeedDetailComments>? comments,
  }) {
    return NewsfeedDetailEntity()
      ..id = id ?? this.id
      ..content = content ?? this.content
      ..resources = resources ?? this.resources
      ..clicks = clicks ?? this.clicks
      ..share = share ?? this.share
      ..createdAt = createdAt ?? this.createdAt
      ..likesCount = likesCount ?? this.likesCount
      ..commentsCount = commentsCount ?? this.commentsCount
      ..liked = liked ?? this.liked
      ..account = account ?? this.account
      ..comments = comments ?? this.comments;
  }
}

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

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

NewsfeedDetailComments $NewsfeedDetailCommentsFromJson(Map<String, dynamic> json) {
  final NewsfeedDetailComments newsfeedDetailComments = NewsfeedDetailComments();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    newsfeedDetailComments.id = id;
  }
  final String? content = jsonConvert.convert<String>(json['content']);
  if (content != null) {
    newsfeedDetailComments.content = content;
  }
  final String? createdAt = jsonConvert.convert<String>(json['created_at']);
  if (createdAt != null) {
    newsfeedDetailComments.createdAt = createdAt;
  }
  final NewsfeedDetailCommentsAccount? account = jsonConvert.convert<NewsfeedDetailCommentsAccount>(json['account']);
  if (account != null) {
    newsfeedDetailComments.account = account;
  }
  final NewsfeedDetailCommentsToAccount? toAccount = jsonConvert.convert<NewsfeedDetailCommentsToAccount>(json['to_account']);
  if (toAccount != null) {
    newsfeedDetailComments.toAccount = toAccount;
  }
  return newsfeedDetailComments;
}

Map<String, dynamic> $NewsfeedDetailCommentsToJson(NewsfeedDetailComments entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['content'] = entity.content;
  data['created_at'] = entity.createdAt;
  data['account'] = entity.account?.toJson();
  data['to_account'] = entity.toAccount?.toJson();
  return data;
}

extension NewsfeedDetailCommentsExtension on NewsfeedDetailComments {
  NewsfeedDetailComments copyWith({
    int? id,
    String? content,
    String? createdAt,
    NewsfeedDetailCommentsAccount? account,
    NewsfeedDetailCommentsToAccount? toAccount,
  }) {
    return NewsfeedDetailComments()
      ..id = id ?? this.id
      ..content = content ?? this.content
      ..createdAt = createdAt ?? this.createdAt
      ..account = account ?? this.account
      ..toAccount = toAccount ?? this.toAccount;
  }
}

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

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

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

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

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

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