/** * RatingCalculatedEvent * * Event published when a driver's rating is calculated. */ import { DomainEvent } from '../../../shared/ports/EventPublisher'; import { Rating } from '../Rating'; export class RatingCalculatedEvent implements DomainEvent { readonly type = 'RatingCalculatedEvent'; readonly timestamp: Date; constructor(private readonly rating: Rating) { this.timestamp = new Date(); } getRating(): Rating { return this.rating; } toJSON(): Record { return { type: this.type, timestamp: this.timestamp.toISOString(), rating: this.rating.toJSON(), }; } }