From 7f9b03aafacb65ed5a1436d1b55c28be60272034 Mon Sep 17 00:00:00 2001 From: jos3duardo Date: Sun, 10 Aug 2025 00:55:43 -0400 Subject: [PATCH] Add PaymentsSummary endpoint to PaymentsController for retrieving payment summaries --- src/modules/payments/payments.controller.ts | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/modules/payments/payments.controller.ts b/src/modules/payments/payments.controller.ts index 6928439..79cd788 100644 --- a/src/modules/payments/payments.controller.ts +++ b/src/modules/payments/payments.controller.ts @@ -1,13 +1,25 @@ -import { Body, Controller, Post } from '@nestjs/common'; +import { Body, Controller, Get, Post, Query } from '@nestjs/common'; import { PaymentsService } from './services/payments.service'; import { CreatePaymentDto } from './dto/create-payment.dto'; +import { PaymentsSummaryService } from './services/payments-summary.service'; -@Controller('payments') +@Controller() export class PaymentsController { - constructor(private readonly paymentsService: PaymentsService) {} + constructor( + private readonly paymentsService: PaymentsService, + private readonly paymentsSummaryService: PaymentsSummaryService, + ) {} - @Post() + @Post('payments') async payment(@Body() createPaymentDto: CreatePaymentDto): Promise { return this.paymentsService.store(createPaymentDto); } + + @Get('payments-summary') + async getPaymentsSummary( + @Query('from') from: string, + @Query('to') to: string, + ): Promise { + return this.paymentsSummaryService.execute(from, to); + } }