import { Injectable } from '@nestjs/common';
import { IndexPaymentMethodManager } from './managers/index-payment-method.manager';
import { PaymentMethodReadService } from '../../data/services/payment-method-read.service';
import { PaymentMethodEntity } from '../entities/payment-method.entity';
import { PaginationResponse } from 'src/core/response/domain/ok-response.interface';
import { BaseReadOrchestrator } from 'src/core/modules/domain/usecase/orchestrators/base-read.orchestrator';
import { DetailPaymentMethodManager } from './managers/detail-payment-method.manager';
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';

@Injectable()
export class PaymentMethodReadOrchestrator extends BaseReadOrchestrator<PaymentMethodEntity> {
  constructor(
    private indexManager: IndexPaymentMethodManager,
    private detailManager: DetailPaymentMethodManager,
    private serviceData: PaymentMethodReadService,
  ) {
    super();
  }

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

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