Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update outbound interface and response oa3 defs #316

Merged
merged 3 commits into from
May 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 51 additions & 29 deletions src/OutboundServer/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2124,8 +2124,15 @@ components:
description: 'GET /parties/{Type}/{ID} response object'
properties:
party:
$ref: '#/components/schemas/Party'
description: Information regarding the requested Party.
properties:
body:
$ref: '#/components/schemas/Party'
description: Information regarding the requested Party.
headers:
type: object
required:
- body
- headers
currentState:
$ref: '#/components/schemas/async2SyncCurrentState'
required:
Expand Down Expand Up @@ -2235,33 +2242,41 @@ components:
type: object
description: 'The object sent in the PUT /quotes/{ID} callback.'
properties:
transferAmount:
$ref: '#/components/schemas/Money'
payeeReceiveAmount:
$ref: '#/components/schemas/Money'
payeeFspFee:
$ref: '#/components/schemas/Money'
payeeFspCommission:
$ref: '#/components/schemas/Money'
expiration:
type: string
description: >-
Date and time until when the quotation is valid and can be
honored when used in the subsequent transaction.
example: '2016-05-24T08:38:08.699-04:00'
geoCode:
$ref: '#/components/schemas/GeoCode'
ilpPacket:
$ref: '#/components/schemas/IlpPacket'
condition:
$ref: '#/components/schemas/IlpCondition'
extensionList:
$ref: '#/components/schemas/ExtensionList'
body:
type: object
properties:
transferAmount:
$ref: '#/components/schemas/Money'
payeeReceiveAmount:
$ref: '#/components/schemas/Money'
payeeFspFee:
$ref: '#/components/schemas/Money'
payeeFspCommission:
$ref: '#/components/schemas/Money'
expiration:
type: string
description: >-
Date and time until when the quotation is valid and can be
honored when used in the subsequent transaction.
example: '2016-05-24T08:38:08.699-04:00'
geoCode:
$ref: '#/components/schemas/GeoCode'
ilpPacket:
$ref: '#/components/schemas/IlpPacket'
condition:
$ref: '#/components/schemas/IlpCondition'
extensionList:
$ref: '#/components/schemas/ExtensionList'
required:
- transferAmount
- expiration
- ilpPacket
- condition
headers:
type: object
required:
- transferAmount
- expiration
- ilpPacket
- condition
- body
- headers
currentState:
$ref: '#/components/schemas/async2SyncCurrentState'
required:
Expand Down Expand Up @@ -2316,7 +2331,14 @@ components:
type: object
properties:
transfer:
$ref: '#/components/schemas/TransfersIDPutResponse'
properties:
body:
$ref: '#/components/schemas/TransfersIDPutResponse'
headers:
type: object
required:
- body
- headers
currentState:
$ref: '#/components/schemas/async2SyncCurrentState'
required:
Expand Down
35 changes: 22 additions & 13 deletions src/OutboundServer/api_interfaces/openapi.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1070,8 +1070,11 @@ export interface components {
| "ERROR_OCCURRED";
/** GET /parties/{Type}/{ID} response object */
partiesByIdResponse: {
/** Information regarding the requested Party. */
party: components["schemas"]["Party"];
party: {
/** Information regarding the requested Party. */
body: components["schemas"]["Party"];
headers: { [key: string]: unknown };
};
currentState: components["schemas"]["async2SyncCurrentState"];
};
/** The object sent in the POST /quotes request. */
Expand Down Expand Up @@ -1110,16 +1113,19 @@ export interface components {
quotesPostResponse: {
/** The object sent in the PUT /quotes/{ID} callback. */
quotes: {
transferAmount: components["schemas"]["Money"];
payeeReceiveAmount?: components["schemas"]["Money"];
payeeFspFee?: components["schemas"]["Money"];
payeeFspCommission?: components["schemas"]["Money"];
/** Date and time until when the quotation is valid and can be honored when used in the subsequent transaction. */
expiration: string;
geoCode?: components["schemas"]["GeoCode"];
ilpPacket: components["schemas"]["IlpPacket"];
condition: components["schemas"]["IlpCondition"];
extensionList?: components["schemas"]["ExtensionList"];
body: {
transferAmount: components["schemas"]["Money"];
payeeReceiveAmount?: components["schemas"]["Money"];
payeeFspFee?: components["schemas"]["Money"];
payeeFspCommission?: components["schemas"]["Money"];
/** Date and time until when the quotation is valid and can be honored when used in the subsequent transaction. */
expiration: string;
geoCode?: components["schemas"]["GeoCode"];
ilpPacket: components["schemas"]["IlpPacket"];
condition: components["schemas"]["IlpCondition"];
extensionList?: components["schemas"]["ExtensionList"];
};
headers: { [key: string]: unknown };
};
currentState: components["schemas"]["async2SyncCurrentState"];
};
Expand All @@ -1142,7 +1148,10 @@ export interface components {
transfersPostRequest: components["schemas"]["TransfersPostRequest"];
};
simpleTransfersPostResponse: {
transfer: components["schemas"]["TransfersIDPutResponse"];
transfer: {
body: components["schemas"]["TransfersIDPutResponse"];
headers: { [key: string]: unknown };
};
currentState: components["schemas"]["async2SyncCurrentState"];
};
errorSimpleTransfersResponse: components["schemas"]["errorResponse"] & {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,16 @@
description: 'GET /parties/{Type}/{ID} response object'
properties:
party:
$ref: >-
../../../../../node_modules/@mojaloop/api-snippets/thirdparty/v1_0/openapi3/components/schemas/Party.yaml
description: Information regarding the requested Party.
properties:
body:
$ref: >-
../../../../../node_modules/@mojaloop/api-snippets/thirdparty/v1_0/openapi3/components/schemas/Party.yaml
description: Information regarding the requested Party.
headers:
type: object
required:
- body
- headers
currentState:
$ref: ../schemas/async2SyncCurrentState.yaml
required:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,41 +6,49 @@ properties:
type: object
description: 'The object sent in the PUT /quotes/{ID} callback.'
properties:
transferAmount:
$ref: >-
../../../../../node_modules/@mojaloop/api-snippets/fspiop/v1_1/openapi3/components/schemas/Money.yaml
payeeReceiveAmount:
$ref: >-
../../../../../node_modules/@mojaloop/api-snippets/fspiop/v1_1/openapi3/components/schemas/Money.yaml
payeeFspFee:
$ref: >-
../../../../../node_modules/@mojaloop/api-snippets/fspiop/v1_1/openapi3/components/schemas/Money.yaml
payeeFspCommission:
$ref: >-
../../../../../node_modules/@mojaloop/api-snippets/fspiop/v1_1/openapi3/components/schemas/Money.yaml
expiration:
type: string
description: >-
Date and time until when the quotation is valid and can be honored when
used in the subsequent transaction.
example: '2016-05-24T08:38:08.699-04:00'
geoCode:
$ref: >-
../../../../../node_modules/@mojaloop/api-snippets/fspiop/v1_1/openapi3/components/schemas/GeoCode.yaml
ilpPacket:
$ref: >-
../../../../../node_modules/@mojaloop/api-snippets/fspiop/v1_1/openapi3/components/schemas/IlpPacket.yaml
condition:
$ref: >-
../../../../../node_modules/@mojaloop/api-snippets/fspiop/v1_1/openapi3/components/schemas/IlpCondition.yaml
extensionList:
$ref: >-
../../../../../node_modules/@mojaloop/api-snippets/fspiop/v1_1/openapi3/components/schemas/ExtensionList.yaml
body:
type: object
properties:
transferAmount:
$ref: >-
../../../../../node_modules/@mojaloop/api-snippets/fspiop/v1_1/openapi3/components/schemas/Money.yaml
payeeReceiveAmount:
$ref: >-
../../../../../node_modules/@mojaloop/api-snippets/fspiop/v1_1/openapi3/components/schemas/Money.yaml
payeeFspFee:
$ref: >-
../../../../../node_modules/@mojaloop/api-snippets/fspiop/v1_1/openapi3/components/schemas/Money.yaml
payeeFspCommission:
$ref: >-
../../../../../node_modules/@mojaloop/api-snippets/fspiop/v1_1/openapi3/components/schemas/Money.yaml
expiration:
type: string
description: >-
Date and time until when the quotation is valid and can be honored when
used in the subsequent transaction.
example: '2016-05-24T08:38:08.699-04:00'
geoCode:
$ref: >-
../../../../../node_modules/@mojaloop/api-snippets/fspiop/v1_1/openapi3/components/schemas/GeoCode.yaml
ilpPacket:
$ref: >-
../../../../../node_modules/@mojaloop/api-snippets/fspiop/v1_1/openapi3/components/schemas/IlpPacket.yaml
condition:
$ref: >-
../../../../../node_modules/@mojaloop/api-snippets/fspiop/v1_1/openapi3/components/schemas/IlpCondition.yaml
extensionList:
$ref: >-
../../../../../node_modules/@mojaloop/api-snippets/fspiop/v1_1/openapi3/components/schemas/ExtensionList.yaml
required:
- transferAmount
- expiration
- ilpPacket
- condition
headers:
type: object
required:
- transferAmount
- expiration
- ilpPacket
- condition
- body
- headers
currentState:
$ref: ../schemas/async2SyncCurrentState.yaml
required:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,15 @@ title: SimpleTransfersPostResponse
type: object
properties:
transfer:
$ref: >-
../../../../../node_modules/@mojaloop/api-snippets/fspiop/v1_1/openapi3/components/schemas/TransfersIDPutResponse.yaml
properties:
body:
$ref: >-
../../../../../node_modules/@mojaloop/api-snippets/fspiop/v1_1/openapi3/components/schemas/TransfersIDPutResponse.yaml
headers:
type: object
required:
- body
- headers
currentState:
$ref: ../schemas/async2SyncCurrentState.yaml
required:
Expand Down
15 changes: 14 additions & 1 deletion src/lib/model/PartiesModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,25 @@ function argsValidation({ type, id, subId }) {
}
}

/**
* @name reformatMessage
* @description reformats message received from PUB/SUB channel, it is optional method, if not specified identify function is used by default
* @param {object} message - message received
* @returns {object} - reformatted message
*/
function reformatMessage(message) {
return {
party: { ...message }
};
}

// generate model
const PartiesModel = Async2SyncModel.generate({
modelName: 'PartiesModel',
channelNameMethod: channelName,
requestActionMethod: requestAction,
argsValidationMethod: argsValidation
argsValidationMethod: argsValidation,
reformatMessageMethod: reformatMessage
});

module.exports = PartiesModel;
Expand Down
4 changes: 3 additions & 1 deletion test/integration/lib/Outbound/parties.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ describe('/parties', () => {

expect(res.status).toEqual(200);
expect(res.data.currentState).toEqual('COMPLETED');
expect(typeof res.data.body.party).toEqual('object');
expect(typeof res.data.party).toEqual('object');
expect(typeof res.data.party.body).toEqual('object');
expect(typeof res.data.party.headers).toEqual('object');
});

test('get - timeout', (done) => {
Expand Down
2 changes: 2 additions & 0 deletions test/integration/lib/Outbound/quotes.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ describe('/quotes', () => {
expect(res.status).toEqual(200);
expect(res.data.currentState).toEqual('COMPLETED');
expect(typeof res.data.quotes).toEqual('object');
expect(typeof res.data.quotes.body).toEqual('object');
expect(typeof res.data.quotes.headers).toEqual('object');
});

test('post - timeout', (done) => {
Expand Down
2 changes: 2 additions & 0 deletions test/integration/lib/Outbound/simpleTransfers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ describe('/simpleTransfers', () => {
expect(res.status).toEqual(200);
expect(res.data.currentState).toEqual('COMPLETED');
expect(typeof res.data.transfer).toEqual('object');
expect(typeof res.data.transfer.body).toEqual('object');
expect(typeof res.data.transfer.headers).toEqual('object');
});

test('post - timeout', async () => {
Expand Down
2 changes: 1 addition & 1 deletion test/unit/api/transfers/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ function createPostTransfersTester(

const res = await reqOutbound.post('/transfers').send(postTransfersSimpleBody);
const {body} = res;
console.log(body)

expect(res.statusCode).toEqual(responseCode);

// remove elements of the response we do not want/need to compare for correctness.
Expand Down
20 changes: 13 additions & 7 deletions test/unit/lib/model/PartiesModel.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,12 @@ describe('PartiesModel', () => {
model.run = jest.fn(() => Promise.resolve());

const message = {
party: {
Iam: 'the-body'
}
body: {
party: {
Iam: 'the-body'
}
},
headers: {}
};

const onRequestActionPromise = new Promise((resolve, reject) => {
Expand All @@ -175,7 +178,7 @@ describe('PartiesModel', () => {

// check that this.context.data is updated
expect(model.context.data).toEqual({
...message,
party: { ...message },
// current state will be updated by onAfterTransition which isn't called
// when manual invocation of transition handler happens
currentState: 'start'
Expand Down Expand Up @@ -216,9 +219,12 @@ describe('PartiesModel', () => {
model.run = jest.fn(() => Promise.resolve());

const message = {
party: {
Iam: 'the-body'
}
body: {
party: {
Iam: 'the-body'
}
},
headers: {}
};

const onRequestActionPromise = new Promise((resolve, reject) => {
Expand Down
Loading