import { Controller, Get, Param, Query } from '@nestjs/common';
import { FilterRefundDto } from './dto/filter-refund.dto';
import { Pagination } from 'src/core/response';
import { PaginationResponse } from 'src/core/response/domain/ok-response.interface';
import { RefundEntity } from '../domain/entities/refund.entity';
import { RefundReadOrchestrator } from '../domain/usecases/refund-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.REFUND.split('-').join(' ')} - read`)
@Controller(`v1/${MODULE_NAME.REFUND}`)
@Public(false)
@ApiBearerAuth('JWT')
export class RefundReadController {
  constructor(private orchestrator: RefundReadOrchestrator) {}

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

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