import { Injectable } from '@nestjs/common';
import { CreatePaymentMethodManager } from './managers/create-payment-method.manager';
import { PaymentMethodDataService } from '../../data/services/payment-method-data.service';
import { PaymentMethodEntity } from '../entities/payment-method.entity';
import { DeletePaymentMethodManager } from './managers/delete-payment-method.manager';
import { UpdatePaymentMethodManager } from './managers/update-payment-method.manager';
import { BaseDataTransactionOrchestrator } from 'src/core/modules/domain/usecase/orchestrators/base-data-transaction.orchestrator';
import { ActivePaymentMethodManager } from './managers/active-payment-method.manager';
import { InactivePaymentMethodManager } from './managers/inactive-payment-method.manager';
import { ConfirmPaymentMethodManager } from './managers/confirm-payment-method.manager';
import { STATUS } from 'src/core/strings/constants/base.constants';
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
import { BatchConfirmPaymentMethodManager } from './managers/batch-confirm-payment-method.manager';
import { BatchInactivePaymentMethodManager } from './managers/batch-inactive-payment-method.manager';
import { BatchActivePaymentMethodManager } from './managers/batch-active-payment-method.manager';
import { BatchDeletePaymentMethodManager } from './managers/batch-delete-payment-method.manager';
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';

@Injectable()
export class PaymentMethodDataOrchestrator extends BaseDataTransactionOrchestrator<PaymentMethodEntity> {
  constructor(
    private createManager: CreatePaymentMethodManager,
    private updateManager: UpdatePaymentMethodManager,
    private deleteManager: DeletePaymentMethodManager,
    private activeManager: ActivePaymentMethodManager,
    private confirmManager: ConfirmPaymentMethodManager,
    private inactiveManager: InactivePaymentMethodManager,
    private batchDeleteManager: BatchDeletePaymentMethodManager,
    private batchActiveManager: BatchActivePaymentMethodManager,
    private batchConfirmManager: BatchConfirmPaymentMethodManager,
    private batchInactiveManager: BatchInactivePaymentMethodManager,
    private serviceData: PaymentMethodDataService,
  ) {
    super();
  }

  async create(data): Promise<PaymentMethodEntity> {
    this.createManager.setData(data);
    this.createManager.setService(this.serviceData, TABLE_NAME.PAYMENT_METHOD);
    await this.createManager.execute();
    return this.createManager.getResult();
  }

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

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

  async batchDelete(dataIds: string[]): Promise<BatchResult> {
    this.batchDeleteManager.setData(dataIds);
    this.batchDeleteManager.setService(
      this.serviceData,
      TABLE_NAME.PAYMENT_METHOD,
    );
    await this.batchDeleteManager.execute();
    return this.batchDeleteManager.getResult();
  }

  async active(dataId): Promise<string> {
    this.activeManager.setData(dataId, STATUS.ACTIVE);
    this.activeManager.setService(this.serviceData, TABLE_NAME.PAYMENT_METHOD);
    await this.activeManager.execute();
    return this.activeManager.getResult();
  }

  async batchActive(dataIds: string[]): Promise<BatchResult> {
    this.batchActiveManager.setData(dataIds, STATUS.ACTIVE);
    this.batchActiveManager.setService(
      this.serviceData,
      TABLE_NAME.PAYMENT_METHOD,
    );
    await this.batchActiveManager.execute();
    return this.batchActiveManager.getResult();
  }

  async confirm(dataId): Promise<string> {
    this.confirmManager.setData(dataId, STATUS.ACTIVE);
    this.confirmManager.setService(this.serviceData, TABLE_NAME.PAYMENT_METHOD);
    await this.confirmManager.execute();
    return this.confirmManager.getResult();
  }

  async batchConfirm(dataIds: string[]): Promise<BatchResult> {
    this.batchConfirmManager.setData(dataIds, STATUS.ACTIVE);
    this.batchConfirmManager.setService(
      this.serviceData,
      TABLE_NAME.PAYMENT_METHOD,
    );
    await this.batchConfirmManager.execute();
    return this.batchConfirmManager.getResult();
  }

  async inactive(dataId): Promise<string> {
    this.inactiveManager.setData(dataId, STATUS.INACTIVE);
    this.inactiveManager.setService(
      this.serviceData,
      TABLE_NAME.PAYMENT_METHOD,
    );
    await this.inactiveManager.execute();
    return this.inactiveManager.getResult();
  }

  async batchInactive(dataIds: string[]): Promise<BatchResult> {
    this.batchInactiveManager.setData(dataIds, STATUS.INACTIVE);
    this.batchInactiveManager.setService(
      this.serviceData,
      TABLE_NAME.PAYMENT_METHOD,
    );
    await this.batchInactiveManager.execute();
    return this.batchInactiveManager.getResult();
  }
}
