part of '../customer_dtos.dart';

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

  const factory CustomerDto({
    @JsonKey(name: "id") String? id,
    @JsonKey(name: "organization_id") String? organizationId,
    @JsonKey(name: "name") String? name,
    @JsonKey(name: "email") String? email,
    @JsonKey(name: "phone") String? phone,
    @JsonKey(name: "address") String? address,
    @JsonKey(name: "is_default") bool? isDefault,
    @JsonKey(name: "is_active") bool? isActive,
    @JsonKey(name: "metadata") Map<String, dynamic>? metadata,
    @JsonKey(name: "created_at") String? createdAt,
    @JsonKey(name: "updated_at") String? updatedAt,
  }) = _CustomerDto;

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

  Customer toDomain() {
    return Customer(
      id: id ?? '',
      organizationId: organizationId ?? '',
      name: name ?? '',
      email: email ?? '',
      phone: phone ?? '',
      address: address ?? '',
      isDefault: isDefault ?? false,
      isActive: isActive ?? false,
      metadata: metadata ?? {},
      createdAt: createdAt ?? '',
      updatedAt: updatedAt ?? '',
    );
  }
}
