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

LatestNewsDetailEntity $LatestNewsDetailEntityFromJson(Map<String, dynamic> json) {
  final LatestNewsDetailEntity latestNewsDetailEntity = LatestNewsDetailEntity();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    latestNewsDetailEntity.id = id;
  }
  final int? type = jsonConvert.convert<int>(json['type']);
  if (type != null) {
    latestNewsDetailEntity.type = type;
  }
  final String? title = jsonConvert.convert<String>(json['title']);
  if (title != null) {
    latestNewsDetailEntity.title = title;
  }
  final String? coverImage = jsonConvert.convert<String>(json['cover_image']);
  if (coverImage != null) {
    latestNewsDetailEntity.coverImage = coverImage;
  }
  final String? content = jsonConvert.convert<String>(json['content']);
  if (content != null) {
    latestNewsDetailEntity.content = content;
  }
  final String? createdAt = jsonConvert.convert<String>(json['created_at']);
  if (createdAt != null) {
    latestNewsDetailEntity.createdAt = createdAt;
  }
  return latestNewsDetailEntity;
}

Map<String, dynamic> $LatestNewsDetailEntityToJson(LatestNewsDetailEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['type'] = entity.type;
  data['title'] = entity.title;
  data['cover_image'] = entity.coverImage;
  data['content'] = entity.content;
  data['created_at'] = entity.createdAt;
  return data;
}

extension LatestNewsDetailEntityExtension on LatestNewsDetailEntity {
  LatestNewsDetailEntity copyWith({
    String? id,
    int? type,
    String? title,
    String? coverImage,
    String? content,
    String? createdAt,
  }) {
    return LatestNewsDetailEntity()
      ..id = id ?? this.id
      ..type = type ?? this.type
      ..title = title ?? this.title
      ..coverImage = coverImage ?? this.coverImage
      ..content = content ?? this.content
      ..createdAt = createdAt ?? this.createdAt;
  }
}