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

HotelInfoEntity $HotelInfoEntityFromJson(Map<String, dynamic> json) {
  final HotelInfoEntity hotelInfoEntity = HotelInfoEntity();
  final int? adminId = jsonConvert.convert<int>(json['admin_id']);
  if (adminId != null) {
    hotelInfoEntity.adminId = adminId;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    hotelInfoEntity.name = name;
  }
  final int? hotelId = jsonConvert.convert<int>(json['hotel_id']);
  if (hotelId != null) {
    hotelInfoEntity.hotelId = hotelId;
  }
  final String? hotelName = jsonConvert.convert<String>(json['hotel_name']);
  if (hotelName != null) {
    hotelInfoEntity.hotelName = hotelName;
  }
  final List<HotelInfoMenus>? menus = (json['menus'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<HotelInfoMenus>(e) as HotelInfoMenus).toList();
  if (menus != null) {
    hotelInfoEntity.menus = menus;
  }
  final String? token = jsonConvert.convert<String>(json['token']);
  if (token != null) {
    hotelInfoEntity.token = token;
  }
  return hotelInfoEntity;
}

Map<String, dynamic> $HotelInfoEntityToJson(HotelInfoEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['admin_id'] = entity.adminId;
  data['name'] = entity.name;
  data['hotel_id'] = entity.hotelId;
  data['hotel_name'] = entity.hotelName;
  data['menus'] = entity.menus?.map((v) => v.toJson()).toList();
  data['token'] = entity.token;
  return data;
}

extension HotelInfoEntityExtension on HotelInfoEntity {
  HotelInfoEntity copyWith({
    int? adminId,
    String? name,
    int? hotelId,
    String? hotelName,
    List<HotelInfoMenus>? menus,
    String? token,
  }) {
    return HotelInfoEntity()
      ..adminId = adminId ?? this.adminId
      ..name = name ?? this.name
      ..hotelId = hotelId ?? this.hotelId
      ..hotelName = hotelName ?? this.hotelName
      ..menus = menus ?? this.menus
      ..token = token ?? this.token;
  }
}

HotelInfoMenus $HotelInfoMenusFromJson(Map<String, dynamic> json) {
  final HotelInfoMenus hotelInfoMenus = HotelInfoMenus();
  final String? key = jsonConvert.convert<String>(json['key']);
  if (key != null) {
    hotelInfoMenus.key = key;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    hotelInfoMenus.name = name;
  }
  final String? route = jsonConvert.convert<String>(json['route']);
  if (route != null) {
    hotelInfoMenus.route = route;
  }
  final String? redDot = jsonConvert.convert<String>(json['red_dot']);
  if (redDot != null) {
    hotelInfoMenus.redDot = redDot;
  }
  final bool? own = jsonConvert.convert<bool>(json['own']);
  if (own != null) {
    hotelInfoMenus.own = own;
  }
  final List<HotelInfoMenusChildren>? children = (json['children'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<HotelInfoMenusChildren>(e) as HotelInfoMenusChildren).toList();
  if (children != null) {
    hotelInfoMenus.children = children;
  }
  return hotelInfoMenus;
}

Map<String, dynamic> $HotelInfoMenusToJson(HotelInfoMenus entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['key'] = entity.key;
  data['name'] = entity.name;
  data['route'] = entity.route;
  data['red_dot'] = entity.redDot;
  data['own'] = entity.own;
  data['children'] = entity.children?.map((v) => v.toJson()).toList();
  return data;
}

extension HotelInfoMenusExtension on HotelInfoMenus {
  HotelInfoMenus copyWith({
    String? key,
    String? name,
    String? route,
    String? redDot,
    bool? own,
    List<HotelInfoMenusChildren>? children,
  }) {
    return HotelInfoMenus()
      ..key = key ?? this.key
      ..name = name ?? this.name
      ..route = route ?? this.route
      ..redDot = redDot ?? this.redDot
      ..own = own ?? this.own
      ..children = children ?? this.children;
  }
}

HotelInfoMenusChildren $HotelInfoMenusChildrenFromJson(Map<String, dynamic> json) {
  final HotelInfoMenusChildren hotelInfoMenusChildren = HotelInfoMenusChildren();
  final String? key = jsonConvert.convert<String>(json['key']);
  if (key != null) {
    hotelInfoMenusChildren.key = key;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    hotelInfoMenusChildren.name = name;
  }
  return hotelInfoMenusChildren;
}

Map<String, dynamic> $HotelInfoMenusChildrenToJson(HotelInfoMenusChildren entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['key'] = entity.key;
  data['name'] = entity.name;
  return data;
}

extension HotelInfoMenusChildrenExtension on HotelInfoMenusChildren {
  HotelInfoMenusChildren copyWith({
    String? key,
    String? name,
  }) {
    return HotelInfoMenusChildren()
      ..key = key ?? this.key
      ..name = name ?? this.name;
  }
}