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

PaidServiceDetailEntity $PaidServiceDetailEntityFromJson(Map<String, dynamic> json) {
  final PaidServiceDetailEntity paidServiceDetailEntity = PaidServiceDetailEntity();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    paidServiceDetailEntity.id = id;
  }
  final List<String>? resources = (json['resources'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<String>(e) as String).toList();
  if (resources != null) {
    paidServiceDetailEntity.resources = resources;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    paidServiceDetailEntity.name = name;
  }
  final int? evaluationsAvgScore = jsonConvert.convert<int>(json['evaluations_avg_score']);
  if (evaluationsAvgScore != null) {
    paidServiceDetailEntity.evaluationsAvgScore = evaluationsAvgScore;
  }
  final String? highlight = jsonConvert.convert<String>(json['highlight']);
  if (highlight != null) {
    paidServiceDetailEntity.highlight = highlight;
  }
  final int? urgentPrice = jsonConvert.convert<int>(json['urgent_price']);
  if (urgentPrice != null) {
    paidServiceDetailEntity.urgentPrice = urgentPrice;
  }
  final int? holidayPrice = jsonConvert.convert<int>(json['holiday_price']);
  if (holidayPrice != null) {
    paidServiceDetailEntity.holidayPrice = holidayPrice;
  }
  final int? nightPrice = jsonConvert.convert<int>(json['night_price']);
  if (nightPrice != null) {
    paidServiceDetailEntity.nightPrice = nightPrice;
  }
  final String? servicePeriodStart = jsonConvert.convert<String>(json['service_period_start']);
  if (servicePeriodStart != null) {
    paidServiceDetailEntity.servicePeriodStart = servicePeriodStart;
  }
  final String? servicePeriodEnd = jsonConvert.convert<String>(json['service_period_end']);
  if (servicePeriodEnd != null) {
    paidServiceDetailEntity.servicePeriodEnd = servicePeriodEnd;
  }
  final int? servicePeriodInterval = jsonConvert.convert<int>(json['service_period_interval']);
  if (servicePeriodInterval != null) {
    paidServiceDetailEntity.servicePeriodInterval = servicePeriodInterval;
  }
  final String? description = jsonConvert.convert<String>(json['description']);
  if (description != null) {
    paidServiceDetailEntity.description = description;
  }
  final PaidServiceDetailMerchant? merchant = jsonConvert.convert<PaidServiceDetailMerchant>(json['merchant']);
  if (merchant != null) {
    paidServiceDetailEntity.merchant = merchant;
  }
  final PaidServiceDetailCategory? category = jsonConvert.convert<PaidServiceDetailCategory>(json['category']);
  if (category != null) {
    paidServiceDetailEntity.category = category;
  }
  final List<PaidServiceDetailProducts>? products = (json['products'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<PaidServiceDetailProducts>(e) as PaidServiceDetailProducts).toList();
  if (products != null) {
    paidServiceDetailEntity.products = products;
  }
  final List<PaidServiceDetailEvaluations>? evaluations = (json['evaluations'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<PaidServiceDetailEvaluations>(e) as PaidServiceDetailEvaluations).toList();
  if (evaluations != null) {
    paidServiceDetailEntity.evaluations = evaluations;
  }
  return paidServiceDetailEntity;
}

Map<String, dynamic> $PaidServiceDetailEntityToJson(PaidServiceDetailEntity entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['resources'] = entity.resources;
  data['name'] = entity.name;
  data['evaluations_avg_score'] = entity.evaluationsAvgScore;
  data['highlight'] = entity.highlight;
  data['urgent_price'] = entity.urgentPrice;
  data['holiday_price'] = entity.holidayPrice;
  data['night_price'] = entity.nightPrice;
  data['service_period_start'] = entity.servicePeriodStart;
  data['service_period_end'] = entity.servicePeriodEnd;
  data['service_period_interval'] = entity.servicePeriodInterval;
  data['description'] = entity.description;
  data['merchant'] = entity.merchant?.toJson();
  data['category'] = entity.category?.toJson();
  data['products'] = entity.products?.map((v) => v.toJson()).toList();
  data['evaluations'] = entity.evaluations?.map((v) => v.toJson()).toList();
  return data;
}

extension PaidServiceDetailEntityExtension on PaidServiceDetailEntity {
  PaidServiceDetailEntity copyWith({
    int? id,
    List<String>? resources,
    String? name,
    int? evaluationsAvgScore,
    String? highlight,
    int? urgentPrice,
    int? holidayPrice,
    int? nightPrice,
    String? servicePeriodStart,
    String? servicePeriodEnd,
    int? servicePeriodInterval,
    String? description,
    PaidServiceDetailMerchant? merchant,
    PaidServiceDetailCategory? category,
    List<PaidServiceDetailProducts>? products,
    List<PaidServiceDetailEvaluations>? evaluations,
  }) {
    return PaidServiceDetailEntity()
      ..id = id ?? this.id
      ..resources = resources ?? this.resources
      ..name = name ?? this.name
      ..evaluationsAvgScore = evaluationsAvgScore ?? this.evaluationsAvgScore
      ..highlight = highlight ?? this.highlight
      ..urgentPrice = urgentPrice ?? this.urgentPrice
      ..holidayPrice = holidayPrice ?? this.holidayPrice
      ..nightPrice = nightPrice ?? this.nightPrice
      ..servicePeriodStart = servicePeriodStart ?? this.servicePeriodStart
      ..servicePeriodEnd = servicePeriodEnd ?? this.servicePeriodEnd
      ..servicePeriodInterval = servicePeriodInterval ?? this.servicePeriodInterval
      ..description = description ?? this.description
      ..merchant = merchant ?? this.merchant
      ..category = category ?? this.category
      ..products = products ?? this.products
      ..evaluations = evaluations ?? this.evaluations;
  }
}

PaidServiceDetailMerchant $PaidServiceDetailMerchantFromJson(Map<String, dynamic> json) {
  final PaidServiceDetailMerchant paidServiceDetailMerchant = PaidServiceDetailMerchant();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    paidServiceDetailMerchant.id = id;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    paidServiceDetailMerchant.name = name;
  }
  final String? contactPhone = jsonConvert.convert<String>(json['contact_phone']);
  if (contactPhone != null) {
    paidServiceDetailMerchant.contactPhone = contactPhone;
  }
  return paidServiceDetailMerchant;
}

Map<String, dynamic> $PaidServiceDetailMerchantToJson(PaidServiceDetailMerchant entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['name'] = entity.name;
  data['contact_phone'] = entity.contactPhone;
  return data;
}

extension PaidServiceDetailMerchantExtension on PaidServiceDetailMerchant {
  PaidServiceDetailMerchant copyWith({
    int? id,
    String? name,
    String? contactPhone,
  }) {
    return PaidServiceDetailMerchant()
      ..id = id ?? this.id
      ..name = name ?? this.name
      ..contactPhone = contactPhone ?? this.contactPhone;
  }
}

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

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

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

PaidServiceDetailProducts $PaidServiceDetailProductsFromJson(Map<String, dynamic> json) {
  final PaidServiceDetailProducts paidServiceDetailProducts = PaidServiceDetailProducts();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    paidServiceDetailProducts.id = id;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    paidServiceDetailProducts.name = name;
  }
  final String? shortDescription = jsonConvert.convert<String>(json['short_description']);
  if (shortDescription != null) {
    paidServiceDetailProducts.shortDescription = shortDescription;
  }
  final int? price = jsonConvert.convert<int>(json['price']);
  if (price != null) {
    paidServiceDetailProducts.price = price;
  }
  return paidServiceDetailProducts;
}

