part of '../category_dtos.dart';

@freezed
class CategoryDto with _$CategoryDto {
  const CategoryDto._();

  const factory CategoryDto({
    @JsonKey(name: 'id') String? id,
    @JsonKey(name: 'organization_id') String? organizationId,
    @JsonKey(name: 'name') String? name,
    @JsonKey(name: 'description') String? description,
    @JsonKey(name: 'business_type') String? businessType,
    @JsonKey(name: 'metadata') Map<String, dynamic>? metadata,
    @JsonKey(name: 'created_at') DateTime? createdAt,
    @JsonKey(name: 'updated_at') DateTime? updatedAt,
  }) = _CategoryDto;

  factory CategoryDto.fromJson(Map<String, dynamic> json) =>
      _$CategoryDtoFromJson(json);

  Category toDomain() => Category(
    id: id ?? '',
    organizationId: organizationId ?? '',
    name: name ?? '',
    description: description ?? '',
    businessType: businessType ?? '',
    metadata: metadata ?? {},
    createdAt: createdAt,
    updatedAt: updatedAt,
  );
}
