/**
 * SessionFailed Event
 *
 * Emitted when a session fails.
 */

import { DomainEvent } from './domain-event.base';
import { SessionType } from '../enums';

export class SessionFailedEvent extends DomainEvent {
  constructor(
    public readonly sessionId: string,
    public readonly partyId: string,
    public readonly sessionType: SessionType,
    public readonly errorMessage: string,
    public readonly errorCode?: string,
  ) {
    super();
  }

  get eventType(): string {
    return 'SessionFailed';
  }

  get aggregateId(): string {
    return this.sessionId;
  }

  get aggregateType(): string {
    return 'PartySession';
  }

  get payload(): Record<string, unknown> {
    return {
      sessionId: this.sessionId,
      partyId: this.partyId,
      sessionType: this.sessionType,
      errorMessage: this.errorMessage,
      errorCode: this.errorCode,
    };
  }
}
