import 'package:domain/generated/json/base/json_convert_content.dart'; import 'package:domain/entity/newsfeed_detail_entity.dart'; NewsfeedDetailEntity $NewsfeedDetailEntityFromJson(Map json) { final NewsfeedDetailEntity newsfeedDetailEntity = NewsfeedDetailEntity(); final int? id = jsonConvert.convert(json['id']); if (id != null) { newsfeedDetailEntity.id = id; } final String? content = jsonConvert.convert(json['content']); if (content != null) { newsfeedDetailEntity.content = content; } final List? resources = (json['resources'] as List?)?.map( (e) => jsonConvert.convert(e) as String).toList(); if (resources != null) { newsfeedDetailEntity.resources = resources; } final int? clicks = jsonConvert.convert(json['clicks']); if (clicks != null) { newsfeedDetailEntity.clicks = clicks; } final int? share = jsonConvert.convert(json['share']); if (share != null) { newsfeedDetailEntity.share = share; } final String? createdAt = jsonConvert.convert(json['created_at']); if (createdAt != null) { newsfeedDetailEntity.createdAt = createdAt; } final int? likesCount = jsonConvert.convert(json['likes_count']); if (likesCount != null) { newsfeedDetailEntity.likesCount = likesCount; } final int? commentsCount = jsonConvert.convert(json['comments_count']); if (commentsCount != null) { newsfeedDetailEntity.commentsCount = commentsCount; } final bool? liked = jsonConvert.convert(json['liked']); if (liked != null) { newsfeedDetailEntity.liked = liked; } final NewsfeedDetailAccount? account = jsonConvert.convert(json['account']); if (account != null) { newsfeedDetailEntity.account = account; } final List? comments = (json['comments'] as List?)?.map( (e) => jsonConvert.convert(e) as NewsfeedDetailComments).toList(); if (comments != null) { newsfeedDetailEntity.comments = comments; } return newsfeedDetailEntity; } Map $NewsfeedDetailEntityToJson(NewsfeedDetailEntity entity) { final Map data = {}; 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? resources, int? clicks, int? share, String? createdAt, int? likesCount, int? commentsCount, bool? liked, NewsfeedDetailAccount? account, List? 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 json) { final NewsfeedDetailAccount newsfeedDetailAccount = NewsfeedDetailAccount(); final int? id = jsonConvert.convert(json['id']); if (id != null) { newsfeedDetailAccount.id = id; } final String? name = jsonConvert.convert(json['name']); if (name != null) { newsfeedDetailAccount.name = name; } final String? avatar = jsonConvert.convert(json['avatar']); if (avatar != null) { newsfeedDetailAccount.avatar = avatar; } final bool? followed = jsonConvert.convert(json['followed']); if (followed != null) { newsfeedDetailAccount.followed = followed; } return newsfeedDetailAccount; } Map $NewsfeedDetailAccountToJson(NewsfeedDetailAccount entity) { final Map data = {}; 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 json) { final NewsfeedDetailComments newsfeedDetailComments = NewsfeedDetailComments(); final int? id = jsonConvert.convert(json['id']); if (id != null) { newsfeedDetailComments.id = id; } final String? content = jsonConvert.convert(json['content']); if (content != null) { newsfeedDetailComments.content = content; } final String? createdAt = jsonConvert.convert(json['created_at']); if (createdAt != null) { newsfeedDetailComments.createdAt = createdAt; } final NewsfeedDetailCommentsAccount? account = jsonConvert.convert(json['account']); if (account != null) { newsfeedDetailComments.account = account; } final NewsfeedDetailCommentsToAccount? toAccount = jsonConvert.convert(json['to_account']); if (toAccount != null) { newsfeedDetailComments.toAccount = toAccount; } return newsfeedDetailComments; } Map $NewsfeedDetailCommentsToJson(NewsfeedDetailComments entity) { final Map data = {}; 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 json) { final NewsfeedDetailCommentsAccount newsfeedDetailCommentsAccount = NewsfeedDetailCommentsAccount(); final int? id = jsonConvert.convert(json['id']); if (id != null) { newsfeedDetailCommentsAccount.id = id; } final String? name = jsonConvert.convert(json['name']); if (name != null) { newsfeedDetailCommentsAccount.name = name; } final String? avatar = jsonConvert.convert(json['avatar']); if (avatar != null) { newsfeedDetailCommentsAccount.avatar = avatar; } return newsfeedDetailCommentsAccount; } Map $NewsfeedDetailCommentsAccountToJson(NewsfeedDetailCommentsAccount entity) { final Map data = {}; 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 json) { final NewsfeedDetailCommentsToAccount newsfeedDetailCommentsToAccount = NewsfeedDetailCommentsToAccount(); final int? id = jsonConvert.convert(json['id']); if (id != null) { newsfeedDetailCommentsToAccount.id = id; } final String? name = jsonConvert.convert(json['name']); if (name != null) { newsfeedDetailCommentsToAccount.name = name; } final String? avatar = jsonConvert.convert(json['avatar']); if (avatar != null) { newsfeedDetailCommentsToAccount.avatar = avatar; } return newsfeedDetailCommentsToAccount; } Map $NewsfeedDetailCommentsToAccountToJson(NewsfeedDetailCommentsToAccount entity) { final Map data = {}; 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; } }