54 lines
1.7 KiB
TypeScript
54 lines
1.7 KiB
TypeScript
import {
|
|
Body,
|
|
Controller,
|
|
Delete,
|
|
Param,
|
|
Patch,
|
|
Post,
|
|
Put,
|
|
} from '@nestjs/common';
|
|
import { ReconciliationDataOrchestrator } from '../domain/usecases/reconciliation-data.orchestrator';
|
|
import { MODULE_NAME } from 'src/core/strings/constants/module.constants';
|
|
import { ApiBearerAuth, ApiTags } from '@nestjs/swagger';
|
|
import { BatchResult } from 'src/core/response/domain/ok-response.interface';
|
|
import { BatchIdsDto } from 'src/core/modules/infrastructure/dto/base-batch.dto';
|
|
import { Public } from 'src/core/guards';
|
|
import { TransactionEntity } from '../../transaction/domain/entities/transaction.entity';
|
|
import { UpdateReconciliationDto } from './dto/reconciliation.dto';
|
|
|
|
@ApiTags(`${MODULE_NAME.RECONCILIATION.split('-').join(' ')} - data`)
|
|
@Controller(`v1/${MODULE_NAME.RECONCILIATION}`)
|
|
@Public(false)
|
|
@ApiBearerAuth('JWT')
|
|
export class ReconciliationDataController {
|
|
constructor(private orchestrator: ReconciliationDataOrchestrator) {}
|
|
|
|
@Put('/batch-confirm')
|
|
async batchConfirm(@Body() body: BatchIdsDto): Promise<BatchResult> {
|
|
return await this.orchestrator.batchConfirm(body.ids);
|
|
}
|
|
|
|
@Patch(':id/confirm')
|
|
async confirm(@Param('id') dataId: string): Promise<String> {
|
|
return await this.orchestrator.confirm(dataId);
|
|
}
|
|
|
|
@Patch(':id/cancel')
|
|
async cancel(@Param('id') dataId: string): Promise<String> {
|
|
return await this.orchestrator.cancel(dataId);
|
|
}
|
|
|
|
@Put('/batch-cancel')
|
|
async batchCancel(@Body() body: BatchIdsDto): Promise<BatchResult> {
|
|
return await this.orchestrator.batchCancel(body.ids);
|
|
}
|
|
|
|
@Put(':id')
|
|
async update(
|
|
@Param('id') dataId: string,
|
|
@Body() data: UpdateReconciliationDto,
|
|
): Promise<TransactionEntity> {
|
|
return await this.orchestrator.update(dataId, data);
|
|
}
|
|
}
|