Skip to content

Commit

Permalink
Update to check route and controller
Browse files Browse the repository at this point in the history
  • Loading branch information
Beckyrose200 committed Oct 21, 2024
1 parent 4cc89c7 commit 1a22aa1
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 31 deletions.
28 changes: 28 additions & 0 deletions app/controllers/check.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,37 @@
* @module CheckController
*/

const DetermineSupplementaryBillingFlagsService = require('../services/import/determine-supplementary-billing-flags.service.js')
const ProcessLicenceReturnLogsService = require('../services/jobs/return-logs/process-licence-return-logs.service.js')

const redirectStatusCode = 204

/**
* A test end point for the licence supplementary billing flags process
*
* This endpoint takes a licenceId and licence expired, lapsed and revoked date. It passes this onto the
* `DetermineSupplementaryBillingFlagsService` to test if it correctly flags the licence for supplementary billing. This
* normally happens during the licence import process.
*
* @param request - the hapi request object
* @param h - the hapi response object
*
* @returns {Promise<object>} - A promise that resolves to an HTTP response object with a 204 status code
*/
async function flagForBilling (request, h) {
const { licenceId, expiredDate, lapsedDate, revokedDate } = request.payload

const transformedLicence = {
expiredDate,
lapsedDate,
revokedDate
}

DetermineSupplementaryBillingFlagsService.go(transformedLicence, licenceId)

return h.response().code(204)
}

/**
* A test end point to create return logs for a given licence reference
*
Expand All @@ -32,5 +59,6 @@ async function returnLogsForLicence (_request, h) {
}

module.exports = {
flagForBilling,
returnLogsForLicence
}
16 changes: 0 additions & 16 deletions app/controllers/data.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* @module DataController
*/

const DetermineSupplementaryBillingFlagsService = require('../services/import/determine-supplementary-billing-flags.service.js')
const LoadService = require('../services/data/load/load.service.js')
const SeedService = require('../services/data/seed/seed.service.js')
const SubmitDeduplicateService = require('../services/data/deduplicate/submit-deduplicate.service.js')
Expand All @@ -18,20 +17,6 @@ async function deduplicate (_request, h) {
})
}

async function flagForBilling (request, h) {
const { licenceId, expiredDate, lapsedDate, revokedDate } = request.payload

const transformedLicence = {
expiredDate,
lapsedDate,
revokedDate
}

DetermineSupplementaryBillingFlagsService.go(transformedLicence, licenceId)

return h.response().code(204)
}

async function load (request, h) {
const result = await LoadService.go(request.payload)

Expand Down Expand Up @@ -66,7 +51,6 @@ async function tearDown (_request, h) {

module.exports = {
deduplicate,
flagForBilling,
load,
seed,
submitDeduplicate,
Expand Down
15 changes: 15 additions & 0 deletions app/routes/check.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,21 @@
const CheckController = require('../controllers/check.controller.js')

const routes = [
{
method: 'POST',
path: '/check/flag-for-billing',
options: {
handler: CheckController.flagForBilling,
app: {
excludeFromProd: true,
plainOutput: true
},
auth: false,
plugins: {
crumb: false
}
}
},
{
method: 'POST',
path: '/check/licence-return-logs',
Expand Down
15 changes: 0 additions & 15 deletions app/routes/data.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,21 +27,6 @@ const routes = [
}
}
},
{
method: 'POST',
path: '/data/flag-for-billing',
options: {
handler: DataController.flagForBilling,
app: {
excludeFromProd: true,
plainOutput: true
},
auth: false,
plugins: {
crumb: false
}
}
},
{
method: 'POST',
path: '/data/load',
Expand Down

0 comments on commit 1a22aa1

Please sign in to comment.