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


FeedbackDetailEntity $FeedbackDetailEntityFromJson(Map<String, dynamic> json) {
  final FeedbackDetailEntity feedbackDetailEntity = FeedbackDetailEntity();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    feedbackDetailEntity.id = id;
  }
  final String? title = jsonConvert.convert<String>(json['title']);
  if (title != null) {
    feedbackDetailEntity.title = title;
  }
  final String? content = jsonConvert.convert<String>(json['content']);
  if (content != null) {
    feedbackDetailEntity.content = content;
  }
  final List<String>? resources = (json['resources'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<String>(e) as String).toList();
  if (resources != null) {
    feedbackDetailEntity.resources = resources;
  }
  final int? status = jsonConvert.convert<int>(json['status']);
  if (status != null) {
    feedbackDetailEntity.status = status;
  }
  final String? createdAt = jsonConvert.convert<String>(json['created_at']);
  if (createdAt != null) {
    feedbackDetailEntity.createdAt = createdAt;
  }
  final IdNameEntity? category = jsonConvert.convert<IdNameEntity>(json['category']);
  if (category != null) {
    feedbackDetailEntity.category = category;
  }
  final List<FeedbackDetailReplies>? replies = (json['replies'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<FeedbackDetailReplies>(e) as FeedbackDetailReplies).toList();
  if (replies != null) {
    feedbackDetailEntity.replies = replies;
  }
  return feedbackDetailEntity;
}

Map<String, dynamic> $FeedbackDetailEntityToJson(FeedbackDetailEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['title'] = entity.title;
  data['content'] = entity.content;
  data['resources'] = entity.resources;
  data['status'] = entity.status;
  data['created_at'] = entity.createdAt;
  data['category'] = entity.category?.toJson();
  data['replies'] = entity.replies?.map((v) => v.toJson()).toList();
  return data;
}

extension FeedbackDetailEntityExtension on FeedbackDetailEntity {
  FeedbackDetailEntity copyWith({
    String? id,
    String? title,
    String? content,
    List<String>? resources,
    int? status,
    String? createdAt,
    IdNameEntity? category,
    List<FeedbackDetailReplies>? replies,
  }) {
    return FeedbackDetailEntity()
      ..id = id ?? this.id
      ..title = title ?? this.title
      ..content = content ?? this.content
      ..resources = resources ?? this.resources
      ..status = status ?? this.status
      ..createdAt = createdAt ?? this.createdAt
      ..category = category ?? this.category
      ..replies = replies ?? this.replies;
  }
}

FeedbackDetailReplies $FeedbackDetailRepliesFromJson(Map<String, dynamic> json) {
  final FeedbackDetailReplies feedbackDetailReplies = FeedbackDetailReplies();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    feedbackDetailReplies.id = id;
  }
  final String? content = jsonConvert.convert<String>(json['content']);
  if (content != null) {
    feedbackDetailReplies.content = content;
  }
  final List<String>? resources = (json['resources'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<String>(e) as String).toList();
  if (resources != null) {
    feedbackDetailReplies.resources = resources;
  }
  final String? createdAt = jsonConvert.convert<String>(json['created_at']);
  if (createdAt != null) {
    feedbackDetailReplies.createdAt = createdAt;
  }
  final IdNameEntity? accountable = jsonConvert.convert<IdNameEntity>(json['accountable']);
  if (accountable != null) {
    feedbackDetailReplies.accountable = accountable;
  }
  return feedbackDetailReplies;
}

Map<String, dynamic> $FeedbackDetailRepliesToJson(FeedbackDetailReplies entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['content'] = entity.content;
  data['resources'] = entity.resources;
  data['created_at'] = entity.createdAt;
  data['accountable'] = entity.accountable?.toJson();
  return data;
}

extension FeedbackDetailRepliesExtension on FeedbackDetailReplies {
  FeedbackDetailReplies copyWith({
    String? id,
    String? content,
    List<String>? resources,
    String? createdAt,
    IdNameEntity? accountable,
  }) {
    return FeedbackDetailReplies()
      ..id = id ?? this.id
      ..content = content ?? this.content
      ..resources = resources ?? this.resources
      ..createdAt = createdAt ?? this.createdAt
      ..accountable = accountable ?? this.accountable;
  }
}