import {
  AggregateRoot,
  IDomainError,
  Note,
  Result,
  UTCDateValue,
  UniqueID,
} from "@shared/contexts";

export interface IIncidenceProps {
  dealerId: UniqueID;
  date: UTCDateValue;
  description: Note;
}

export interface IIncidence {
  id: UniqueID;

  dealerId: UniqueID;
  date: UTCDateValue;
  description: Note;
}

export class Incidence extends AggregateRoot<IIncidenceProps> implements IIncidence {
  public static create(props: IIncidenceProps, id?: UniqueID): Result<Incidence, IDomainError> {
    const incidence = new Incidence(props, id);
    return Result.ok<Incidence>(incidence);
  }

  get id(): UniqueID {
    return this._id;
  }

  get dealerId() {
    return this.props.dealerId;
  }

  get date() {
    return this.props.date;
  }

  get description() {
    return this.props.description;
  }
}
