import type { RecordEngagementOutput } from '@core/analytics/application/use-cases/RecordEngagementUseCase';
import type { UseCaseOutputPort } from '@core/shared/application';
import type { RecordEngagementOutputDTO } from '../dtos/RecordEngagementOutputDTO';

export class RecordEngagementPresenter implements UseCaseOutputPort<RecordEngagementOutput> {
  private model: RecordEngagementOutputDTO | null = null;

  reset(): void {
    this.model = null;
  }

  present(result: RecordEngagementOutput): void {
    this.model = {
      eventId: result.eventId,
      engagementWeight: result.engagementWeight,
    };
  }

  get responseModel(): RecordEngagementOutputDTO {
    if (!this.model) throw new Error('Presenter not presented');
    return this.model;
  }

  getResponseModel(): RecordEngagementOutputDTO {
    if (!this.model) throw new Error('Presenter not presented');
    return this.model;
  }
}
