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

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

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

RepairServiceList $RepairServiceListFromJson(Map<String, dynamic> json) {
  final RepairServiceList repairServiceList = RepairServiceList();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    repairServiceList.id = id;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    repairServiceList.name = name;
  }
  final List<String>? resources = (json['resources'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<String>(e) as String).toList();
  if (resources != null) {
    repairServiceList.resources = resources;
  }
  final int? likesCount = jsonConvert.convert<int>(json['likes_count']);
  if (likesCount != null) {
    repairServiceList.likesCount = likesCount;
  }
  final bool? liked = jsonConvert.convert<bool>(json['liked']);
  if (liked != null) {
    repairServiceList.liked = liked;
  }
  final RepairServiceListMerchant? merchant = jsonConvert.convert<RepairServiceListMerchant>(json['merchant']);
  if (merchant != null) {
    repairServiceList.merchant = merchant;
  }
  final RepairServiceListCategory? category = jsonConvert.convert<RepairServiceListCategory>(json['category']);
  if (category != null) {
    repairServiceList.category = category;
  }
  return repairServiceList;
}

Map<String, dynamic> $RepairServiceListToJson(RepairServiceList entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['name'] = entity.name;
  data['resources'] = entity.resources;
  data['likes_count'] = entity.likesCount;
  data['liked'] = entity.liked;
  data['merchant'] = entity.merchant?.toJson();
  data['category'] = entity.category?.toJson();
  return data;
}

extension RepairServiceListExtension on RepairServiceList {
  RepairServiceList copyWith({
    int? id,
    String? name,
    List<String>? resources,
    int? likesCount,
    bool? liked,
    RepairServiceListMerchant? merchant,
    RepairServiceListCategory? category,
  }) {
    return RepairServiceList()
      ..id = id ?? this.id
      ..name = name ?? this.name
      ..resources = resources ?? this.resources
      ..likesCount = likesCount ?? this.likesCount
      ..liked = liked ?? this.liked
      ..merchant = merchant ?? this.merchant
      ..category = category ?? this.category;
  }
}

RepairServiceListMerchant $RepairServiceListMerchantFromJson(Map<String, dynamic> json) {
  final RepairServiceListMerchant repairServiceListMerchant = RepairServiceListMerchant();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    repairServiceListMerchant.id = id;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    repairServiceListMerchant.name = name;
  }
  return repairServiceListMerchant;
}

Map<String, dynamic> $RepairServiceListMerchantToJson(RepairServiceListMerchant entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['name'] = entity.name;
  return data;
}

extension RepairServiceListMerchantExtension on RepairServiceListMerchant {
  RepairServiceListMerchant copyWith({
    int? id,
    String? name,
  }) {
    return RepairServiceListMerchant()
      ..id = id ?? this.id
      ..name = name ?? this.name;
  }
}

RepairServiceListCategory $RepairServiceListCategoryFromJson(Map<String, dynamic> json) {
  final RepairServiceListCategory repairServiceListCategory = RepairServiceListCategory();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    repairServiceListCategory.id = id;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    repairServiceListCategory.name = name;
  }
  final String? type = jsonConvert.convert<String>(json['type']);
  if (type != null) {
    repairServiceListCategory.type = type;
  }
  return repairServiceListCategory;
}

Map<String, dynamic> $RepairServiceListCategoryToJson(RepairServiceListCategory entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['name'] = entity.name;
  data['type'] = entity.type;
  return data;
}

extension RepairServiceListCategoryExtension on RepairServiceListCategory {
  RepairServiceListCategory copyWith({
    int? id,
    String? name,
    String? type,
  }) {
    return RepairServiceListCategory()
      ..id = id ?? this.id
      ..name = name ?? this.name
      ..type = type ?? this.type;
  }
}