import { Controller, Get, Param, Query } from '@nestjs/common';
import { FilterPaymentMethodDto } from './dto/filter-payment-method.dto';
import { Pagination } from 'src/core/response';
import { PaginationResponse } from 'src/core/response/domain/ok-response.interface';
import { PaymentMethodEntity } from '../domain/entities/payment-method.entity';
import { PaymentMethodReadOrchestrator } from '../domain/usecases/payment-method-read.orchestrator';
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
import { MODULE_NAME } from 'src/core/strings/constants/module.constants';
import { Public } from 'src/core/guards';

@ApiTags(`${MODULE_NAME.PAYMENT_METHOD.split('-').join(' ')} - read`)
@Controller(`v1/${MODULE_NAME.PAYMENT_METHOD}`)
@Public(false)
@ApiBearerAuth('JWT')
export class PaymentMethodReadController {
  constructor(private orchestrator: PaymentMethodReadOrchestrator) {}

  @Get()
  @Pagination()
  async index(
    @Query() params: FilterPaymentMethodDto,
  ): Promise<PaginationResponse<PaymentMethodEntity>> {
    return await this.orchestrator.index(params);
  }

  @Get(':id')
  async detail(@Param('id') id: string): Promise<PaymentMethodEntity> {
    return await this.orchestrator.detail(id);
  }
}
