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


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

Map<String, dynamic> $FeedbackListEntityToJson(FeedbackListEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['count'] = entity.count;
  data['page'] = entity.page;
  data['count_page'] = entity.countPage;
  data['limit'] = entity.limit;
  data['list'] = entity.list?.map((v) => v.toJson()).toList();
  return data;
}

extension FeedbackListEntityExtension on FeedbackListEntity {
  FeedbackListEntity copyWith({
    int? count,
    int? page,
    int? countPage,
    int? limit,
    List<FeedbackItemEntity>? list,
  }) {
    return FeedbackListEntity()
      ..count = count ?? this.count
      ..page = page ?? this.page
      ..countPage = countPage ?? this.countPage
      ..limit = limit ?? this.limit
      ..list = list ?? this.list;
  }
}

FeedbackItemEntity $FeedbackItemEntityFromJson(Map<String, dynamic> json) {
  final FeedbackItemEntity feedbackItemEntity = FeedbackItemEntity();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    feedbackItemEntity.id = id;
  }
  final String? title = jsonConvert.convert<String>(json['title']);
  if (title != null) {
    feedbackItemEntity.title = title;
  }
  final String? content = jsonConvert.convert<String>(json['content']);
  if (content != null) {
    feedbackItemEntity.content = content;
  }
  final int? status = jsonConvert.convert<int>(json['status']);
  if (status != null) {
    feedbackItemEntity.status = status;
  }
  final String? createdAt = jsonConvert.convert<String>(json['created_at']);
  if (createdAt != null) {
    feedbackItemEntity.createdAt = createdAt;
  }
  final IdNameEntity? category = jsonConvert.convert<IdNameEntity>(json['category']);
  if (category != null) {
    feedbackItemEntity.category = category;
  }
  return feedbackItemEntity;
}

Map<String, dynamic> $FeedbackItemEntityToJson(FeedbackItemEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['title'] = entity.title;
  data['content'] = entity.content;
  data['status'] = entity.status;
  data['created_at'] = entity.createdAt;
  data['category'] = entity.category?.toJson();
  return data;
}

extension FeedbackItemEntityExtension on FeedbackItemEntity {
  FeedbackItemEntity copyWith({
    String? id,
    String? title,
    String? content,
    int? status,
    String? createdAt,
    IdNameEntity? category,
  }) {
    return FeedbackItemEntity()
      ..id = id ?? this.id
      ..title = title ?? this.title
      ..content = content ?? this.content
      ..status = status ?? this.status
      ..createdAt = createdAt ?? this.createdAt
      ..category = category ?? this.category;
  }
}