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

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

Map<String, dynamic> $VisitorPageEntityToJson(VisitorPageEntity 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 VisitorPageEntityExtension on VisitorPageEntity {
  VisitorPageEntity copyWith({
    int? count,
    int? page,
    int? limit,
    int? countPage,
    List<VisitorPageList>? list,
  }) {
    return VisitorPageEntity()
      ..count = count ?? this.count
      ..page = page ?? this.page
      ..limit = limit ?? this.limit
      ..countPage = countPage ?? this.countPage
      ..list = list ?? this.list;
  }
}

VisitorPageList $VisitorPageListFromJson(Map<String, dynamic> json) {
  final VisitorPageList visitorPageList = VisitorPageList();
  final String? id = jsonConvert.convert<String>(json['id']);
  if (id != null) {
    visitorPageList.id = id;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    visitorPageList.name = name;
  }
  final String? phone = jsonConvert.convert<String>(json['phone']);
  if (phone != null) {
    visitorPageList.phone = phone;
  }
  final String? nric = jsonConvert.convert<String>(json['nric']);
  if (nric != null) {
    visitorPageList.nric = nric;
  }
  final String? vehicleNumber = jsonConvert.convert<String>(json['vehicle_number']);
  if (vehicleNumber != null) {
    visitorPageList.vehicleNumber = vehicleNumber;
  }
  final String? createdAt = jsonConvert.convert<String>(json['created_at']);
  if (createdAt != null) {
    visitorPageList.createdAt = createdAt;
  }
  final String? note = jsonConvert.convert<String>(json['note']);
  if (note != null) {
    visitorPageList.note = note;
  }
  return visitorPageList;
}

Map<String, dynamic> $VisitorPageListToJson(VisitorPageList entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['name'] = entity.name;
  data['phone'] = entity.phone;
  data['nric'] = entity.nric;
  data['vehicle_number'] = entity.vehicleNumber;
  data['created_at'] = entity.createdAt;
  data['note'] = entity.note;
  return data;
}

extension VisitorPageListExtension on VisitorPageList {
  VisitorPageList copyWith({
    String? id,
    String? name,
    String? phone,
    String? nric,
    String? vehicleNumber,
    String? createdAt,
    String? note,
  }) {
    return VisitorPageList()
      ..id = id ?? this.id
      ..name = name ?? this.name
      ..phone = phone ?? this.phone
      ..nric = nric ?? this.nric
      ..vehicleNumber = vehicleNumber ?? this.vehicleNumber
      ..createdAt = createdAt ?? this.createdAt
      ..note = note ?? this.note;
  }
}