import { AggregateRoot } from '@modules/shared';

export interface ValuationProps {
  propertyId: string;
  estimatedPrice: bigint;
  confidence: number;
  pricePerM2: number;
  comparables: unknown;
  features: unknown;
  modelVersion: string;
}

export class ValuationEntity extends AggregateRoot<string> {
  private _propertyId: string;
  private _estimatedPrice: bigint;
  private _confidence: number;
  private _pricePerM2: number;
  private _comparables: unknown;
  private _features: unknown;
  private _modelVersion: string;

  constructor(id: string, props: ValuationProps, createdAt?: Date, updatedAt?: Date) {
    super(id, createdAt, updatedAt);
    this._propertyId = props.propertyId;
    this._estimatedPrice = props.estimatedPrice;
    this._confidence = props.confidence;
    this._pricePerM2 = props.pricePerM2;
    this._comparables = props.comparables;
    this._features = props.features;
    this._modelVersion = props.modelVersion;
  }

  get propertyId(): string { return this._propertyId; }
  get estimatedPrice(): bigint { return this._estimatedPrice; }
  get confidence(): number { return this._confidence; }
  get pricePerM2(): number { return this._pricePerM2; }
  get comparables(): unknown { return this._comparables; }
  get features(): unknown { return this._features; }
  get modelVersion(): string { return this._modelVersion; }

  static createNew(
    id: string,
    propertyId: string,
    estimatedPrice: bigint,
    confidence: number,
    pricePerM2: number,
    comparables: unknown,
    features: unknown,
    modelVersion: string,
  ): ValuationEntity {
    return new ValuationEntity(id, {
      propertyId,
      estimatedPrice,
      confidence,
      pricePerM2,
      comparables,
      features,
      modelVersion,
    });
  }
}
