-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #356 from USEPA/feature/update-status-api-endpoints
Feature/update status api endpoints
- Loading branch information
Showing
3 changed files
with
51 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,13 +3,21 @@ const express = require("express"); | |
const { axiosFormio, formUrl } = require("../config/formio"); | ||
const { getSamEntities } = require("../utilities/bap"); | ||
|
||
/** | ||
* Verify that schema has type of form and a title exists | ||
* (confirming Formio returned a valid schema). | ||
*/ | ||
function verifySchema(schema) { | ||
return schema.type === "form" && !!schema.title; | ||
} | ||
|
||
const router = express.Router(); | ||
|
||
router.get("/app", (req, res) => { | ||
return res.json({ status: true }); | ||
}); | ||
|
||
router.get("/bap-sam-data", (req, res) => { | ||
router.get("/bap/sam", (req, res) => { | ||
getSamEntities(req, "[email protected]") | ||
.then((bapRes) => { | ||
if (!Array.isArray(bapRes)) { | ||
|
@@ -24,50 +32,51 @@ router.get("/bap-sam-data", (req, res) => { | |
}); | ||
}); | ||
|
||
router.get("/formio-application-schema", (req, res) => { | ||
router.get("/formio/2022/frf", (req, res) => { | ||
axiosFormio(req) | ||
.get(formUrl["2022"].frf) | ||
.then((axiosRes) => axiosRes.data) | ||
.then((schema) => { | ||
/** | ||
* Verify that schema has type of form and a title exists | ||
* (confirming Formio returned a valid schema). | ||
*/ | ||
return res.json({ status: schema.type === "form" && !!schema.title }); | ||
return res.json({ status: verifySchema(schema) }); | ||
}) | ||
.catch((error) => { | ||
// NOTE: error is logged in axiosFormio response interceptor | ||
return res.json({ status: false }); | ||
}); | ||
}); | ||
|
||
router.get("/formio-payment-request-schema", (req, res) => { | ||
router.get("/formio/2022/prf", (req, res) => { | ||
axiosFormio(req) | ||
.get(formUrl["2022"].prf) | ||
.then((axiosRes) => axiosRes.data) | ||
.then((schema) => { | ||
/** | ||
* Verify that schema has type of form and a title exists | ||
* (confirming Formio returned a valid schema). | ||
*/ | ||
return res.json({ status: schema.type === "form" && !!schema.title }); | ||
return res.json({ status: verifySchema(schema) }); | ||
}) | ||
.catch((error) => { | ||
// NOTE: error is logged in axiosFormio response interceptor | ||
return res.json({ status: false }); | ||
}); | ||
}); | ||
|
||
router.get("/formio-close-out-schema", (req, res) => { | ||
router.get("/formio/2022/crf", (req, res) => { | ||
axiosFormio(req) | ||
.get(formUrl["2022"].crf) | ||
.then((axiosRes) => axiosRes.data) | ||
.then((schema) => { | ||
/** | ||
* Verify that schema has type of form and a title exists | ||
* (confirming Formio returned a valid schema). | ||
*/ | ||
return res.json({ status: schema.type === "form" && !!schema.title }); | ||
return res.json({ status: verifySchema(schema) }); | ||
}) | ||
.catch((error) => { | ||
// NOTE: error is logged in axiosFormio response interceptor | ||
return res.json({ status: false }); | ||
}); | ||
}); | ||
|
||
router.get("/formio/2023/frf", (req, res) => { | ||
axiosFormio(req) | ||
.get(formUrl["2023"].frf) | ||
.then((axiosRes) => axiosRes.data) | ||
.then((schema) => { | ||
return res.json({ status: verifySchema(schema) }); | ||
}) | ||
.catch((error) => { | ||
// NOTE: error is logged in axiosFormio response interceptor | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters