export interface RaceCreationResultData { sessionId: string; price: string; timestamp: Date; } export class RaceCreationResult { private readonly _sessionId: string; private readonly _price: string; private readonly _timestamp: Date; private constructor(data: RaceCreationResultData) { this._sessionId = data.sessionId; this._price = data.price; this._timestamp = data.timestamp; } static create(data: RaceCreationResultData): RaceCreationResult { if (!data.sessionId || data.sessionId.trim() === '') { throw new Error('Session ID cannot be empty'); } if (!data.price || data.price.trim() === '') { throw new Error('Price cannot be empty'); } return new RaceCreationResult(data); } get sessionId(): string { return this._sessionId; } get price(): string { return this._price; } get timestamp(): Date { return this._timestamp; } equals(other: RaceCreationResult): boolean { return ( this._sessionId === other._sessionId && this._price === other._price && this._timestamp.getTime() === other._timestamp.getTime() ); } toJSON(): { sessionId: string; price: string; timestamp: string } { return { sessionId: this._sessionId, price: this._price, timestamp: this._timestamp.toISOString(), }; } }