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

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

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

extension NotificationPageEntityExtension on NotificationPageEntity {
  NotificationPageEntity copyWith({
    int? count,
    int? page,
    int? limit,
    int? countPage,
    List<NotificationPageList>? list,
  }) {
    return NotificationPageEntity()
      ..count = count ?? this.count
      ..page = page ?? this.page
      ..limit = limit ?? this.limit
      ..countPage = countPage ?? this.countPage
      ..list = list ?? this.list;
  }
}

NotificationPageList $NotificationPageListFromJson(Map<String, dynamic> json) {
  final NotificationPageList notificationPageList = NotificationPageList();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    notificationPageList.id = id;
  }
  final String? estateId = jsonConvert.convert<String>(json['estate_id']);
  if (estateId != null) {
    notificationPageList.estateId = estateId;
  }
  final String? type = jsonConvert.convert<String>(json['type']);
  if (type != null) {
    notificationPageList.type = type;
  }
  final String? title = jsonConvert.convert<String>(json['title']);
  if (title != null) {
    notificationPageList.title = title;
  }
  final String? body = jsonConvert.convert<String>(json['body']);
  if (body != null) {
    notificationPageList.body = body;
  }
  final NotificationPageListData? data = jsonConvert.convert<NotificationPageListData>(json['data']);
  if (data != null) {
    notificationPageList.data = data;
  }
  final bool? read = jsonConvert.convert<bool>(json['read']);
  if (read != null) {
    notificationPageList.read = read;
  }
  final String? createdAt = jsonConvert.convert<String>(json['created_at']);
  if (createdAt != null) {
    notificationPageList.createdAt = createdAt;
  }
  return notificationPageList;
}

Map<String, dynamic> $NotificationPageListToJson(NotificationPageList entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['estate_id'] = entity.estateId;
  data['type'] = entity.type;
  data['title'] = entity.title;
  data['body'] = entity.body;
  data['data'] = entity.data?.toJson();
  data['read'] = entity.read;
  data['created_at'] = entity.createdAt;
  return data;
}

extension NotificationPageListExtension on NotificationPageList {
  NotificationPageList copyWith({
    String? id,
    String? estateId,
    String? type,
    String? title,
    String? body,
    NotificationPageListData? data,
    bool? read,
    String? createdAt,
  }) {
    return NotificationPageList()
      ..id = id ?? this.id
      ..estateId = estateId ?? this.estateId
      ..type = type ?? this.type
      ..title = title ?? this.title
      ..body = body ?? this.body
      ..data = data ?? this.data
      ..read = read ?? this.read
      ..createdAt = createdAt ?? this.createdAt;
  }
}

NotificationPageListData $NotificationPageListDataFromJson(Map<String, dynamic> json) {
  final NotificationPageListData notificationPageListData = NotificationPageListData();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    notificationPageListData.id = id;
  }
  final String? estateOnlineFormId = jsonConvert.convert<String>(json['estate_online_form_id']);
  if (estateOnlineFormId != null) {
    notificationPageListData.estateOnlineFormId = estateOnlineFormId;
  }
  final String? onlineFormTypeId = jsonConvert.convert<String>(json['online_form_type_id']);
  if (onlineFormTypeId != null) {
    notificationPageListData.onlineFormTypeId = onlineFormTypeId;
  }
  final String? type = jsonConvert.convert<String>(json['type']);
  if (type != null) {
    notificationPageListData.type = type;
  }
  return notificationPageListData;
}

Map<String, dynamic> $NotificationPageListDataToJson(NotificationPageListData entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['estate_online_form_id'] = entity.estateOnlineFormId;
  data['online_form_type_id'] = entity.onlineFormTypeId;
  data['type'] = entity.type;
  return data;
}

extension NotificationPageListDataExtension on NotificationPageListData {
  NotificationPageListData copyWith({
    String? id,
    String? estateOnlineFormId,
    String? onlineFormTypeId,
    String? type,
  }) {
    return NotificationPageListData()
      ..id = id ?? this.id
      ..estateOnlineFormId = estateOnlineFormId ?? this.estateOnlineFormId
      ..onlineFormTypeId = onlineFormTypeId ?? this.onlineFormTypeId
      ..type = type ?? this.type;
  }
}