Skip to content

Commit

Permalink
Mbp 286 - If backed returns fulfilment, transferState or completedTim…
Browse files Browse the repository at this point in the history
…estamp assign to POST /transfers response (#38)

* mbp-286: If backed returns fulfilment, transferState or completedTimestamp assign to POST /transfers response

* mbp-286: bump package version

* mbp-286 Update dfspInboundApi.yaml in docs

* Update InboundTransfersModel.js

* Update InboundTransfersModel.js

* Update dfspInboundApi.yaml

* Update src/lib/model/InboundTransfersModel.js

Co-authored-by: Yevhen Kyriukha <[email protected]>

* Update src/lib/model/InboundTransfersModel.js

Co-authored-by: Yevhen Kyriukha <[email protected]>

* Update src/lib/model/InboundTransfersModel.js

Co-authored-by: Yevhen Kyriukha <[email protected]>

Co-authored-by: Yevhen Kyriukha <[email protected]>
  • Loading branch information
gibaros and kirgene authored May 17, 2022
1 parent 4c61343 commit da5384d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
11 changes: 11 additions & 0 deletions docs/dfspInboundApi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,17 @@ components:
homeTransactionId:
type: string
description: Transaction ID from the DFSP backend, used to reconcile transactions between the Switch and DFSP backend systems.
fulfilment:
$ref: '#/components/schemas/IlpFulfilment'
description: Fulfilment from the DFSP backend, used for testing purposes to inject an invalid fulfilment via a rule.
transferState:
$ref: '#/components/schemas/transferState'
description: Transfer state from the DFSP backend, used for testing purposes to inject an desired transfer state via a rule.
example: ABORTED
completedTimestamp:
$ref: '#/components/schemas/timestamp'
description: Completed timestamp from the DFSP backend, used for testing purposes to inject a given completed timestamp via a rule.
example: "2020-05-19T08:38:08.699-04:00"

transferDetailsResponse:
type: object
Expand Down
8 changes: 4 additions & 4 deletions src/lib/model/InboundTransfersModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,9 +349,9 @@ class InboundTransfersModel {

// create a mojaloop transfer fulfil response
const mojaloopResponse = {
completedTimestamp: new Date(),
transferState: this._reserveNotification ? 'RESERVED' : 'COMMITTED',
fulfilment: fulfilment,
completedTimestamp: response.completedTimestamp || new Date(),
transferState: response.transferState || (this._reserveNotification ? TransferStateEnum.RESERVED : TransferStateEnum.COMPLETED),
fulfilment: response.fulfilment || fulfilment,
...response.extensionList && {
extensionList: {
extension: response.extensionList,
Expand All @@ -366,7 +366,7 @@ class InboundTransfersModel {
headers: res.originalRequest.headers,
body: res.originalRequest.body,
};
this.data.currentState = this._reserveNotification ? TransferStateEnum.RESERVED : TransferStateEnum.COMPLETED;
this.data.currentState = response.transferState || (this._reserveNotification ? TransferStateEnum.RESERVED : TransferStateEnum.COMPLETED);
await this._save();
return res;
}
Expand Down
2 changes: 1 addition & 1 deletion src/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@pm4ml/mojaloop-connector",
"version": "14.1.11",
"version": "14.1.12",
"description": "An adapter for connecting to Mojaloop API enabled switches.",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit da5384d

Please sign in to comment.