From 8a4abc74b8aaab227a46202794f12cf74c81714e Mon Sep 17 00:00:00 2001 From: Hitesh Wadhwani Date: Sun, 11 Aug 2024 14:58:48 +0530 Subject: [PATCH] addressed PR comments and added triggerBulkCancel in node SDK to cancel events in bulk --- apps/api/src/app/events/events.controller.ts | 2 +- .../process-bulk-cancel/process-bulk-cancel.usecase.ts | 2 +- packages/node/src/lib/events/events.ts | 6 ++++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/apps/api/src/app/events/events.controller.ts b/apps/api/src/app/events/events.controller.ts index a297aa6a2c0..5e2e9c5919c 100644 --- a/apps/api/src/app/events/events.controller.ts +++ b/apps/api/src/app/events/events.controller.ts @@ -214,7 +214,7 @@ export class EventsController { @ThrottlerCost(ApiRateLimitCostEnum.BULK) @Post('/trigger/bulk-cancel') @ApiOkResponse({ - type: TriggerBulkCancelResponseDto, + type: [TriggerBulkCancelResponseDto], }) @ApiOperation({ summary: 'Bulk Cancel triggered event', diff --git a/apps/api/src/app/events/usecases/process-bulk-cancel/process-bulk-cancel.usecase.ts b/apps/api/src/app/events/usecases/process-bulk-cancel/process-bulk-cancel.usecase.ts index 6afc02fc5a7..b6a2e2e3546 100644 --- a/apps/api/src/app/events/usecases/process-bulk-cancel/process-bulk-cancel.usecase.ts +++ b/apps/api/src/app/events/usecases/process-bulk-cancel/process-bulk-cancel.usecase.ts @@ -7,7 +7,7 @@ import { ProcessBulkCancelCommand } from './process-bulk-cancel.command'; export class ProcessBulkCancel { constructor(private cancelDelayed: CancelDelayed) {} - async execute(command: ProcessBulkCancelCommand) { + async execute(command: ProcessBulkCancelCommand): Promise { const results: TriggerBulkCancelResponseDto[] = []; for (const transactionId of command.transactionIds) { diff --git a/packages/node/src/lib/events/events.ts b/packages/node/src/lib/events/events.ts index fbb55d8140f..2375937a347 100644 --- a/packages/node/src/lib/events/events.ts +++ b/packages/node/src/lib/events/events.ts @@ -47,4 +47,10 @@ export class Events extends WithHttp implements IEvents { async cancel(transactionId: string) { return await this.http.delete(`/events/trigger/${transactionId}`); } + + async triggerBulkCancel(transactionIds: string[]) { + return await this.http.post(`/events/trigger/bulk-cancel`, { + transactionIds, + }); + } }