Skip to content

Commit

Permalink
Implement BulkTransfersByIDPut operation
Browse files Browse the repository at this point in the history
  • Loading branch information
ggrg committed Jun 21, 2019
1 parent 9e2d185 commit 5f79bf1
Show file tree
Hide file tree
Showing 10 changed files with 4,751 additions and 403 deletions.
18 changes: 18 additions & 0 deletions config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,24 @@
"request.required.acks": "all"
}
}
},
"FULFIL": {
"config": {
"options": {
"messageCharset": "utf8"
},
"rdkafkaConf": {
"metadata.broker.list": "localhost:9092",
"client.id": "ml-prod-bulk-fulfil",
"event_cb": true,
"dr_cb": true,
"socket.keepalive.enable": true,
"queue.buffering.max.messages": 10000000
},
"topicConf": {
"request.required.acks": "all"
}
}
}
},
"TRANSFER": {
Expand Down
2,630 changes: 2,238 additions & 392 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"@hapi/joi": "15.0.3",
"@hapi/joi-date": "1.3.0",
"@hapi/vision": "5.5.2",
"@mojaloop/central-object-store": "6.4.0-snapshot",
"@mojaloop/central-object-store": "file:../../../npmpack/mojaloop-central-object-store-6.4.1-snapshot.tgz",
"@mojaloop/central-services-auth": "5.2.1",
"@mojaloop/central-services-database": "5.2.1",
"@mojaloop/central-services-error-handling": "5.2.0",
Expand Down
4 changes: 2 additions & 2 deletions src/bulkApi/handlers/bulkTransfers.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ module.exports = {
const hash = Util.createHash(JSON.stringify(request.payload))
const messageId = Uuid()
let BulkTransferModel = BulkTransferModels.getBulkTransferModel()
const newBulk = new BulkTransferModel(Object.assign({}, { messageId, headers: request.headers }, request.payload))
await newBulk.save()
const doc = Object.assign({}, { messageId, headers: request.headers }, request.payload)
await new BulkTransferModel(doc).save()
const message = { bulkTransferId, bulkQuoteId, payerFsp, payeeFsp, expiration, extensionList, hash }
await TransferService.bulkPrepare(messageId, request.headers, message)
return h.response().code(202)
Expand Down
23 changes: 21 additions & 2 deletions src/bulkApi/handlers/bulkTransfers/{id}.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@
******/
'use strict'

const TransferService = require('../../../domain/transfer')
const Logger = require('@mojaloop/central-services-shared').Logger
const Boom = require('boom')
const BulkTransferModels = require('@mojaloop/central-object-store').Models.BulkTransfer
const Util = require('../../../lib/util')
const Uuid = require('uuid4')

/**
* Operations on /bulkTransfers/{id}
Expand Down Expand Up @@ -61,7 +65,22 @@ module.exports = {
* produces:
* responses: default
*/
put: function BulkTransfersByIDPut (request, h) {
return Boom.notImplemented()
put: async function BulkTransfersByIDPut (request, h) {
try {
Logger.debug('create::payload(%s)', JSON.stringify(request.payload))
const bulkTransferId = request.params.id
const { bulkTransferState, completedTimestamp, extensionList } = request.payload
const hash = Util.createHash(JSON.stringify(request.payload))
const messageId = Uuid()
let BulkTransferFulfilModel = BulkTransferModels.getBulkTransferFulfilModel()
const doc = Object.assign({}, { messageId, headers: request.headers, bulkTransferId }, request.payload)
await new BulkTransferFulfilModel(doc).save()
const message = { bulkTransferId, bulkTransferState, completedTimestamp, extensionList, hash }
await TransferService.bulkPrepare(messageId, request.headers, message)
return h.response().code(202)
} catch (err) {
Logger.error(err)
throw Boom.boomify(err, { message: 'An error has occurred' })
}
}
}
Loading

0 comments on commit 5f79bf1

Please sign in to comment.