Skip to content

Commit

Permalink
Merge pull request #208 from bcgov/ofmcc-3836-display-funding-pdf
Browse files Browse the repository at this point in the history
Ofmcc 3836 display funding pdf
  • Loading branch information
jenbeckett authored May 24, 2024
2 parents 3970d15 + 2f514e8 commit 451a111
Show file tree
Hide file tree
Showing 7 changed files with 976 additions and 47 deletions.
12 changes: 12 additions & 0 deletions backend/src/components/fundingAgreements.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,17 @@ async function getFundingAgreementById(req, res) {
}
}

async function getFundingPDFById(req, res) {
try {
const operation = `ofm_fundings(${req?.params?.fundingAgreementId})/ofm_agreement_file`
const response = await getOperation(operation)
return res.status(HttpStatus.OK).json(response?.value)
} catch (e) {
log.error(e)
return res.status(HttpStatus.INTERNAL_SERVER_ERROR).json(e.data ? e.data : e?.status)
}
}

async function updateFundingAgreement(req, res) {
try {
let payload
Expand All @@ -71,4 +82,5 @@ module.exports = {
getFundingAgreements,
updateFundingAgreement,
getFundingAgreementById,
getFundingPDFById,
}
10 changes: 9 additions & 1 deletion backend/src/routes/fundingAgreements.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const passport = require('passport')
const router = express.Router()
const auth = require('../components/auth')
const isValidBackendToken = auth.isValidBackendToken()
const { getFundingAgreements, updateFundingAgreement, getFundingAgreementById } = require('../components/fundingAgreements')
const { getFundingAgreements, updateFundingAgreement, getFundingAgreementById, getFundingPDFById } = require('../components/fundingAgreements')
const { param, validationResult } = require('express-validator')
//TODO - JB: add permissions back in when complete

Expand All @@ -25,6 +25,14 @@ router.get('/:fundingAgreementId', passport.authenticate('jwt', { session: false
return getFundingAgreementById(req, res)
})

/**
* Get Funding Agreement PDF by ID
*/
router.get('/:fundingAgreementId/pdf', passport.authenticate('jwt', { session: false }), isValidBackendToken, (req, res) => {
validationResult(req).throw()
return getFundingPDFById(req, res)
})

/**
* Update an existing Application using applicationId
*/
Expand Down
Loading

0 comments on commit 451a111

Please sign in to comment.