Added service stage status and delete functions

This commit is contained in:
2022-01-25 10:09:11 +00:00
parent 10f2baa7be
commit f347a0d73b
27 changed files with 575 additions and 125 deletions
+3
View File
@@ -31,11 +31,14 @@ export default async function ApiProxy(req, res) {
var data = JSON.stringify({
"title": "insertion test case",
"caseorigincode": 3,
"servicestage": 1,
"customerid_contact@odata.bind": "/contacts(" + contactid + ")",
"pinswg_appealcasetype": appealTypeId,
"pinswg_AssociatedLPA@odata.bind": "/accounts(" + lpaID + ")",
});
console.log(data);
var config = {
method: "post",
url: WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
@@ -0,0 +1,49 @@
import axios from "axios";
import CryptoJS from "crypto-js";
import { getToken, azureHeadersPaged } from "../../../actions";
const WORDKEY = process.env.HASHKEY;
const WEBAPI_URL =
process.env.RELAY_ROOT ||
"https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/";
const hashAPIPath = (queryPath) => {
var hashlink = CryptoJS.HmacSHA256(
queryPath,
CryptoJS.enc.Hex.parse(WORDKEY)
);
hashlink = hashlink.toString(CryptoJS.enc.Hex);
//return "&hash=" + hashlink;
return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink;
};
export default async function ApiProxy(req, res) {
var incidentID = req.query.incidentID;
var token = await getToken();
var queryUrl = "incidents(" + incidentID + ")";
var config = {
method: "delete",
url: WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
headers: {
"OData-MaxVersion": "4.0",
"OData-Version": "4.0",
"Accept": "application/json",
"Prefer": 'odata.include-annotations="*"',
"Authorization": "Bearer " + token.access_token,
"Content-Type": "application/json",
},
};
return axios(config)
.then(({ data }) => {
console.log("deleted awaitingsubmission case - " + incidentID);
res.status(200).json(data);
})
.catch(({ err }) => {
res.status(400).json(err);
});
}
@@ -0,0 +1,45 @@
import axios from "axios";
import CryptoJS from "crypto-js";
import { getToken, azureHeaders } from "../../../actions";
const WORDKEY = process.env.HASHKEY;
const WEBAPI_URL =
process.env.RELAY_ROOT ||
"https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/";
const hashAPIPath = (queryPath) => {
var hashlink = CryptoJS.HmacSHA256(
queryPath,
CryptoJS.enc.Hex.parse(WORDKEY)
);
hashlink = hashlink.toString(CryptoJS.enc.Hex);
return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink;
};
export default async function ApiProxy(req, res) {
var loggedInUserId = req.query.loggedInUserId;
var token = await getToken();
var queryUrl =
"incidents?$select=numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=_customerid_value eq " +
loggedInUserId +
" and servicestage eq 1 and pinswg_appealcasetype ne null&$orderby=createdon desc&$count=true";
console.log(queryUrl);
return axios
.get(
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
azureHeaders(token.access_token)
)
.then(({ data }) => {
data.value.forEach(function (element) {
element.pinswg_title = element.title;
});
res.status(200).json(data);
})
.catch(({ err }) => {
res.status(400).json(err);
});
}
@@ -0,0 +1,44 @@
import axios from "axios";
import CryptoJS from "crypto-js";
import { getToken, azureHeaders } from "../../../actions";
const WORDKEY = process.env.HASHKEY;
const WEBAPI_URL =
process.env.RELAY_ROOT ||
"https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/";
const hashAPIPath = (queryPath) => {
var hashlink = CryptoJS.HmacSHA256(
queryPath,
CryptoJS.enc.Hex.parse(WORDKEY)
);
hashlink = hashlink.toString(CryptoJS.enc.Hex);
return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink;
};
export default async function ApiProxy(req, res) {
var loggedInUserId = req.query.loggedInUserId;
var token = await getToken();
var queryUrl =
"incidents?$select=numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=_customerid_value eq " +
loggedInUserId +
" and pinswg_appealcasetype ne null&$orderby=createdon desc&$count=true";
return axios
.get(
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
azureHeaders(token.access_token)
)
.then(({ data }) => {
data.value.forEach(function (element) {
element.pinswg_title = element.title;
});
console.log(data);
res.status(200).json(data);
})
.catch(({ err }) => {
res.status(400).json(err);
});
}
@@ -15,9 +15,6 @@ const hashAPIPath = (queryPath) => {
CryptoJS.enc.Hex.parse(WORDKEY)
);
hashlink = hashlink.toString(CryptoJS.enc.Hex);
//return "&hash=" + hashlink;
return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink;
};
@@ -37,7 +34,7 @@ export default async function ApiProxy(req, res) {
queryUrl = queryUrl + getSelectQuery(appealTypeName);
console.log("query: ", queryUrl, "<<<<end query");
//console.log("query: ", queryUrl, "<<<<end query");
return axios
.get(
@@ -38,7 +38,7 @@ export default async function ApiProxy(req, res) {
queryUrl = queryUrl + getSelectQuery(appealTypeName);
console.log("query: ", queryUrl, "<<<<end query");
//console.log("query: ", queryUrl, "<<<<end query");
return axios
.get(
+7 -2
View File
@@ -22,9 +22,11 @@ export default async function ApiProxy(req, res) {
var token = await getToken();
var queryUrl =
"incidents?$select=ticketnumber,casetypecode,createdon,_customerid_value,description,incidentid,pinswg_appealcasetype,_pinswg_assignedinspectrids_value,statecode,statuscode,title&$filter=_customerid_value eq " +
"incidents?$select=numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=_customerid_value eq " +
loggedInUserId +
" and pinswg_appealcasetype ne null&$orderby=createdon desc&$count=true&$top=3";
" and servicestage eq 0 and pinswg_appealcasetype ne null&$orderby=createdon desc&$count=true&$top=3";
//console.log("Portal query: ", queryUrl, "<<<<end query");
return axios
.get(
@@ -32,6 +34,9 @@ export default async function ApiProxy(req, res) {
azureHeaders(token.access_token)
)
.then(({ data }) => {
data.value.forEach(function (element) {
element.pinswg_title = element.title;
});
res.status(200).json(data);
})
.catch(({ err }) => {
+2
View File
@@ -26,6 +26,8 @@ export default async function ApiProxy(req, res) {
whichForm +
"')/Attributes/Microsoft.Dynamics.CRM.PicklistAttributeMetadata?$select=LogicalName&$expand=OptionSet,GlobalOptionSet&$count=true";
console.log("get pick list for " + whichForm + ": ", queryUrl);
return axios
.get(
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
@@ -1,6 +1,7 @@
import axios from "axios";
import CryptoJS from "crypto-js";
import { getToken, azureHeaders } from "../../../actions";
import { getSelectQuery } from "../../../actions/selectQueryTypes";
const WORDKEY = process.env.HASHKEY;
@@ -28,6 +29,8 @@ export default async function ApiProxy(req, res) {
caseReference +
"'&$count=true";
queryUrl = queryUrl + getSelectQuery(appealType);
return axios
.get(
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
+31 -2
View File
@@ -1,6 +1,10 @@
import axios from "axios";
import CryptoJS from "crypto-js";
import { getToken, azureHeaders } from "../../../actions";
import {
getToken,
azureHeaders,
getBasicSearchDetails,
} from "../../../actions";
const WORDKEY = process.env.HASHKEY;
@@ -24,7 +28,7 @@ export default async function ApiProxy(req, res) {
var queryUrl =
"pinswg_watchlists?$filter= _pinswg_contact_value eq " +
loggedInUserId +
"&$count=true&$orderby=createdon desc";
"&$select=pinswg_appealcasetype,pinswg_watchlistid,_pinswg_watchedcase_value,statuscode&$count=true&$orderby=createdon desc&$expand=pinswg_WatchedCase($select=pinswg_AssociatedLPA)";
return axios
.get(
@@ -32,6 +36,31 @@ export default async function ApiProxy(req, res) {
azureHeaders(token.access_token)
)
.then(({ data }) => {
data.value.forEach(function (element) {
element.pinswg_title =
element[
"_pinswg_watchedcase_value@OData.Community.Display.V1.FormattedValue"
];
element[
"_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue"
] =
element.pinswg_WatchedCase[
"_pinswg_associatedlpa_value@OData.Community.Display.V1.FormattedValue"
];
element._pinswg_associatedlpa_value =
element.pinswg_WatchedCase._pinswg_associatedlpa_value;
element[
"_ownerid_value@OData.Community.Display.V1.FormattedValue"
] =
element.pinswg_WatchedCase[
"_ownerid_value@OData.Community.Display.V1.FormattedValue"
];
element._ownerid_value =
element.pinswg_WatchedCase._ownerid_value;
delete element.pinswg_WatchedCase;
});
res.status(200).json(data);
})
.catch(({ err }) => {
@@ -24,7 +24,7 @@ export default async function ApiProxy(req, res) {
var queryUrl =
"pinswg_watchlists?$filter= _pinswg_contact_value eq " +
loggedInUserId +
"&$count=true&$orderby=createdon desc";
"&$select=pinswg_appealcasetype,pinswg_watchlistid,_pinswg_watchedcase_value,statuscode&$count=true&$orderby=createdon desc&$expand=pinswg_WatchedCase($select=pinswg_AssociatedLPA)";
return axios
.get(
+60
View File
@@ -0,0 +1,60 @@
import axios from "axios";
import CryptoJS from "crypto-js";
import _ from "lodash";
import { getToken, azureHeadersPaged } from "../../../actions";
const WORDKEY = process.env.HASHKEY;
const WEBAPI_URL =
process.env.RELAY_ROOT ||
"https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/";
const hashAPIPath = (queryPath) => {
var hashlink = CryptoJS.HmacSHA256(
queryPath,
CryptoJS.enc.Hex.parse(WORDKEY)
);
hashlink = hashlink.toString(CryptoJS.enc.Hex);
//return "&hash=" + hashlink;
return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink;
};
export default async function ApiProxy(req, res) {
var incidentID = req.query.incidentid;
var queryUrl = "incidents(" + incidentID + ")";
var token = await getToken();
var data = JSON.stringify({
"servicestage": 0,
});
//console.log(data, WEBAPI_URL + queryUrl);
var config = {
method: "patch",
url: WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
headers: {
"OData-MaxVersion": "4.0",
"OData-Version": "4.0",
"Accept": "application/json",
"Prefer": 'odata.include-annotations="*",return=representation',
"Authorization": "Bearer " + token.access_token,
"Content-Type": "application/json",
},
data: data,
};
var apiResponse = _.isEmpty(req.query)
? res.status(400).json()
: axios(config)
.then(({ data }) => {
res.status(200).json(data);
})
.catch(({ err }) => {
res.status(400).json(err);
});
return apiResponse;
}
+5 -2
View File
@@ -1,6 +1,6 @@
import axios from "axios";
import CryptoJS from "crypto-js";
import { getToken } from "../../../actions";
import { getToken, patchCase } from "../../../actions";
const WORDKEY = process.env.HASHKEY;
@@ -22,7 +22,9 @@ const hashAPIPath = (queryPath) => {
export default async function ApiProxy(req, res) {
var data = JSON.stringify(req.body);
var appealObj = rea.query.appealObj;
var appealObj = req.query.appealObj;
var incidentID = req.query.incident;
var updateFormCollection = req.query.updateFormCollection;
var queryUrl = updateFormCollection + "(" + appealObj + ")";
@@ -47,6 +49,7 @@ export default async function ApiProxy(req, res) {
res.status(200).json(data);
})
.catch(({ err }) => {
console.log(err);
res.status(400).json(err);
});
}