import type { RecordPageViewOutput } from '@core/analytics/application/use-cases/RecordPageViewUseCase';
import type { UseCaseOutputPort } from '@core/shared/application';
import type { RecordPageViewOutputDTO } from '../dtos/RecordPageViewOutputDTO';

export class RecordPageViewPresenter implements UseCaseOutputPort<RecordPageViewOutput> {
  private model: RecordPageViewOutputDTO | null = null;

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

  present(result: RecordPageViewOutput): void {
    this.model = {
      pageViewId: result.pageViewId,
    };
  }

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

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