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

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

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

PaidServiceList $PaidServiceListFromJson(Map<String, dynamic> json) {
  final PaidServiceList paidServiceList = PaidServiceList();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    paidServiceList.id = id;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    paidServiceList.name = name;
  }
  final List<String>? resources = (json['resources'] as List<dynamic>?)?.map(
          (e) => jsonConvert.convert<String>(e) as String).toList();
  if (resources != null) {
    paidServiceList.resources = resources;
  }
  final int? lowestPrice = jsonConvert.convert<int>(json['lowest_price']);
  if (lowestPrice != null) {
    paidServiceList.lowestPrice = lowestPrice;
  }
  final int? likesCount = jsonConvert.convert<int>(json['likes_count']);
  if (likesCount != null) {
    paidServiceList.likesCount = likesCount;
  }
  final bool? liked = jsonConvert.convert<bool>(json['liked']);
  if (liked != null) {
    paidServiceList.liked = liked;
  }
  final PaidServiceListMerchant? merchant = jsonConvert.convert<PaidServiceListMerchant>(json['merchant']);
  if (merchant != null) {
    paidServiceList.merchant = merchant;
  }
  final PaidServiceListCategory? category = jsonConvert.convert<PaidServiceListCategory>(json['category']);
  if (category != null) {
    paidServiceList.category = category;
  }
  return paidServiceList;
}

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

extension PaidServiceListExtension on PaidServiceList {
  PaidServiceList copyWith({
    int? id,
    String? name,
    List<String>? resources,
    int? lowestPrice,
    int? likesCount,
    bool? liked,
    PaidServiceListMerchant? merchant,
    PaidServiceListCategory? category,
  }) {
    return PaidServiceList()
      ..id = id ?? this.id
      ..name = name ?? this.name
      ..resources = resources ?? this.resources
      ..lowestPrice = lowestPrice ?? this.lowestPrice
      ..likesCount = likesCount ?? this.likesCount
      ..liked = liked ?? this.liked
      ..merchant = merchant ?? this.merchant
      ..category = category ?? this.category;
  }
}

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

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

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

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

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

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