From b88fde0891f9dadeeb0d3fa38a565f4d8f07ee01 Mon Sep 17 00:00:00 2001 From: Kevin Date: Mon, 19 Sep 2022 22:54:11 -0500 Subject: [PATCH 1/4] feat(mojaloop/#2803): add BulkTransfersRequestedDmEvt implementation and handling --- modules/api-svc/package.json | 2 +- .../handlers/bulk-transfers-requested.js | 63 ++++++ .../src/FSPIOPEventHandler/handlers/index.js | 1 + .../api-svc/src/FSPIOPEventHandler/index.js | 12 +- .../test/unit/FSPIOPEventHandler.test.js | 111 ++++++++-- .../package.json | 10 +- .../package.json | 10 +- modules/private-shared-lib/package.json | 4 +- .../bulk_transfers_callback_received.ts | 25 ++- .../src/events/outbound_domain_event/index.ts | 1 + package.json | 8 +- yarn.lock | 194 +++++++++--------- 12 files changed, 295 insertions(+), 146 deletions(-) create mode 100644 modules/api-svc/src/FSPIOPEventHandler/handlers/bulk-transfers-requested.js diff --git a/modules/api-svc/package.json b/modules/api-svc/package.json index 66058860b..9e4a7aa77 100644 --- a/modules/api-svc/package.json +++ b/modules/api-svc/package.json @@ -104,7 +104,7 @@ "jest": "^29.0.3", "jest-junit": "^14.0.1", "nock": "^13.2.9", - "npm-check-updates": "^16.1.3", + "npm-check-updates": "^16.2.1", "openapi-response-validator": "^12.0.2", "openapi-typescript": "^5.4.1", "redis-mock": "^0.56.3", diff --git a/modules/api-svc/src/FSPIOPEventHandler/handlers/bulk-transfers-requested.js b/modules/api-svc/src/FSPIOPEventHandler/handlers/bulk-transfers-requested.js new file mode 100644 index 000000000..d85e6cddf --- /dev/null +++ b/modules/api-svc/src/FSPIOPEventHandler/handlers/bulk-transfers-requested.js @@ -0,0 +1,63 @@ +/***** + License + -------------- + Copyright © 2017 Bill & Melinda Gates Foundation + The Mojaloop files are made available by the Bill & Melinda Gates Foundation under the Apache License, Version 2.0 (the "License") and you may not use these files except in compliance with the License. You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 + Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + Contributors + -------------- + This is the official list (alphabetical ordering) of the Mojaloop project contributors for this file. + Names of the original copyright holders (individuals or organizations) + should be listed with a '*' in the first column. People who have + contributed from an organization can be listed under the organization + that actually holds the copyright for their contributions (see the + Gates Foundation organization for an example). Those individuals should have + their names indented and be marked with a '-'. Email address can be added + optionally within square brackets . + * Gates Foundation + - Name Surname + * Modusbox + - Kevin Leyow + -------------- + ******/ + +const { BulkTransfersRequestedDmEvt } = require('@mojaloop/sdk-scheme-adapter-private-shared-lib'); +const { OutboundBulkTransfersModel } = require('../../lib/model'); +const { BulkTransfersCallbackReceivedDmEvt } = require('@mojaloop/sdk-scheme-adapter-private-shared-lib'); + +module.exports.handleBulkTransfersRequestedDmEvt = async ( + message, + options, + logger, +) => { + const event = BulkTransfersRequestedDmEvt.CreateFromDomainEvent(message); + + try { + // use the bulk quotes model to execute asynchronous request with the switch + const model = new OutboundBulkTransfersModel({ + ...options.config, + cache: options.cache, + logger: logger, + wso2: options.wso2Auth, + }); + + await model.initialize(event.request); + const response = await model.run(); + + const bulkTransfersCallbackReceivedDmEvt = new BulkTransfersCallbackReceivedDmEvt({ + bulkId: event.getKey(), + content: { + batchId: event.batchId, + bulkTransferId: response.bulkTransferId, + bulkTransfersResult: response, + }, + timestamp: Date.now(), + headers: [], + }); + + await options.producer.sendDomainEvent(bulkTransfersCallbackReceivedDmEvt); + } catch (err) { + logger.push({ err }).log('Error in handleBulkTransfersRequestedDmEvt'); + } +}; diff --git a/modules/api-svc/src/FSPIOPEventHandler/handlers/index.js b/modules/api-svc/src/FSPIOPEventHandler/handlers/index.js index 9fa37e210..27990d921 100644 --- a/modules/api-svc/src/FSPIOPEventHandler/handlers/index.js +++ b/modules/api-svc/src/FSPIOPEventHandler/handlers/index.js @@ -25,4 +25,5 @@ module.exports = { ...require('./bulk-quotes-requested'), ...require('./party-info-requested'), + ...require('./bulk-transfers-requested'), }; diff --git a/modules/api-svc/src/FSPIOPEventHandler/index.js b/modules/api-svc/src/FSPIOPEventHandler/index.js index 86e4aa9e8..eef231fde 100644 --- a/modules/api-svc/src/FSPIOPEventHandler/index.js +++ b/modules/api-svc/src/FSPIOPEventHandler/index.js @@ -29,15 +29,15 @@ const { BC_CONFIG, KafkaDomainEventConsumer, KafkaDomainEventProducer, + BulkTransfersRequestedDmEvt, + PartyInfoRequestedDmEvt, + BulkQuotesRequestedDmEvt, } = require('@mojaloop/sdk-scheme-adapter-private-shared-lib'); const { handlePartyInfoRequestedDmEvt, handleBulkQuotesRequestedDmEvt, + handleBulkTransfersRequestedDmEvt, } = require('./handlers'); -const { - PartyInfoRequestedDmEvt, - BulkQuotesRequestedDmEvt, -} = require('@mojaloop/sdk-scheme-adapter-private-shared-lib'); class FSPIOPEventHandler { constructor({ config, logger, cache, wso2Auth }) { @@ -94,6 +94,10 @@ class FSPIOPEventHandler { await handleBulkQuotesRequestedDmEvt(message, this._domainEventHandlerOptions, this._logger); break; } + case BulkTransfersRequestedDmEvt.name: { + await handleBulkTransfersRequestedDmEvt(message, this._domainEventHandlerOptions, this._logger); + break; + } default: { this._logger.debug(`${message?.getName()}:${message?.getKey()} - Skipping unknown domain event`); return; diff --git a/modules/api-svc/test/unit/FSPIOPEventHandler.test.js b/modules/api-svc/test/unit/FSPIOPEventHandler.test.js index ff08382fa..d93c5af0d 100644 --- a/modules/api-svc/test/unit/FSPIOPEventHandler.test.js +++ b/modules/api-svc/test/unit/FSPIOPEventHandler.test.js @@ -5,27 +5,35 @@ const config = require('./data/defaultConfig.json'); const { PartyInfoRequestedDmEvt, BulkQuotesRequestedDmEvt, + BulkTransfersRequestedDmEvt, + KafkaDomainEventConsumer, + KafkaDomainEventProducer, } = require('@mojaloop/sdk-scheme-adapter-private-shared-lib'); const { OutboundBulkQuotesModel, PartiesModel, + OutboundBulkTransfersModel, } = require('~/lib/model'); -const { - KafkaDomainEventConsumer, - KafkaDomainEventProducer, -} = require('@mojaloop/sdk-scheme-adapter-private-shared-lib'); - const logger = new Logger.Logger({ context: { app: 'FSPIOPEventHandler' }, stringify: () => '' }); describe('FSPIOPEventHandler', () => { - test('should handle PartyInfoRequestedDmEvt event', async () => { - const fspiopEventHandler = new FSPIOPEventHandler({ + let fspiopEventHandler; + + beforeEach(async () => { + fspiopEventHandler = new FSPIOPEventHandler({ config, logger, }); await fspiopEventHandler.start(); + }); + + afterAll(async () => { + await fspiopEventHandler.stop(); + }); + + test('should handle PartyInfoRequestedDmEvt event', async () => { const request = { partyIdType: 'PERSONAL_ID', partyIdentifier: '16135551212', @@ -99,16 +107,9 @@ describe('FSPIOPEventHandler', () => { currentState: 'COMPLETED', } }); - - await fspiopEventHandler.stop(); }); test('should return error information for PartyInfoRequestedDmEvt event', async () => { - const fspiopEventHandler = new FSPIOPEventHandler({ - config, - logger, - }); - await fspiopEventHandler.start(); const request = { partyIdType: 'PERSONAL_ID', partyIdentifier: '16135551212', @@ -180,16 +181,9 @@ describe('FSPIOPEventHandler', () => { }, }, }); - - await fspiopEventHandler.stop(); }); test('should handle BulkQuotesRequestedDmEvt event', async () => { - const fspiopEventHandler = new FSPIOPEventHandler({ - config, - logger, - }); - await fspiopEventHandler.start(); const bulkId = 'bulk-tx-test'; const event = new BulkQuotesRequestedDmEvt({ bulkId, @@ -251,8 +245,81 @@ describe('FSPIOPEventHandler', () => { bulkQuoteId: bulkQuoteResponse.bulkQuoteId, bulkQuotesResult: bulkQuoteResponse, }); + }); - await fspiopEventHandler.stop(); + test('should handle BulkTransfersRequestedDmEvt event', async () => { + const bulkTransfersRequest = { + homeTransactionId: 'home-transaction-id', + from: { + idType: 'MSISDN', + idValue: '123456' + }, + individualTransfers: [ + { + homeTransactionId: 'home-individual-transfer-id', + to: { + partyIdInfo: { + partyIdType: 'MSISDN', + partyIdentifier: '1' + }, + }, + amountType: 'SEND', + currency: 'USD', + amount: '1' + }, + ] + }; + const bulkTransfersRequestedDmEvt = new BulkTransfersRequestedDmEvt({ + bulkId: 'bulk-tx-test', + headers: [], + timestamp: Date.now(), + content: { + batchId: '61c35bae-77d0-4f7d-b894-be375b838ff6', + bulkTransfersRequest, + }, + }); + + const bulkTransfersResult = { + bulkTransferId: '81c35bae-77d0-4f7d-b894-be375b838ff6', + currentState: 'COMPLETED', + individualTransferResults: [ + { + transferId: 'individual-transfer-id', + to: { + partyIdInfo: { + partyIdType: 'MSISDN', + partyIdentifier: '1' + }, + }, + amountType: 'SEND', + currency: 'USD', + amount: '1' + }, + ] + }; + + const initializeSpy = jest.spyOn(OutboundBulkTransfersModel.prototype, 'initialize') + .mockImplementationOnce(async () => bulkTransfersResult); + + jest.spyOn(OutboundBulkTransfersModel.prototype, 'run') + .mockImplementationOnce(async () => bulkTransfersResult); + + + const handler = KafkaDomainEventConsumer.mock.ctor.mock.calls[0][0]; + await handler(bulkTransfersRequestedDmEvt); + + // run workflow + expect(initializeSpy).toBeCalledWith(bulkTransfersRequestedDmEvt.request); + + await new Promise((resolve) => setTimeout(resolve, 1500)); + + const sent = KafkaDomainEventProducer.mock.sendDomainEvent.mock.calls[0][0]; + expect(sent._data.name).toEqual('BulkTransfersCallbackReceivedDmEvt'); + expect(sent._data.content).toEqual({ + batchId: '61c35bae-77d0-4f7d-b894-be375b838ff6', + bulkTransferId: '81c35bae-77d0-4f7d-b894-be375b838ff6', + bulkTransfersResult + }); }); }); diff --git a/modules/outbound-command-event-handler/package.json b/modules/outbound-command-event-handler/package.json index bf2de7944..4b8d57877 100644 --- a/modules/outbound-command-event-handler/package.json +++ b/modules/outbound-command-event-handler/package.json @@ -40,8 +40,8 @@ }, "dependencies": { "@mojaloop/api-snippets": "^15.0.1", - "@mojaloop/logging-bc-client-lib": "^0.1.13", - "@mojaloop/logging-bc-public-types-lib": "^0.1.10", + "@mojaloop/logging-bc-client-lib": "^0.1.14", + "@mojaloop/logging-bc-public-types-lib": "^0.1.11", "@mojaloop/sdk-scheme-adapter-private-shared-lib": "workspace:^", "ajv": "^8.11.0", "convict": "^6.2.3", @@ -60,13 +60,13 @@ "@types/supertest": "^2.0.12", "@types/swagger-ui-express": "^4.1.3", "@types/yamljs": "^0.2.31", - "@typescript-eslint/eslint-plugin": "^5.37.0", - "@typescript-eslint/parser": "^5.37.0", + "@typescript-eslint/eslint-plugin": "^5.38.0", + "@typescript-eslint/parser": "^5.38.0", "copyfiles": "^2.4.1", "eslint": "^8.23.1", "jest": "^29.0.3", "nodemon": "^2.0.20", - "npm-check-updates": "^16.1.3", + "npm-check-updates": "^16.2.1", "replace": "^1.2.1", "standard-version": "^9.5.0", "ts-jest": "^29.0.1", diff --git a/modules/outbound-domain-event-handler/package.json b/modules/outbound-domain-event-handler/package.json index c6e2c1e01..487389092 100644 --- a/modules/outbound-domain-event-handler/package.json +++ b/modules/outbound-domain-event-handler/package.json @@ -38,8 +38,8 @@ "snapshot": "standard-version --no-verify --skip.changelog --prerelease snapshot --releaseCommitMessageFormat 'chore(snapshot): {{currentTag}}'" }, "dependencies": { - "@mojaloop/logging-bc-client-lib": "^0.1.13", - "@mojaloop/logging-bc-public-types-lib": "^0.1.10", + "@mojaloop/logging-bc-client-lib": "^0.1.14", + "@mojaloop/logging-bc-public-types-lib": "^0.1.11", "@mojaloop/sdk-scheme-adapter-private-shared-lib": "workspace:^", "convict": "^6.2.3" }, @@ -48,12 +48,12 @@ "@types/jest": "^29.0.3", "@types/node": "^18.7.18", "@types/node-cache": "^4.2.5", - "@typescript-eslint/eslint-plugin": "^5.37.0", - "@typescript-eslint/parser": "^5.37.0", + "@typescript-eslint/eslint-plugin": "^5.38.0", + "@typescript-eslint/parser": "^5.38.0", "eslint": "^8.23.1", "jest": "^29.0.3", "nodemon": "^2.0.20", - "npm-check-updates": "^16.1.3", + "npm-check-updates": "^16.2.1", "replace": "^1.2.1", "standard-version": "^9.5.0", "ts-jest": "^29.0.1", diff --git a/modules/private-shared-lib/package.json b/modules/private-shared-lib/package.json index 78d205792..4ab604c6d 100644 --- a/modules/private-shared-lib/package.json +++ b/modules/private-shared-lib/package.json @@ -28,7 +28,7 @@ }, "dependencies": { "@mojaloop/api-snippets": "^15.0.1", - "@mojaloop/logging-bc-public-types-lib": "^0.1.10", + "@mojaloop/logging-bc-public-types-lib": "^0.1.11", "@mojaloop/platform-shared-lib-messaging-types-lib": "^0.0.3", "@mojaloop/platform-shared-lib-nodejs-kafka-client-lib": "^0.0.9", "ajv": "^8.11.0", @@ -39,7 +39,7 @@ "@types/node": "^18.7.18", "eslint": "^8.23.1", "jest": "^29.0.3", - "npm-check-updates": "^16.1.3", + "npm-check-updates": "^16.2.1", "replace": "^1.2.1", "standard-version": "^9.5.0", "ts-jest": "^29.0.1", diff --git a/modules/private-shared-lib/src/events/outbound_domain_event/bulk_transfers_callback_received.ts b/modules/private-shared-lib/src/events/outbound_domain_event/bulk_transfers_callback_received.ts index e4a8d44f9..a2d732a53 100644 --- a/modules/private-shared-lib/src/events/outbound_domain_event/bulk_transfers_callback_received.ts +++ b/modules/private-shared-lib/src/events/outbound_domain_event/bulk_transfers_callback_received.ts @@ -2,10 +2,15 @@ import { DomainEvent } from '../domain_event'; import { IMessageHeader } from '@mojaloop/platform-shared-lib-messaging-types-lib'; +import { SDKSchemeAdapter } from '@mojaloop/api-snippets'; export type IBulkTransfersCallbackReceivedDmEvtData = { bulkId: string; - content: null; + content: { + batchId: string; + bulkTransferId: string; + bulkTransfersResult: SDKSchemeAdapter.Outbound.V2_0_0.Types.bulkTransferResponse + }, timestamp: number | null; headers: IMessageHeader[] | null; }; @@ -16,7 +21,7 @@ export class BulkTransfersCallbackReceivedDmEvt extends DomainEvent { key: data.bulkId, timestamp: data.timestamp, headers: data.headers, - content: null, + content: data.content, name: BulkTransfersCallbackReceivedDmEvt.name, }); } @@ -31,6 +36,22 @@ export class BulkTransfersCallbackReceivedDmEvt extends DomainEvent { timestamp: message.getTimeStamp(), headers: message.getHeaders(), }; + return new BulkTransfersCallbackReceivedDmEvt(data); } + + get batchId(): string { + const content = this.getContent() as IBulkTransfersCallbackReceivedDmEvtData['content']; + return content.batchId; + } + + get bulkTransferId(): string { + const content = this.getContent() as IBulkTransfersCallbackReceivedDmEvtData['content']; + return content.bulkTransferId; + } + + get bulkTransfersResult(): SDKSchemeAdapter.Outbound.V2_0_0.Types.bulkTransferResponse { + const content = this.getContent() as IBulkTransfersCallbackReceivedDmEvtData['content']; + return content.bulkTransfersResult; + } } diff --git a/modules/private-shared-lib/src/events/outbound_domain_event/index.ts b/modules/private-shared-lib/src/events/outbound_domain_event/index.ts index f83230222..9f597fd5c 100644 --- a/modules/private-shared-lib/src/events/outbound_domain_event/index.ts +++ b/modules/private-shared-lib/src/events/outbound_domain_event/index.ts @@ -40,3 +40,4 @@ export * from './sdk_outbound_bulk_accept_quote_received'; export * from './sdk_outbound_bulk_accept_quote_processed'; export * from './sdk_outbound_bulk_response_sent'; export * from './bulk_transfers_requested'; +export * from './bulk_transfers_callback_received'; diff --git a/package.json b/package.json index 03ffe4674..6a56e5a16 100644 --- a/package.json +++ b/package.json @@ -60,15 +60,15 @@ "wait-4-docker": "node ./scripts/_wait4_all.js" }, "dependencies": { - "nx": "14.7.5", + "nx": "14.7.6", "tslib": "^2.4.0" }, "devDependencies": { "@types/jest": "^29.0.3", "@types/node": "^18.7.18", "@types/node-cache": "^4.2.5", - "@typescript-eslint/eslint-plugin": "^5.37.0", - "@typescript-eslint/parser": "^5.37.0", + "@typescript-eslint/eslint-plugin": "^5.38.0", + "@typescript-eslint/parser": "^5.38.0", "audit-ci": "^6.3.0", "eslint": "^8.23.1", "eslint-config-airbnb-typescript": "^17.0.0", @@ -76,7 +76,7 @@ "husky": "^8.0.1", "jest": "^29.0.3", "nodemon": "^2.0.20", - "npm-check-updates": "^16.1.3", + "npm-check-updates": "^16.2.1", "replace": "^1.2.1", "standard-version": "^9.5.0", "ts-jest": "^29.0.1", diff --git a/yarn.lock b/yarn.lock index a92c6ea7f..84bc4b987 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2492,14 +2492,14 @@ __metadata: languageName: node linkType: hard -"@mojaloop/logging-bc-client-lib@npm:^0.1.13": - version: 0.1.13 - resolution: "@mojaloop/logging-bc-client-lib@npm:0.1.13" +"@mojaloop/logging-bc-client-lib@npm:^0.1.14": + version: 0.1.14 + resolution: "@mojaloop/logging-bc-client-lib@npm:0.1.14" dependencies: "@mojaloop/logging-bc-public-types-lib": ~0.1.0 "@mojaloop/platform-shared-lib-nodejs-kafka-client-lib": ^0.0.8 winston: ^3.3.3 - checksum: 4b3d3f4af1adeb453e118dd88c72fb8fbe5d46683a717fa52ad3dc392172a0cf40ca0d616e147fd465e003f8b11c50e1f3fbcb30b17079423a35c2b89c8e477b + checksum: 471075ce4fd3f0bd711eb4412bfd098adb2b8f2c94d41a1d43e39cca2785272a76e94793607448b1507b03a50696bbb059ff4822f478d18b2718613cf522a4d4 languageName: node linkType: hard @@ -2510,10 +2510,10 @@ __metadata: languageName: node linkType: hard -"@mojaloop/logging-bc-public-types-lib@npm:^0.1.10": - version: 0.1.10 - resolution: "@mojaloop/logging-bc-public-types-lib@npm:0.1.10" - checksum: 8cc0dc62a278c39861d59d6a2c1e4275495b2b19c3ec2e87a5f37a26b466ed3542a10577ef678fd0d628c851f21daa2330404b1c2aa36eab1aaaccdfe5d503f6 +"@mojaloop/logging-bc-public-types-lib@npm:^0.1.11": + version: 0.1.11 + resolution: "@mojaloop/logging-bc-public-types-lib@npm:0.1.11" + checksum: ab0bc7189c752ad14f748b08e30944a9ea48e2845613406ff4179460629aa55a74382f2e5aa06eecb0330c6f4c976620d937ef7e7cf4829457b7bd01c3cbb14b languageName: node linkType: hard @@ -2598,7 +2598,7 @@ __metadata: lodash: ^4.17.21 module-alias: ^2.2.2 nock: ^13.2.9 - npm-check-updates: ^16.1.3 + npm-check-updates: ^16.2.1 oauth2-server: ^4.0.0-dev.2 openapi-jsonschema-parameters: ^12.0.2 openapi-response-validator: ^12.0.2 @@ -2622,8 +2622,8 @@ __metadata: resolution: "@mojaloop/sdk-scheme-adapter-outbound-command-event-handler@workspace:modules/outbound-command-event-handler" dependencies: "@mojaloop/api-snippets": ^15.0.1 - "@mojaloop/logging-bc-client-lib": ^0.1.13 - "@mojaloop/logging-bc-public-types-lib": ^0.1.10 + "@mojaloop/logging-bc-client-lib": ^0.1.14 + "@mojaloop/logging-bc-public-types-lib": ^0.1.11 "@mojaloop/sdk-scheme-adapter-private-shared-lib": "workspace:^" "@types/convict": ^6.1.1 "@types/express": ^4.17.14 @@ -2633,8 +2633,8 @@ __metadata: "@types/supertest": ^2.0.12 "@types/swagger-ui-express": ^4.1.3 "@types/yamljs": ^0.2.31 - "@typescript-eslint/eslint-plugin": ^5.37.0 - "@typescript-eslint/parser": ^5.37.0 + "@typescript-eslint/eslint-plugin": ^5.38.0 + "@typescript-eslint/parser": ^5.38.0 ajv: ^8.11.0 convict: ^6.2.3 copyfiles: ^2.4.1 @@ -2642,7 +2642,7 @@ __metadata: express: ^4.18.1 jest: ^29.0.3 nodemon: ^2.0.20 - npm-check-updates: ^16.1.3 + npm-check-updates: ^16.2.1 openapi-backend: ^5.5.0 redis: ^4.3.1 replace: ^1.2.1 @@ -2659,20 +2659,20 @@ __metadata: version: 0.0.0-use.local resolution: "@mojaloop/sdk-scheme-adapter-outbound-domain-event-handler@workspace:modules/outbound-domain-event-handler" dependencies: - "@mojaloop/logging-bc-client-lib": ^0.1.13 - "@mojaloop/logging-bc-public-types-lib": ^0.1.10 + "@mojaloop/logging-bc-client-lib": ^0.1.14 + "@mojaloop/logging-bc-public-types-lib": ^0.1.11 "@mojaloop/sdk-scheme-adapter-private-shared-lib": "workspace:^" "@types/convict": ^6.1.1 "@types/jest": ^29.0.3 "@types/node": ^18.7.18 "@types/node-cache": ^4.2.5 - "@typescript-eslint/eslint-plugin": ^5.37.0 - "@typescript-eslint/parser": ^5.37.0 + "@typescript-eslint/eslint-plugin": ^5.38.0 + "@typescript-eslint/parser": ^5.38.0 convict: ^6.2.3 eslint: ^8.23.1 jest: ^29.0.3 nodemon: ^2.0.20 - npm-check-updates: ^16.1.3 + npm-check-updates: ^16.2.1 replace: ^1.2.1 standard-version: ^9.5.0 ts-jest: ^29.0.1 @@ -2686,14 +2686,14 @@ __metadata: resolution: "@mojaloop/sdk-scheme-adapter-private-shared-lib@workspace:modules/private-shared-lib" dependencies: "@mojaloop/api-snippets": ^15.0.1 - "@mojaloop/logging-bc-public-types-lib": ^0.1.10 + "@mojaloop/logging-bc-public-types-lib": ^0.1.11 "@mojaloop/platform-shared-lib-messaging-types-lib": ^0.0.3 "@mojaloop/platform-shared-lib-nodejs-kafka-client-lib": ^0.0.9 "@types/node": ^18.7.18 ajv: ^8.11.0 eslint: ^8.23.1 jest: ^29.0.3 - npm-check-updates: ^16.1.3 + npm-check-updates: ^16.2.1 redis: ^4.3.1 replace: ^1.2.1 standard-version: ^9.5.0 @@ -2710,8 +2710,8 @@ __metadata: "@types/jest": ^29.0.3 "@types/node": ^18.7.18 "@types/node-cache": ^4.2.5 - "@typescript-eslint/eslint-plugin": ^5.37.0 - "@typescript-eslint/parser": ^5.37.0 + "@typescript-eslint/eslint-plugin": ^5.38.0 + "@typescript-eslint/parser": ^5.38.0 audit-ci: ^6.3.0 eslint: ^8.23.1 eslint-config-airbnb-typescript: ^17.0.0 @@ -2719,8 +2719,8 @@ __metadata: husky: ^8.0.1 jest: ^29.0.3 nodemon: ^2.0.20 - npm-check-updates: ^16.1.3 - nx: 14.7.5 + npm-check-updates: ^16.2.1 + nx: 14.7.6 replace: ^1.2.1 standard-version: ^9.5.0 ts-jest: ^29.0.1 @@ -2849,23 +2849,23 @@ __metadata: languageName: node linkType: hard -"@nrwl/cli@npm:14.7.5": - version: 14.7.5 - resolution: "@nrwl/cli@npm:14.7.5" +"@nrwl/cli@npm:14.7.6": + version: 14.7.6 + resolution: "@nrwl/cli@npm:14.7.6" dependencies: - nx: 14.7.5 - checksum: 547e1e19d116fa1e3e46ec42912c8f5b176138228fa9bacd17e7d5fd354a75e733a935bf6b6bd4dc942a7396fb86e5e314adf32b7efaed8da4f2bfe8f55164d4 + nx: 14.7.6 + checksum: fd51a4e57c7bce0c803163aed4cbdcb24ce67bc7c4c118e39b8c86bba8f4f9bfad9e1425a3bd90a7221337871946e7e0e285973845ace764711e371d37a0e8dd languageName: node linkType: hard -"@nrwl/tao@npm:14.7.5": - version: 14.7.5 - resolution: "@nrwl/tao@npm:14.7.5" +"@nrwl/tao@npm:14.7.6": + version: 14.7.6 + resolution: "@nrwl/tao@npm:14.7.6" dependencies: - nx: 14.7.5 + nx: 14.7.6 bin: tao: index.js - checksum: 1d72241e7631a922cf84f39805f73bacb9dd60fa8c3698a587603bda02e178f7bae2b1a1839ab57a04d7bbe64c29d61e896dac016da906b66fefd53f02a8016c + checksum: a94ad95829f5803c86aa2d6339ca6fb9fe39b98e180e65d55b184a36776cef5bc11e392f34810ba8df276ae2eec9194172960630c0cc2a8224ced014cd3f5cf8 languageName: node linkType: hard @@ -3619,15 +3619,14 @@ __metadata: languageName: node linkType: hard -"@typescript-eslint/eslint-plugin@npm:^5.37.0": - version: 5.37.0 - resolution: "@typescript-eslint/eslint-plugin@npm:5.37.0" +"@typescript-eslint/eslint-plugin@npm:^5.38.0": + version: 5.38.0 + resolution: "@typescript-eslint/eslint-plugin@npm:5.38.0" dependencies: - "@typescript-eslint/scope-manager": 5.37.0 - "@typescript-eslint/type-utils": 5.37.0 - "@typescript-eslint/utils": 5.37.0 + "@typescript-eslint/scope-manager": 5.38.0 + "@typescript-eslint/type-utils": 5.38.0 + "@typescript-eslint/utils": 5.38.0 debug: ^4.3.4 - functional-red-black-tree: ^1.0.1 ignore: ^5.2.0 regexpp: ^3.2.0 semver: ^7.3.7 @@ -3638,24 +3637,24 @@ __metadata: peerDependenciesMeta: typescript: optional: true - checksum: 9ef75628fcd6f5425002d0172514ad27e51c6ca438aba65ad445be3c63187de3cb294bcc994bd2859dff4fc0221a22da497b34990e8165dcfd1fec33d7d17fb3 + checksum: e9cd1970c7c8a438aee912cf00aa27bdcde0a0fb57bbfe70eccda93eefa5b4fb4c7ebf5ba7a51744c1ec2b4df3a72b8dcd19dc17a9c3e4e3435f631ac6b10a6a languageName: node linkType: hard -"@typescript-eslint/parser@npm:^5.37.0": - version: 5.37.0 - resolution: "@typescript-eslint/parser@npm:5.37.0" +"@typescript-eslint/parser@npm:^5.38.0": + version: 5.38.0 + resolution: "@typescript-eslint/parser@npm:5.38.0" dependencies: - "@typescript-eslint/scope-manager": 5.37.0 - "@typescript-eslint/types": 5.37.0 - "@typescript-eslint/typescript-estree": 5.37.0 + "@typescript-eslint/scope-manager": 5.38.0 + "@typescript-eslint/types": 5.38.0 + "@typescript-eslint/typescript-estree": 5.38.0 debug: ^4.3.4 peerDependencies: eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 peerDependenciesMeta: typescript: optional: true - checksum: 33343e27c9602820d43ee12de9797365d97a5cf3f716e750fa44de760f2a2c6800f3bc4fa54931ac70c0e0ede77a92224f8151da7f30fed3bf692a029d6659af + checksum: d5fb2d8f3a25cd6ff31326c665db4617f2d428247cad690f0404de440abbcfc7261528f54d642d2b121aae34aadecb55a24b72c8ef341cafdc7b2bbcbf7dae8d languageName: node linkType: hard @@ -3669,22 +3668,22 @@ __metadata: languageName: node linkType: hard -"@typescript-eslint/scope-manager@npm:5.37.0": - version: 5.37.0 - resolution: "@typescript-eslint/scope-manager@npm:5.37.0" +"@typescript-eslint/scope-manager@npm:5.38.0": + version: 5.38.0 + resolution: "@typescript-eslint/scope-manager@npm:5.38.0" dependencies: - "@typescript-eslint/types": 5.37.0 - "@typescript-eslint/visitor-keys": 5.37.0 - checksum: 1c439e21ffa63ebaadb8c8363e9d668132a835a28203e5b779366bfa56772f332e5dedb50d63dffb836839b9d9c4e66aa9e3ea47b8c59465b18a0cbd063ec7a3 + "@typescript-eslint/types": 5.38.0 + "@typescript-eslint/visitor-keys": 5.38.0 + checksum: a34d2976e9c755b853b6524e0b9fb1da237340ddff9f6839a51ba37998527c02d0f2f16ffc3d4baa47898f2bb7eb85a6749d6ca588c0461dbd654d8f9925dd0f languageName: node linkType: hard -"@typescript-eslint/type-utils@npm:5.37.0": - version: 5.37.0 - resolution: "@typescript-eslint/type-utils@npm:5.37.0" +"@typescript-eslint/type-utils@npm:5.38.0": + version: 5.38.0 + resolution: "@typescript-eslint/type-utils@npm:5.38.0" dependencies: - "@typescript-eslint/typescript-estree": 5.37.0 - "@typescript-eslint/utils": 5.37.0 + "@typescript-eslint/typescript-estree": 5.38.0 + "@typescript-eslint/utils": 5.38.0 debug: ^4.3.4 tsutils: ^3.21.0 peerDependencies: @@ -3692,7 +3691,7 @@ __metadata: peerDependenciesMeta: typescript: optional: true - checksum: 79dac78eefdbdb3c168da6b303381461af3523e2b45fdeb821eb05e6a5cac797a8850e1dd9e1b6cd1a7c22408acfa2a09854a0f85ff038518c312db8eae9aa4f + checksum: 43f2f55329b2357bedf158a93a469d058a11c69f8f88ff891080b8cb5977bffe8d679923bce7048cbc076c083e0f5741c83b761355309d606cc4e217e1da4208 languageName: node linkType: hard @@ -3703,10 +3702,10 @@ __metadata: languageName: node linkType: hard -"@typescript-eslint/types@npm:5.37.0": - version: 5.37.0 - resolution: "@typescript-eslint/types@npm:5.37.0" - checksum: 899e59e7775fa95c2d9fcac5cc02cc49d83af5f1ffc706df495046c3b3733f79d5489568b01bfaf8c9ae4636e057056866adc783113036f774580086d0189f21 +"@typescript-eslint/types@npm:5.38.0": + version: 5.38.0 + resolution: "@typescript-eslint/types@npm:5.38.0" + checksum: 03aec1de64417e60830c6d33bb4f1bf4402411080371013513f55c7a2fadb6f8745a89a7604cde03d89aa53307f94bc913060c5897ed93285247e4c39af43a00 languageName: node linkType: hard @@ -3728,12 +3727,12 @@ __metadata: languageName: node linkType: hard -"@typescript-eslint/typescript-estree@npm:5.37.0": - version: 5.37.0 - resolution: "@typescript-eslint/typescript-estree@npm:5.37.0" +"@typescript-eslint/typescript-estree@npm:5.38.0": + version: 5.38.0 + resolution: "@typescript-eslint/typescript-estree@npm:5.38.0" dependencies: - "@typescript-eslint/types": 5.37.0 - "@typescript-eslint/visitor-keys": 5.37.0 + "@typescript-eslint/types": 5.38.0 + "@typescript-eslint/visitor-keys": 5.38.0 debug: ^4.3.4 globby: ^11.1.0 is-glob: ^4.0.3 @@ -3742,23 +3741,23 @@ __metadata: peerDependenciesMeta: typescript: optional: true - checksum: 80365a50fa11ed39bf54d9ef06e264fbbf3bdbcc55b7d7d555ef0be915edae40ec30e98d08b3f6ef048e1874450cbcb1e7d9f429d4f420dacbbde45d3376a7bc + checksum: 174461c91e49a0340945da2d31e38ec175cd90b2b5068f3c925518cc9182100fe1435d3225908a52f62257e97bc2b995cbc6b6bd1b7143ff0a0e4b483bd70834 languageName: node linkType: hard -"@typescript-eslint/utils@npm:5.37.0": - version: 5.37.0 - resolution: "@typescript-eslint/utils@npm:5.37.0" +"@typescript-eslint/utils@npm:5.38.0": + version: 5.38.0 + resolution: "@typescript-eslint/utils@npm:5.38.0" dependencies: "@types/json-schema": ^7.0.9 - "@typescript-eslint/scope-manager": 5.37.0 - "@typescript-eslint/types": 5.37.0 - "@typescript-eslint/typescript-estree": 5.37.0 + "@typescript-eslint/scope-manager": 5.38.0 + "@typescript-eslint/types": 5.38.0 + "@typescript-eslint/typescript-estree": 5.38.0 eslint-scope: ^5.1.1 eslint-utils: ^3.0.0 peerDependencies: eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 - checksum: dc6c19ab07b50113f6fa3722518b2f31ce04036ec018855587d4c467108cb4e3c2866e54ed2e18ce61d1e7d0eaab24f94ee39574031b7d8e1c05e4b83ff84ef2 + checksum: c927a68d4ff5029ed3dbc7e6e87702f7cdfba26452ccf401b37cc68f6e5cca72eb884831dbc7957512998d59950b1852b2ecea19f174a20fe659d851b4afd4fd languageName: node linkType: hard @@ -3788,13 +3787,13 @@ __metadata: languageName: node linkType: hard -"@typescript-eslint/visitor-keys@npm:5.37.0": - version: 5.37.0 - resolution: "@typescript-eslint/visitor-keys@npm:5.37.0" +"@typescript-eslint/visitor-keys@npm:5.38.0": + version: 5.38.0 + resolution: "@typescript-eslint/visitor-keys@npm:5.38.0" dependencies: - "@typescript-eslint/types": 5.37.0 + "@typescript-eslint/types": 5.38.0 eslint-visitor-keys: ^3.3.0 - checksum: d6193550f77413aead0cb267e058df80b80a488c8fb4e39beb5f0a70b971c41682a6391903fbc5f3dd859a872016288c434d631b8efc3ac5a04edbdb7b63b5f6 + checksum: cc3d0c6eb0c9a20a25d66b640d759cb1b52f8df485f16d948218d63d798b5c0672ef298f5dae5e5327ec021c0f8369d1da5d26b9c16a245a20fa44a9365956bc languageName: node linkType: hard @@ -7295,13 +7294,6 @@ __metadata: languageName: node linkType: hard -"functional-red-black-tree@npm:^1.0.1": - version: 1.0.1 - resolution: "functional-red-black-tree@npm:1.0.1" - checksum: ca6c170f37640e2d94297da8bb4bf27a1d12bea3e00e6a3e007fd7aa32e37e000f5772acf941b4e4f3cf1c95c3752033d0c509af157ad8f526e7f00723b9eb9f - languageName: node - linkType: hard - "functions-have-names@npm:^1.2.2": version: 1.2.3 resolution: "functions-have-names@npm:1.2.3" @@ -10715,9 +10707,9 @@ __metadata: languageName: node linkType: hard -"npm-check-updates@npm:^16.1.3": - version: 16.1.3 - resolution: "npm-check-updates@npm:16.1.3" +"npm-check-updates@npm:^16.2.1": + version: 16.2.1 + resolution: "npm-check-updates@npm:16.2.1" dependencies: chalk: ^5.0.1 cli-table: ^0.3.11 @@ -10750,7 +10742,7 @@ __metadata: bin: ncu: build/src/bin/cli.js npm-check-updates: build/src/bin/cli.js - checksum: 7c751332ea840e9037186506d99efee940c2cb52637d5528abcbca1d95899d02d718e388fc5ce8b71c797c6803e27d370712ba34a9911c48a26a6aa93d894c59 + checksum: eca63cd1956f6eae19061c1db1ed314d1515af83eea93b4a21a23327298298e622092f0027b56cce515132c62077dbaff11275ec450d4fd1fdeb92f7575a813a languageName: node linkType: hard @@ -10881,12 +10873,12 @@ __metadata: languageName: node linkType: hard -"nx@npm:14.7.5": - version: 14.7.5 - resolution: "nx@npm:14.7.5" +"nx@npm:14.7.6": + version: 14.7.6 + resolution: "nx@npm:14.7.6" dependencies: - "@nrwl/cli": 14.7.5 - "@nrwl/tao": 14.7.5 + "@nrwl/cli": 14.7.6 + "@nrwl/tao": 14.7.6 "@parcel/watcher": 2.0.4 chalk: 4.1.0 chokidar: ^3.5.1 @@ -10925,7 +10917,7 @@ __metadata: optional: true bin: nx: bin/nx.js - checksum: a65d0fb4f36035802a1710262aced67664322bfe00e181c1424af2356d600d1bd793e251853c28b0e7fc541a3d65dcfe5794521f32595df02c1be85a782cc472 + checksum: 245a8a25b0185c1e0470c15915e8065dbe6ee2938028b5fbb6e2d67c987dc2c3f36fdf43d25ac26c951e403387f56ae4a35169a15d5e3da58c97eb36d3d3bdc9 languageName: node linkType: hard From 5a87f698cbd77a0a34fd526fb1156c5fd5eb53a5 Mon Sep 17 00:00:00 2001 From: Kevin Date: Mon, 19 Sep 2022 23:10:00 -0500 Subject: [PATCH 2/4] add BulkTransfersCallbackReceived domain handler --- .../handlers/bulk-transfers-requested.js | 2 +- .../bulk_transfers_callback_received.ts | 25 +++- .../src/application/handlers/index.ts | 1 + .../bulk-transfers-callback-received.test.ts | 107 ++++++++++++++++++ .../events/outbound_command_event/index.ts | 1 + .../process_bulk_transfers_callback.ts | 24 +++- 6 files changed, 156 insertions(+), 4 deletions(-) create mode 100644 modules/outbound-domain-event-handler/test/unit/application/handlers/bulk-transfers-callback-received.test.ts diff --git a/modules/api-svc/src/FSPIOPEventHandler/handlers/bulk-transfers-requested.js b/modules/api-svc/src/FSPIOPEventHandler/handlers/bulk-transfers-requested.js index d85e6cddf..22ab46300 100644 --- a/modules/api-svc/src/FSPIOPEventHandler/handlers/bulk-transfers-requested.js +++ b/modules/api-svc/src/FSPIOPEventHandler/handlers/bulk-transfers-requested.js @@ -34,7 +34,7 @@ module.exports.handleBulkTransfersRequestedDmEvt = async ( const event = BulkTransfersRequestedDmEvt.CreateFromDomainEvent(message); try { - // use the bulk quotes model to execute asynchronous request with the switch + // use the bulk transfers model to execute asynchronous request with the switch const model = new OutboundBulkTransfersModel({ ...options.config, cache: options.cache, diff --git a/modules/outbound-domain-event-handler/src/application/handlers/bulk_transfers_callback_received.ts b/modules/outbound-domain-event-handler/src/application/handlers/bulk_transfers_callback_received.ts index b80ab683e..28e3ba726 100644 --- a/modules/outbound-domain-event-handler/src/application/handlers/bulk_transfers_callback_received.ts +++ b/modules/outbound-domain-event-handler/src/application/handlers/bulk_transfers_callback_received.ts @@ -1,6 +1,9 @@ import { ILogger } from '@mojaloop/logging-bc-public-types-lib'; import { DomainEvent, + BulkTransfersCallbackReceivedDmEvt, + ProcessBulkTransfersCallbackCmdEvt, + IProcessBulkTransfersCallbackCmdEvtData, } from '@mojaloop/sdk-scheme-adapter-private-shared-lib'; import { IDomainEventHandlerOptions } from '../../types'; @@ -9,8 +12,28 @@ export async function handleBulkTransfersCallbackReceived( options: IDomainEventHandlerOptions, logger: ILogger, ): Promise { + const bulkTransfersCallbackReceivedMessage + = BulkTransfersCallbackReceivedDmEvt.CreateFromDomainEvent(message); try { + const processPartyInfoCallbackMessageData: IProcessBulkTransfersCallbackCmdEvtData = { + bulkId: bulkTransfersCallbackReceivedMessage.getKey(), + content: { + batchId: bulkTransfersCallbackReceivedMessage.batchId, + bulkTransferId: bulkTransfersCallbackReceivedMessage.bulkTransferId, + bulkTransfersResult: bulkTransfersCallbackReceivedMessage.bulkTransfersResult, + }, + timestamp: Date.now(), + headers: bulkTransfersCallbackReceivedMessage.getHeaders(), + }; + + const processBulkTransfersCallbackMessage + = new ProcessBulkTransfersCallbackCmdEvt(processPartyInfoCallbackMessageData); + + await options.commandProducer.sendCommandEvent(processBulkTransfersCallbackMessage); + + logger.info(`Sent command event ${processBulkTransfersCallbackMessage.getName()}`); + console.log(processBulkTransfersCallbackMessage); } catch (err) { - logger.info(`Failed to send command event . ${(err as Error).message}`); + logger.info(`Failed to send command event ProcessBulkTransfersCallbackCmdEvt. ${(err as Error).message}`); } } diff --git a/modules/outbound-domain-event-handler/src/application/handlers/index.ts b/modules/outbound-domain-event-handler/src/application/handlers/index.ts index 8d0c644cf..dc6b6f6b3 100644 --- a/modules/outbound-domain-event-handler/src/application/handlers/index.ts +++ b/modules/outbound-domain-event-handler/src/application/handlers/index.ts @@ -30,3 +30,4 @@ export * from './sdk_outbound_bulk_accept_party_info_processed'; export * from './bulk-quotes-callback-received'; export * from './party-info-callback-processed'; export * from './sdk_outbound_bulk_accept_quote_processed'; +export * from './bulk_transfers_callback_received'; diff --git a/modules/outbound-domain-event-handler/test/unit/application/handlers/bulk-transfers-callback-received.test.ts b/modules/outbound-domain-event-handler/test/unit/application/handlers/bulk-transfers-callback-received.test.ts new file mode 100644 index 000000000..5e9800122 --- /dev/null +++ b/modules/outbound-domain-event-handler/test/unit/application/handlers/bulk-transfers-callback-received.test.ts @@ -0,0 +1,107 @@ +/***** + License + -------------- + Copyright © 2017 Bill & Melinda Gates Foundation + The Mojaloop files are made available by the Bill & Melinda Gates Foundation under the Apache License, Version 2.0 (the "License") and you may not use these files except in compliance with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, the Mojaloop files are distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. + + Contributors + -------------- + This is the official list (alphabetical ordering) of the Mojaloop project contributors for this file. + Names of the original copyright holders (individuals or organizations) + should be listed with a '*' in the first column. People who have + contributed from an organization can be listed under the organization + that actually holds the copyright for their contributions (see the + Gates Foundation organization for an example). Those individuals should have + their names indented and be marked with a '-'. Email address can be added + optionally within square brackets . + + * Gates Foundation + - Name Surname + + * Modusbox + - Kevin Leyow + + -------------- + ******/ + + 'use strict' + + import { DefaultLogger } from "@mojaloop/logging-bc-client-lib"; + import { ILogger } from "@mojaloop/logging-bc-public-types-lib"; + import { + DomainEvent, + EventType, + IDomainEventData, + BulkTransfersCallbackReceivedDmEvt, + ProcessBulkTransfersCallbackCmdEvt, + } from "@mojaloop/sdk-scheme-adapter-private-shared-lib" + import { randomUUID } from "crypto"; + import { handleBulkTransfersCallbackReceived } from "../../../../src/application/handlers" + import { IDomainEventHandlerOptions } from "../../../../src/types"; + + +describe('handleBulkTransfersCallbackReceived', () => { + const logger: ILogger = new DefaultLogger('bc', 'appName', 'appVersion'); + const domainEventHandlerOptions = { + commandProducer: { + init: jest.fn(), + sendCommandEvent: jest.fn() + } + } as unknown as IDomainEventHandlerOptions + + let sampleBulkTransfersCallbackReceivedMessageData: IDomainEventData; + let key: string; + + beforeEach(async () => { + key = `${randomUUID()}_${randomUUID()}` + sampleBulkTransfersCallbackReceivedMessageData = { + key, + name: BulkTransfersCallbackReceivedDmEvt.name, + content: { + batchId: '61c35bae-77d0-4f7d-b894-be375b838ff6', + bulkTransferId: '81c35bae-77d0-4f7d-b894-be375b838ff6', + bulkTransfersResult: { + bulkTransferId: '81c35bae-77d0-4f7d-b894-be375b838ff6', + currentState: 'COMPLETED', + individualTransferResults: [ + { + transferId: 'individual-transfer-id', + to: { + partyIdInfo: { + partyIdType: 'MSISDN', + partyIdentifier: '1' + }, + }, + amountType: 'SEND', + currency: 'USD', + amount: '1' + }, + ] + } + }, + timestamp: Date.now(), + headers: [], + } + }); + + + test('emits a ProcessBulkTransfersCallback message', async () => { + const sampleDomainEventDataObj = new DomainEvent(sampleBulkTransfersCallbackReceivedMessageData); + handleBulkTransfersCallbackReceived(sampleDomainEventDataObj, domainEventHandlerOptions, logger) + expect(domainEventHandlerOptions.commandProducer.sendCommandEvent) + .toBeCalledWith( + expect.objectContaining({ + _data: expect.objectContaining({ + key, + name: ProcessBulkTransfersCallbackCmdEvt.name, + type: EventType.COMMAND_EVENT, + content: sampleBulkTransfersCallbackReceivedMessageData.content + }) + }) + ) + }) +}) diff --git a/modules/private-shared-lib/src/events/outbound_command_event/index.ts b/modules/private-shared-lib/src/events/outbound_command_event/index.ts index 5bcbdc7f1..a2ef2cf44 100644 --- a/modules/private-shared-lib/src/events/outbound_command_event/index.ts +++ b/modules/private-shared-lib/src/events/outbound_command_event/index.ts @@ -31,3 +31,4 @@ export * from './process_sdk_outbound_bulk_quotes_request'; export * from './process_sdk_outbound_bulk_accept_quote'; export * from './process_bulk_quotes_callback'; export * from './process_sdk_outbound_bulk_transfers_request'; +export * from './process_bulk_transfers_callback'; diff --git a/modules/private-shared-lib/src/events/outbound_command_event/process_bulk_transfers_callback.ts b/modules/private-shared-lib/src/events/outbound_command_event/process_bulk_transfers_callback.ts index 83c359058..49ee1a881 100644 --- a/modules/private-shared-lib/src/events/outbound_command_event/process_bulk_transfers_callback.ts +++ b/modules/private-shared-lib/src/events/outbound_command_event/process_bulk_transfers_callback.ts @@ -2,10 +2,15 @@ import { CommandEvent } from '../command_event'; import { IMessageHeader } from '@mojaloop/platform-shared-lib-messaging-types-lib'; +import { SDKSchemeAdapter } from '@mojaloop/api-snippets'; export interface IProcessBulkTransfersCallbackCmdEvtData { bulkId: string; - content: null; + content: { + batchId: string; + bulkTransferId: string; + bulkTransfersResult: SDKSchemeAdapter.Outbound.V2_0_0.Types.bulkTransferResponse + }, timestamp: number | null; headers: IMessageHeader[] | null; } @@ -15,7 +20,7 @@ export class ProcessBulkTransfersCallbackCmdEvt extends CommandEvent { key: data.bulkId, timestamp: data.timestamp, headers: data.headers, - content: null, + content: data.content, name: ProcessBulkTransfersCallbackCmdEvt.name, }); } @@ -32,4 +37,19 @@ export class ProcessBulkTransfersCallbackCmdEvt extends CommandEvent { }; return new ProcessBulkTransfersCallbackCmdEvt(data); } + + get batchId(): string { + const content = this.getContent() as IProcessBulkTransfersCallbackCmdEvtData['content']; + return content.batchId; + } + + get bulkTransferId(): string { + const content = this.getContent() as IProcessBulkTransfersCallbackCmdEvtData['content']; + return content.bulkTransferId; + } + + get bulkTransfersResult(): SDKSchemeAdapter.Outbound.V2_0_0.Types.bulkTransferResponse { + const content = this.getContent() as IProcessBulkTransfersCallbackCmdEvtData['content']; + return content.bulkTransfersResult; + } } From 3f88dae97cad2b568748013e1a7673bfd5c4dc3e Mon Sep 17 00:00:00 2001 From: Kevin Date: Tue, 20 Sep 2022 09:45:11 -0500 Subject: [PATCH 3/4] chore: key --- .../handlers/bulk-transfers-callback-received.test.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/modules/outbound-domain-event-handler/test/unit/application/handlers/bulk-transfers-callback-received.test.ts b/modules/outbound-domain-event-handler/test/unit/application/handlers/bulk-transfers-callback-received.test.ts index 5e9800122..223469c87 100644 --- a/modules/outbound-domain-event-handler/test/unit/application/handlers/bulk-transfers-callback-received.test.ts +++ b/modules/outbound-domain-event-handler/test/unit/application/handlers/bulk-transfers-callback-received.test.ts @@ -57,9 +57,8 @@ describe('handleBulkTransfersCallbackReceived', () => { let key: string; beforeEach(async () => { - key = `${randomUUID()}_${randomUUID()}` sampleBulkTransfersCallbackReceivedMessageData = { - key, + key: randomUUID(), name: BulkTransfersCallbackReceivedDmEvt.name, content: { batchId: '61c35bae-77d0-4f7d-b894-be375b838ff6', From 95a36099b3a584b89eb9f94e0d83dd73b1354ae2 Mon Sep 17 00:00:00 2001 From: Kevin Leyow Date: Tue, 20 Sep 2022 10:00:41 -0500 Subject: [PATCH 4/4] Update modules/outbound-domain-event-handler/src/application/handlers/bulk_transfers_callback_received.ts Co-authored-by: Miguel de Barros --- .../application/handlers/bulk_transfers_callback_received.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/outbound-domain-event-handler/src/application/handlers/bulk_transfers_callback_received.ts b/modules/outbound-domain-event-handler/src/application/handlers/bulk_transfers_callback_received.ts index 28e3ba726..992db3cd2 100644 --- a/modules/outbound-domain-event-handler/src/application/handlers/bulk_transfers_callback_received.ts +++ b/modules/outbound-domain-event-handler/src/application/handlers/bulk_transfers_callback_received.ts @@ -34,6 +34,6 @@ export async function handleBulkTransfersCallbackReceived( logger.info(`Sent command event ${processBulkTransfersCallbackMessage.getName()}`); console.log(processBulkTransfersCallbackMessage); } catch (err) { - logger.info(`Failed to send command event ProcessBulkTransfersCallbackCmdEvt. ${(err as Error).message}`); + logger.info(`Failed to send command event ${ProcessBulkTransfersCallbackCmdEvt.name}. ${(err as Error).message}`); } }