import { Injectable } from '@nestjs/common';
import { IndexRefundManager } from './managers/index-refund.manager';
import { RefundReadService } from '../../data/services/refund-read.service';
import { RefundEntity } from '../entities/refund.entity';
import { PaginationResponse } from 'src/core/response/domain/ok-response.interface';
import { BaseReadOrchestrator } from 'src/core/modules/domain/usecase/orchestrators/base-read.orchestrator';
import { DetailRefundManager } from './managers/detail-refund.manager';
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';

@Injectable()
export class RefundReadOrchestrator extends BaseReadOrchestrator<RefundEntity> {
  constructor(
    private indexManager: IndexRefundManager,
    private detailManager: DetailRefundManager,
    private serviceData: RefundReadService,
  ) {
    super();
  }

  async index(params): Promise<PaginationResponse<RefundEntity>> {
    this.indexManager.setFilterParam(params);
    this.indexManager.setService(this.serviceData, TABLE_NAME.REFUND);
    await this.indexManager.execute();
    return this.indexManager.getResult();
  }

  async detail(dataId: string): Promise<RefundEntity> {
    this.detailManager.setData(dataId);
    this.detailManager.setService(this.serviceData, TABLE_NAME.REFUND);
    await this.detailManager.execute();
    return this.detailManager.getResult();
  }
}