Map<String, dynamic> $PaidServiceDetailProductsToJson(PaidServiceDetailProducts entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['name'] = entity.name;
  data['short_description'] = entity.shortDescription;
  data['price'] = entity.price;
  return data;
}

extension PaidServiceDetailProductsExtension on PaidServiceDetailProducts {
  PaidServiceDetailProducts copyWith({
    int? id,
    String? name,
    String? shortDescription,
    int? price,
  }) {
    return PaidServiceDetailProducts()
      ..id = id ?? this.id
      ..name = name ?? this.name
      ..shortDescription = shortDescription ?? this.shortDescription
      ..price = price ?? this.price;
  }
}

PaidServiceDetailEvaluations $PaidServiceDetailEvaluationsFromJson(Map<String, dynamic> json) {
  final PaidServiceDetailEvaluations paidServiceDetailEvaluations = PaidServiceDetailEvaluations();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    paidServiceDetailEvaluations.id = id;
  }
  final int? score = jsonConvert.convert<int>(json['score']);
  if (score != null) {
    paidServiceDetailEvaluations.score = score;
  }
  final String? comment = jsonConvert.convert<String>(json['comment']);
  if (comment != null) {
    paidServiceDetailEvaluations.comment = comment;
  }
  final List<dynamic>? resources = (json['resources'] as List<dynamic>?)?.map(
          (e) => e).toList();
  if (resources != null) {
    paidServiceDetailEvaluations.resources = resources;
  }
  final PaidServiceDetailEvaluationsAccount? account = jsonConvert.convert<PaidServiceDetailEvaluationsAccount>(json['account']);
  if (account != null) {
    paidServiceDetailEvaluations.account = account;
  }
  final String? createdAt = jsonConvert.convert<String>(json['created_at']);
  if (createdAt != null) {
    paidServiceDetailEvaluations.createdAt = createdAt;
  }
  return paidServiceDetailEvaluations;
}

Map<String, dynamic> $PaidServiceDetailEvaluationsToJson(PaidServiceDetailEvaluations entity) {
  final Map<String, dynamic> data = <String, dynamic>{};
  data['id'] = entity.id;
  data['score'] = entity.score;
  data['comment'] = entity.comment;
  data['resources'] = entity.resources;
  data['account'] = entity.account?.toJson();
  data['created_at'] = entity.createdAt;
  return data;
}

extension PaidServiceDetailEvaluationsExtension on PaidServiceDetailEvaluations {
  PaidServiceDetailEvaluations copyWith({
    int? id,
    int? score,
    String? comment,
    List<dynamic>? resources,
    PaidServiceDetailEvaluationsAccount? account,
    String? createdAt,
  }) {
    return PaidServiceDetailEvaluations()
      ..id = id ?? this.id
      ..score = score ?? this.score
      ..comment = comment ?? this.comment
      ..resources = resources ?? this.resources
      ..account = account ?? this.account
      ..createdAt = createdAt ?? this.createdAt;
  }
}

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

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

extension PaidServiceDetailEvaluationsAccountExtension on PaidServiceDetailEvaluationsAccount {
  PaidServiceDetailEvaluationsAccount copyWith({
    int? id,
    String? name,
    String? avatar,
  }) {
    return PaidServiceDetailEvaluationsAccount()
      ..id = id ?? this.id
      ..name = name ?? this.name
      ..avatar = avatar ?? this.avatar;
  }
}