import type {
  IGetPaymentsPresenter,
  GetPaymentsResultDTO,
  GetPaymentsViewModel,
} from '@core/payments/application/presenters/IGetPaymentsPresenter';

export class GetPaymentsPresenter implements IGetPaymentsPresenter {
  private result: GetPaymentsViewModel | null = null;

  reset() {
    this.result = null;
  }

  present(dto: GetPaymentsResultDTO) {
    this.result = dto;
  }

  getViewModel(): GetPaymentsViewModel | null {
    return this.result;
  }

  get viewModel(): GetPaymentsViewModel {
    if (!this.result) throw new Error('Presenter not presented');
    return this.result;
  }
}