TASK22057: phase19 endpoint consistency hardening slice
This commit is contained in:
@@ -86,12 +86,30 @@ const recordExists = async (incidentId, contactId, token) => {
|
||||
};
|
||||
|
||||
export default async function ApiProxy(req, res) {
|
||||
const token = await getToken();
|
||||
const data = req.body;
|
||||
const watchedCaseBind = data?.["pinswg_WatchedCase@odata.bind"];
|
||||
const contactBind = data?.["pinswg_Contact@odata.bind"];
|
||||
|
||||
const incidentId =
|
||||
data["pinswg_WatchedCase@odata.bind"].match(/\(([^)]+)\)/)[1];
|
||||
const contactId = data["pinswg_Contact@odata.bind"].match(/\(([^)]+)\)/)[1];
|
||||
if (
|
||||
typeof watchedCaseBind !== "string" ||
|
||||
watchedCaseBind.length === 0 ||
|
||||
typeof contactBind !== "string" ||
|
||||
contactBind.length === 0
|
||||
) {
|
||||
return res.status(400).json();
|
||||
}
|
||||
|
||||
const watchedCaseMatch = watchedCaseBind.match(/\(([^)]+)\)/);
|
||||
const contactMatch = contactBind.match(/\(([^)]+)\)/);
|
||||
|
||||
if (!watchedCaseMatch || !contactMatch) {
|
||||
return res.status(400).json();
|
||||
}
|
||||
|
||||
const token = await getToken();
|
||||
|
||||
const incidentId = watchedCaseMatch[1];
|
||||
const contactId = contactMatch[1];
|
||||
|
||||
const existingRecord = await recordExists(incidentId, contactId, token);
|
||||
|
||||
|
||||
@@ -49,8 +49,6 @@ export default async function ApiProxy(req, res) {
|
||||
// "stringmaps?$filter=objecttypecode eq 'incident' and attributename eq 'pinswg_appealcasetype' and value ne 'Misc Casework'&$count=true&$select=value,stringmapid,organizationid,attributevalue&$orderby=value asc";
|
||||
//"stringmaps?$filter=objecttypecode eq 'incident' and attributename eq 'pinswg_appealcasetype' and value ne 'Developments of National Significance' and value ne 'LDP' and value ne 'Misc Casework'&$count=true&$select=value,stringmapid,organizationid,attributevalue&$orderby=value asc";
|
||||
|
||||
console.log(queryUrl);
|
||||
|
||||
return axios
|
||||
.get(
|
||||
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
|
||||
|
||||
@@ -29,8 +29,6 @@ export default async function ApiProxy(req, res) {
|
||||
var queryUrl =
|
||||
"incidents?$select=pinswg_environmentalstatementlocation,pinswg_appealcasetype,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,statuscode,ticketnumber,title &$filter=(pinswg_appealcasetype eq 846040011 or pinswg_appealcasetype eq 846040002) and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true";
|
||||
|
||||
console.log(queryUrl);
|
||||
|
||||
function renameJsonKey(jsonObj, oldKey, newKey) {
|
||||
if (jsonObj.hasOwnProperty(oldKey)) {
|
||||
jsonObj[newKey] = jsonObj[oldKey]; // Add new key with the same value
|
||||
|
||||
Reference in New Issue
Block a user