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

ServiceCategoryEntity $ServiceCategoryEntityFromJson(Map<String, dynamic> json) {
  final ServiceCategoryEntity serviceCategoryEntity = ServiceCategoryEntity();
  final int? id = jsonConvert.convert<int>(json['id']);
  if (id != null) {
    serviceCategoryEntity.id = id;
  }
  final String? name = jsonConvert.convert<String>(json['name']);
  if (name != null) {
    serviceCategoryEntity.name = name;
  }
  final int? parentId = jsonConvert.convert<int>(json['parent_id']);
  if (parentId != null) {
    serviceCategoryEntity.parentId = parentId;
  }
  final String? type = jsonConvert.convert<String>(json['type']);
  if (type != null) {
    serviceCategoryEntity.type = type;
  }
  return serviceCategoryEntity;
}

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

extension ServiceCategoryEntityExtension on ServiceCategoryEntity {
  ServiceCategoryEntity copyWith({
    int? id,
    String? name,
    int? parentId,
    String? type,
  }) {
    return ServiceCategoryEntity()
      ..id = id ?? this.id
      ..name = name ?? this.name
      ..parentId = parentId ?? this.parentId
      ..type = type ?? this.type;
  }
}