Merge branch 'Development' into 6715-change-sastoken-to-oauth

This commit is contained in:
2021-11-18 10:25:47 +00:00
35 changed files with 988 additions and 870 deletions
+269 -269
View File
@@ -1,6 +1,8 @@
import axios from "axios";
import https from "https";
import CryptoJS from "crypto-js";
import HmacSHA256 from "crypto-js/hmac-sha256";
import { has, indexOf } from "lodash";
let BASE_URL;
const port = parseInt(process.env.PORT, 10) || 3000;
@@ -10,6 +12,7 @@ if (process.browser) {
} else {
BASE_URL = process.env.API_ROOT || `http://localhost:${port}`;
}
const WORDKEY = process.env.NEXT_PUBLIC_HASHKEY;
const cache = {};
const API_PATH = "/api/data/v8.2/";
@@ -145,51 +148,62 @@ const azureHeadersPaged = (SASToken) => {
};
};
const hashAPIPath = (queryPath) => {
var hashPath =
queryPath.indexOf("/api/proxy/") == -1
? queryPath
: queryPath.split("/api/proxy/")[1];
var hashlink = CryptoJS.HmacSHA256(
hashPath,
CryptoJS.enc.Hex.parse(WORDKEY)
);
hashlink = hashlink.toString(CryptoJS.enc.Hex);
return "&hash=" + hashlink;
};
export const getBasicSearch = (token, searchString) => {
//console.log("\n\n", token, searchString);
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=(contains(title, '" +
searchString +
"') or contains(ticketnumber, '" +
searchString +
"')) and pinswg_appealcasetype ne null and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true";
return axios
.get(
WEBAPI_URL +
"incidents?$select=numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=(contains(title, '" +
searchString +
"') or contains(ticketnumber, '" +
searchString +
"')) and pinswg_appealcasetype ne null and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true",
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
azureHeadersPaged(token)
)
.then((res) => {
// console.log(" ");
// console.log("/////////////////////");
// console.log("data:" + res.data.value);
// console.log("/////////////////////");
// console.log(" ");
return res.data;
})
.catch((error) => {
//console.log("thiserror", error);
return error.response;
});
};
export const getBasicSearchPaged = (searchString, pageNumber) => {
//console.log("\n\n", token, searchString);
var token = getToken();
console.log(typeof pageNumber != "undefined");
//console.log(typeof pageNumber != "undefined");
var queryUrl =
"/api/proxy/incidents?$select=numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=(contains(title, '" +
searchString +
"') or contains(ticketnumber, '" +
searchString +
"')) and pinswg_appealcasetype ne null and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true" +
(typeof pageNumber != "undefined"
? "&$skiptoken=" + '<cookie pagenumber="' + pageNumber + '" />'
: "");
//console.log(queryUrl);
return axios
.get(
"/api/proxy/incidents?$select=numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=(contains(title, '" +
searchString +
"') or contains(ticketnumber, '" +
searchString +
"')) and pinswg_appealcasetype ne null and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true" +
(typeof pageNumber != "undefined"
? "&$skiptoken=" +
encodeURI('<cookie pagenumber="' + pageNumber + '" />')
: ""),
azureHeadersPaged(token)
)
.get(queryUrl + hashAPIPath(queryUrl))
.then((res) => {
// console.log(" ");
// console.log("/////////////////////");
@@ -205,10 +219,12 @@ export const getBasicSearchPaged = (searchString, pageNumber) => {
};
export const getBasicDNSSearch = (token, searchString) => {
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=pinswg_appealcasetype eq 846040011 and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true";
return axios
.get(
WEBAPI_URL +
"incidents?$select=numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=pinswg_appealcasetype eq 846040011 and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true",
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
azureHeadersPaged(token)
)
.then((res) => res.data)
@@ -220,15 +236,14 @@ export const getBasicDNSSearch = (token, searchString) => {
export const getBasicDNSSearchPaged = (pageNumber) => {
var token = getToken();
var queryUrl =
"/api/proxy/incidents?$select=numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=pinswg_appealcasetype eq 846040011 and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true" +
(typeof pageNumber != "undefined"
? "&$skiptoken=" + '<cookie pagenumber="' + pageNumber + '" />'
: "");
return axios
.get(
"/api/proxy/incidents?$select=numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=pinswg_appealcasetype eq 846040011 and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true" +
(typeof pageNumber != "undefined"
? "&$skiptoken=" +
encodeURI('<cookie pagenumber="' + pageNumber + '" />')
: ""),
azureHeadersPaged(token)
)
.get(queryUrl + hashAPIPath(queryUrl))
.then((res) => res.data)
.catch((error) => {
return error.response;
@@ -265,13 +280,13 @@ export const getAdvancedSearch = (token, searchString) => {
searchString.apt
: "";
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=" +
queryString +
" and pinswg_appealcasetype ne null and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true";
return axios
.get(
WEBAPI_URL +
"incidents?$select=numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=" +
queryString +
" and pinswg_appealcasetype ne null and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true",
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
azureHeadersPaged(token)
)
.then((res) => res.data)
@@ -317,18 +332,16 @@ export const getAdvancedSearchPaged = (searchString, pageNumber) => {
searchString.apt
: "";
return axios
.get(
"/api/proxy/incidents?$select=numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=" +
queryString +
" and pinswg_appealcasetype ne null and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true" +
(typeof pageNumber != "undefined"
? "&$skiptoken=" +
encodeURI('<cookie pagenumber="' + pageNumber + '" />')
: ""),
var queryUrl =
"/api/proxy/incidents?$select=numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value&$expand=primarycontactid($select=fullname)&$filter=" +
queryString +
" and pinswg_appealcasetype ne null and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true" +
(typeof pageNumber != "undefined"
? "&$skiptoken=" + ('<cookie pagenumber="' + pageNumber + '" />')
: "");
azureHeadersPaged(token)
)
return axios
.get(queryUrl + hashAPIPath(queryUrl))
.then((res) => res.data)
.catch((error) => {
let ErrResponse = {
@@ -348,15 +361,17 @@ export const getBasicSearchDetails = (
incidentID
) => {
//console.log("check appealtype:", appealType, caseReference);
var queryUrl =
appealTypeName +
"?$filter=_" +
primaryIdAttribute +
"s_value eq " +
incidentID +
"&$count=true";
return axios
.get(
WEBAPI_URL +
appealTypeName +
"?$filter=_" +
primaryIdAttribute +
"s_value eq " +
incidentID +
"&$count=true",
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
azureHeadersPaged(token)
)
.then((res) => res.data)
@@ -372,19 +387,18 @@ export const getBasicSearchDetailsPaged = (
incidentID
) => {
//console.log("check appealtype:", appealType, caseReference);
var token = getToken();
var queryUrl =
"/api/proxy/" +
appealTypeName +
"?$filter=_" +
primaryIdAttribute +
"s_value eq " +
incidentID +
"&$count=true";
return axios
.get(
"/api/proxy/" +
appealTypeName +
"?$filter=_" +
primaryIdAttribute +
"s_value eq " +
incidentID +
"&$count=true",
azureHeaders(token)
)
.get(queryUrl + hashAPIPath(queryUrl))
.then((res) => res.data)
.catch((error) => {
console.log("this error", error);
@@ -392,12 +406,14 @@ export const getBasicSearchDetailsPaged = (
};
export const getSearchDocumentDetails = (token, incidentID) => {
console.log(incidentID);
var queryUrl =
"pinswg_documents?$count=true&$filter=_pinswg_documentids_value eq " +
incidentID +
" and pinswg_publishtoweb eq true&$select=pinswg_isharedocumentlocations,_pinswg_documentids_value,pinswg_isharelabelcasetype,pinswg_isharelabellpaname,pinswg_publishtoweb,pinswg_uploadstatus,pinswg_isharedocumentclassification,pinswg_isharedocumentreference";
return axios
.get(
WEBAPI_URL +
"pinswg_documents?$count=true&$filter=_pinswg_documentids_value eq " +
incidentID +
" and pinswg_publishtoweb eq true&$select=pinswg_isharedocumentlocations,_pinswg_documentids_value,pinswg_isharelabelcasetype,pinswg_isharelabellpaname,pinswg_publishtoweb,pinswg_uploadstatus,pinswg_isharedocumentclassification,pinswg_isharedocumentreference",
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
azureHeadersPaged(token)
)
.then((res) => res.data)
@@ -407,11 +423,12 @@ export const getSearchDocumentDetails = (token, incidentID) => {
};
export const getSearchDocumentHistory = (token, documentID) => {
var queryUrl =
"pinswg_documenthistories?$count=true&$select=_pinswg_documentid_value,pinswg_createddate,pinswg_state,pinswg_fileexists,statecode,pinswg_publisheddate&$filter=_pinswg_documentid_value eq " +
documentID;
return axios
.get(
WEBAPI_URL +
"pinswg_documenthistories?$count=true&$select=_pinswg_documentid_value,pinswg_createddate,pinswg_state,pinswg_fileexists,statecode,pinswg_publisheddate&$filter=_pinswg_documentid_value eq " +
documentID,
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
azureHeadersPaged(token)
)
.then((res) => res.data)
@@ -424,17 +441,17 @@ export const getSearchDocumentDetailsPaged = (incidentID, pageNumber) => {
console.log(incidentID);
var token = getToken();
var queryUrl =
"/api/proxy/pinswg_documents?$count=true&$filter=_pinswg_documentids_value eq " +
incidentID +
" and pinswg_publishtoweb eq true&$select=pinswg_isharedocumentlocations,_pinswg_documentids_value,pinswg_isharelabelcasetype,pinswg_isharelabellpaname,pinswg_publishtoweb,pinswg_uploadstatus,pinswg_isharedocumentclassification,pinswg_isharedocumentreference" +
(typeof pageNumber != "undefined"
? "&$skiptoken=" +
encodeURI('<cookie pagenumber="' + pageNumber + '" />')
: "");
return axios
.get(
"/api/proxy/pinswg_documents?$count=true&$filter=_pinswg_documentids_value eq " +
incidentID +
" and pinswg_publishtoweb eq true&$select=pinswg_isharedocumentlocations,_pinswg_documentids_value,pinswg_isharelabelcasetype,pinswg_isharelabellpaname,pinswg_publishtoweb,pinswg_uploadstatus,pinswg_isharedocumentclassification,pinswg_isharedocumentreference" +
(typeof pageNumber != "undefined"
? "&$skiptoken=" +
encodeURI('<cookie pagenumber="' + pageNumber + '" />')
: ""),
azureHeadersPaged(token)
)
.get(queryUrl + hashAPIPath(queryUrl))
.then((res) => res.data)
.catch((error) => {
console.log("thiserror", error);
@@ -444,16 +461,14 @@ export const getSearchDocumentDetailsPaged = (incidentID, pageNumber) => {
export const getSearchDocumentHistoryPaged = (documentID, pageNumber) => {
var token = getToken();
var queryUrl =
"/api/proxy/pinswg_documenthistories?$count=true&$select=_pinswg_documentid_value,pinswg_createddate,pinswg_state,pinswg_fileexists,statecode,pinswg_publisheddate&$filter=_pinswg_documentid_value eq " +
documentID +
(typeof pageNumber != "undefined"
? "&$skiptoken=" + ('<cookie pagenumber="' + pageNumber + '" />')
: "");
return axios
.get(
"/api/proxy/pinswg_documenthistories?$count=true&$select=_pinswg_documentid_value,pinswg_createddate,pinswg_state,pinswg_fileexists,statecode,pinswg_publisheddate&$filter=_pinswg_documentid_value eq " +
documentID +
(typeof pageNumber != "undefined"
? "&$skiptoken=" +
encodeURI('<cookie pagenumber="' + pageNumber + '" />')
: ""),
azureHeadersPaged(token)
)
.get(queryUrl + hashAPIPath(queryUrl))
.then((res) => res.data)
.catch((error) => {
console.log("thiserror", error);
@@ -462,12 +477,13 @@ export const getSearchDocumentHistoryPaged = (documentID, pageNumber) => {
export const getSearchDocumentDetails1 = (incidentID) => {
//console.log(incidentID);
var token = getSASToken();
var queryUrl =
"/api/proxy/pinswg_documents?$count=true&$filter=pinswg_publishtoweb eq true and _pinswg_documentids_value eq " +
incidentID +
"&$select=pinswg_isharedocumentlocations,_pinswg_documentids_value,pinswg_isharelabelcasetype,pinswg_isharelabellpaname,pinswg_publishtoweb,pinswg_uploadstatus,pinswg_isharedocumentclassification,pinswg_isharedocumentreference";
return axios
.get(
"/api/proxy/pinswg_documents?$count=true&$filter=pinswg_publishtoweb eq true and _pinswg_documentids_value eq " +
incidentID +
"&$select=pinswg_isharedocumentlocations,_pinswg_documentids_value,pinswg_isharelabelcasetype,pinswg_isharelabellpaname,pinswg_publishtoweb,pinswg_uploadstatus,pinswg_isharedocumentclassification,pinswg_isharedocumentreference"
)
.get(queryUrl + hashAPIPath(queryUrl))
.then((res) => res.data)
.catch((error) => {
console.log("thiserror", error);
@@ -476,16 +492,16 @@ export const getSearchDocumentDetails1 = (incidentID) => {
export const getSearchDocumentDetails1Paged = (incidentID, pageNumber) => {
//console.log(incidentID);
var token = getSASToken();
var queryUrl =
"/api/proxy/pinswg_documents?$count=true&$filter=pinswg_publishtoweb eq true and _pinswg_documentids_value eq " +
incidentID +
"&$select=pinswg_isharedocumentlocations,_pinswg_documentids_value,pinswg_isharelabelcasetype,pinswg_isharelabellpaname,pinswg_publishtoweb,pinswg_uploadstatus,pinswg_isharedocumentclassification,pinswg_isharedocumentreference" +
(typeof pageNumber != "undefined"
? "&$skiptoken=" + ('<cookie pagenumber="' + pageNumber + '" />')
: "");
return axios
.get(
"/api/proxy/pinswg_documents?$count=true&$filter=pinswg_publishtoweb eq true and _pinswg_documentids_value eq " +
incidentID +
"&$select=pinswg_isharedocumentlocations,_pinswg_documentids_value,pinswg_isharelabelcasetype,pinswg_isharelabellpaname,pinswg_publishtoweb,pinswg_uploadstatus,pinswg_isharedocumentclassification,pinswg_isharedocumentreference" +
(typeof pageNumber != "undefined"
? "&$skiptoken=" +
encodeURI('<cookie pagenumber="' + pageNumber + '" />')
: "")
)
.get(queryUrl + hashAPIPath(queryUrl))
.then((res) => res.data)
.catch((error) => {
console.log("thiserror", error);
@@ -494,11 +510,12 @@ export const getSearchDocumentDetails1Paged = (incidentID, pageNumber) => {
export const getSearchDocumentHistory1 = (documentID) => {
//console.log(documentID);
var token = getSASToken();
var queryUrl =
"/api/proxy/pinswg_documenthistories?$count=true&$select=_pinswg_documentid_value,pinswg_createddate,pinswg_state,pinswg_fileexists,statecode,pinswg_publisheddate&$filter=_pinswg_documentid_value eq " +
documentID;
return axios
.get(
"/api/proxy/pinswg_documenthistories?$count=true&$select=_pinswg_documentid_value,pinswg_createddate,pinswg_state,pinswg_fileexists,statecode,pinswg_publisheddate&$filter=_pinswg_documentid_value eq " +
documentID
)
.get(queryUrl + hashAPIPath(queryUrl))
.then((res) => {
return res.data;
})
@@ -509,15 +526,15 @@ export const getSearchDocumentHistory1 = (documentID) => {
export const getSearchDocumentHistory1Paged = (documentID, pageNumber) => {
//console.log(documentID);
var token = getSASToken();
var queryUrl =
"/api/proxy/pinswg_documenthistories?$count=true&$select=_pinswg_documentid_value,pinswg_createddate,pinswg_state,pinswg_fileexists,statecode,pinswg_publisheddate&$filter=_pinswg_documentid_value eq " +
documentID +
(typeof pageNumber != "undefined"
? "&$skiptoken=" + ('<cookie pagenumber="' + pageNumber + '" />')
: "");
return axios
.get(
"/api/proxy/pinswg_documenthistories?$count=true&$select=_pinswg_documentid_value,pinswg_createddate,pinswg_state,pinswg_fileexists,statecode,pinswg_publisheddate&$filter=_pinswg_documentid_value eq " +
documentID +
(typeof pageNumber != "undefined"
? "&$skiptoken=" +
encodeURI('<cookie pagenumber="' + pageNumber + '" />')
: "")
)
.get(queryUrl + hashAPIPath(queryUrl))
.then((res) => {
return res.data;
})
@@ -527,12 +544,13 @@ export const getSearchDocumentHistory1Paged = (documentID, pageNumber) => {
};
export const getBasicDNSSearchDetails = (token, appealType, caseReference) => {
var queryUrl =
"pinswg_dnses?$filter=pinswg_name eq '" +
caseReference +
"'&$count=true";
return axios
.get(
WEBAPI_URL +
"pinswg_dnses?$filter=pinswg_name eq '" +
caseReference +
"'&$count=true",
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
azureHeadersPaged(token)
)
.then((res) => res.data)
@@ -544,13 +562,13 @@ export const getBasicDNSSearchDetails = (token, appealType, caseReference) => {
export const getBasicDNSSearchDetailsPaged = (caseReference) => {
var token = getToken();
var queryUrl =
"/api/proxy/pinswg_dnses?$filter=pinswg_name eq '" +
caseReference +
"'&$count=true";
return axios
.get(
"/api/proxy/pinswg_dnses?$filter=pinswg_name eq '" +
caseReference +
"'&$count=true",
azureHeadersPaged(token)
)
.get(queryUrl + hashAPIPath(queryUrl))
.then((res) => res.data)
.catch((error) => {
console.log("thiserror", error);
@@ -559,14 +577,12 @@ export const getBasicDNSSearchDetailsPaged = (caseReference) => {
export const getLinkedCases = (parentIncidentid) => {
//console.log(parentIncidentid);
//var token = getToken();
var queryUrl =
"/api/proxy/incidents?$count=true&$filter=_parentcaseid_value eq " +
parentIncidentid +
" and pinswg_appealcasetype ne null and pinswg_publishtoweb eq true &$select=title, incidentid";
return axios
.get(
"/api/proxy/incidents?$count=true&$filter=_parentcaseid_value eq " +
parentIncidentid +
" and pinswg_appealcasetype ne null and pinswg_publishtoweb eq true &$select=title, incidentid,"
)
.get(queryUrl + hashAPIPath(queryUrl))
.then((res) => {
//console.log(" linked date", res.data);
return res.data;
@@ -577,16 +593,12 @@ export const getLinkedCases = (parentIncidentid) => {
};
export const getFormData = (token, whichForm) => {
//console.log("got to axios", whichForm);
//console.log("api_root: ", BASE_URL);
var queryUrl =
"systemforms?$select=formid,name,formxml,type,objecttypecode&$filter=(objecttypecode%20eq%20%27pinswg_" +
whichForm +
"%27and%20type%20eq%202)&$count=true&$top=201";
return axios
.get(
WEBAPI_URL +
"systemforms?$select=formid,name,formxml,type,objecttypecode&$filter=(objecttypecode%20eq%20%27pinswg_" +
whichForm +
"%27and%20type%20eq%202)&$count=true&$top=201",
azureHeaders(token)
)
.get(WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), azureHeaders(token))
.then((res) => res.data)
.catch((error) => {
console.log("thiserror", error);
@@ -594,14 +606,12 @@ export const getFormData = (token, whichForm) => {
};
export const getMandatoryFields = (token, whichForm) => {
var queryUrl =
"EntityDefinitions(LogicalName='pinswg_" +
whichForm +
"')/Attributes?$count=true&$select=LogicalName,RequiredLevel";
return axios
.get(
WEBAPI_URL +
"EntityDefinitions(LogicalName='pinswg_" +
whichForm +
"')/Attributes?$count=true&$select=LogicalName,RequiredLevel",
azureHeaders(token)
)
.get(WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), azureHeaders(token))
.then((res) => res.data)
.catch((error) => {
console.log("thiserror", error);
@@ -609,14 +619,12 @@ export const getMandatoryFields = (token, whichForm) => {
};
export const getPickLists = (token, whichForm) => {
var queryUrl =
"EntityDefinitions(LogicalName='pinswg_" +
whichForm +
"')/Attributes/Microsoft.Dynamics.CRM.PicklistAttributeMetadata?$select=LogicalName&$expand=OptionSet,GlobalOptionSet&$count=true";
return axios
.get(
WEBAPI_URL +
"EntityDefinitions(LogicalName='pinswg_" +
whichForm +
"')/Attributes/Microsoft.Dynamics.CRM.PicklistAttributeMetadata?$select=LogicalName&$expand=OptionSet,GlobalOptionSet&$count=true",
azureHeaders(token)
)
.get(WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), azureHeaders(token))
.then((res) => res.data)
.catch((error) => {
console.log("thiserror", error);
@@ -624,12 +632,10 @@ export const getPickLists = (token, whichForm) => {
};
export const getAppealsTypes = (token) => {
var queryUrl =
"stringmaps?$filter=objecttypecode eq 'incident' and attributename eq 'pinswg_appealcasetype' and value ne 'LDP' and value ne 'Misc Casework'&$count=true&$select=value,stringmapid,organizationid,attributevalue&$orderby=value asc";
return axios
.get(
WEBAPI_URL +
"stringmaps?$filter=attributename eq 'pinswg_appealcasetype' and value ne 'LDP' and value ne 'Misc Casework'&$count=true&$select=value,stringmapid,organizationid,attributevalue",
azureHeaders(token)
)
.get(WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), azureHeaders(token))
.then((res) => res.data)
.catch((error) => {
console.log(error);
@@ -645,12 +651,10 @@ export const getAppealsTypes = (token) => {
export const getLPA = (token) => {
// console.log("api_root: ", BASE_URL);
var queryUrl =
"accounts?$count=true&$filter=pinswg_isalocalplanningauthorityaccount eq 846040000&$select=name&$orderby=name asc";
return axios
.get(
WEBAPI_URL +
"accounts?$count=true&$filter=pinswg_isalocalplanningauthorityaccount eq 846040000&$select=name",
azureHeaders(token)
)
.get(WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), azureHeaders(token))
.then((res) => {
//console.log(res.data);
return res.data;
@@ -667,15 +671,13 @@ export const getLPA = (token) => {
};
export const getPersonalAccount = (token, contactid) => {
//console.log("getting personal details:", contactid);
var queryUrl =
"contacts(" +
contactid +
")?$select=firstname, lastname, emailaddress1, telephone1, company, address1_line1,address1_line2,address1_city, address1_county,address1_postalcode&$count=true";
return axios
.get(
WEBAPI_URL +
"contacts(" +
contactid +
")?$select=firstname, lastname, emailaddress1, telephone1, company, address1_line1,address1_line2,address1_city, address1_county,address1_postalcode&$count=true",
azureHeaders(token)
)
.get(WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), azureHeaders(token))
.then((res) => {
console.log(res.data);
return res.data;
@@ -696,7 +698,7 @@ export const getAppealID = (
updateFormCollection,
primaryAttribute
) => {
const weburl =
const queryUrl =
"/api/proxy/" +
updateFormCollection +
"?$count=true&$select=_" +
@@ -705,9 +707,12 @@ export const getAppealID = (
caseReference +
"'";
console.log("proxy url ", weburl);
console.log("proxy url ", queryUrl);
return axios
.get(weburl, azureHeaders(getToken()))
.get(
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
azureHeaders(getSASToken())
)
.then((res) => {
var appealID = res.data.value[0][primaryAttribute];
return appealID;
@@ -718,14 +723,15 @@ export const getAppealID = (
};
export const getLogin = (emailAddress, pwd) => {
var queryUrl =
"/api/proxy/contacts?$filter=emailaddress1 eq '" +
emailAddress +
"' and pinswg_custom_password eq '" +
pwd +
"'&$count=true&$select=emailaddress1,%20contactid,pinswg_custom_password, yomifullname, firstname, lastname";
return axios
.get(
"/api/proxy/contacts?$filter=emailaddress1 eq '" +
emailAddress +
"' and pinswg_custom_password eq '" +
pwd +
"'&$count=true&$select=emailaddress1,%20contactid,pinswg_custom_password, yomifullname, firstname, lastname"
)
.get(queryUrl + hashAPIPath(queryUrl))
.then((res) => res.data)
.catch((error) => {
console.log("thiserror", error);
@@ -734,6 +740,8 @@ export const getLogin = (emailAddress, pwd) => {
export const createCase = (token, appealTypeId, lpaID, contactid) => {
appealTypeId = parseInt(appealTypeId);
var queryUrl = "incidents";
var data = JSON.stringify({
"title": "insertion test case",
"caseorigincode": 3,
@@ -744,7 +752,7 @@ export const createCase = (token, appealTypeId, lpaID, contactid) => {
var config = {
method: "post",
url: WEBAPI_URL + "incidents",
url: queryUrl + hashAPIPath(queryUrl),
headers: {
"OData-MaxVersion": "4.0",
"OData-Version": "4.0",
@@ -783,10 +791,11 @@ export const updateCase = async (
console.log("appeal obj ", appealObj);
var queryUrl = "/api/proxy/" + updateFormCollection + "(" + appealObj + ")";
var config = {
method: "patch",
//url: WEBAPI_URL + updateFormCollection + "(" + incidentId + ")",
url: "/api/proxy/" + updateFormCollection + "(" + appealObj + ")",
//url: updateFormCollection + "(" + incidentId + ")",
url: queryUrl + hashAPIPath(queryUrl),
headers: {
"OData-MaxVersion": "4.0",
"OData-Version": "4.0",
@@ -811,14 +820,12 @@ export const updateCase = async (
export const getMyCases = (token, loggedInUserId) => {
//console.log("in action ", loggedInUserId);
var queryUrl =
"incidents?$select=ticketnumber,casetypecode,createdon,_customerid_value,description,incidentid,pinswg_appealcasetype,_pinswg_assignedinspectrids_value,statecode,statuscode,title&$filter=_customerid_value eq " +
loggedInUserId +
" and pinswg_appealcasetype ne null&$orderby=createdon desc&$count=true&$top=3";
return axios
.get(
WEBAPI_URL +
"incidents?$select=ticketnumber,casetypecode,createdon,_customerid_value,description,incidentid,pinswg_appealcasetype,_pinswg_assignedinspectrids_value,statecode,statuscode,title&$filter=_customerid_value eq " +
loggedInUserId +
" and pinswg_appealcasetype ne null&$orderby=createdon desc&$count=true&$top=3",
azureHeaders(token)
)
.get(WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), azureHeaders(token))
.then((res) => {
return res.data;
})
@@ -828,14 +835,12 @@ export const getMyCases = (token, loggedInUserId) => {
};
export const getMyRepresentations = (token, loggedInUserId) => {
var queryUrl =
"pinswg_representationses?$filter= _pinswg_contact_value eq " +
loggedInUserId +
"&$count=true&$orderby=createdon desc";
return axios
.get(
WEBAPI_URL +
"pinswg_representationses?$filter= _pinswg_contact_value eq " +
loggedInUserId +
"&$count=true&$orderby=createdon desc",
azureHeaders(token)
)
.get(WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), azureHeaders(token))
.then((res) => res.data)
.catch((error) => {
console.log("this serror", error);
@@ -843,13 +848,12 @@ export const getMyRepresentations = (token, loggedInUserId) => {
};
export const getMyRepresentationsProxy = (token, loggedInUserId) => {
var queryUrl =
"/api/proxy/pinswg_representationses?$filter= _pinswg_contact_value eq " +
loggedInUserId +
"&$count=true&$orderby=createdon desc";
return axios
.get(
"/api/proxy/pinswg_representationses?$filter= _pinswg_contact_value eq " +
loggedInUserId +
"&$count=true&$orderby=createdon desc",
azureHeaders(token)
)
.get(queryUrl + hashAPIPath(queryUrl))
.then((res) => res.data)
.catch((error) => {
console.log("this serror", error);
@@ -857,9 +861,11 @@ export const getMyRepresentationsProxy = (token, loggedInUserId) => {
};
export const deleteMyRepresentations = (myRepresentationsID) => {
var queryUrl =
"/api/proxy/pinswg_representationses(" + myRepresentationsID + ")";
var config = {
method: "delete",
url: "/api/proxy/pinswg_representationses(" + myRepresentationsID + ")",
url: queryUrl + hashAPIPath(queryUrl),
headers: {
"OData-MaxVersion": "4.0",
"OData-Version": "4.0",
@@ -881,13 +887,12 @@ export const deleteMyRepresentations = (myRepresentationsID) => {
};
export const getRepresentations = (incidentID) => {
var queryUrl =
"/api/proxy/pinswg_representationses?$filter= _pinswg_case_value eq " +
incidentID +
" and pinswg_publishtoweb eq true&$count=true&$orderby=createdon desc";
return axios
.get(
"/api/proxy/pinswg_representationses?$filter= _pinswg_case_value eq " +
incidentID +
" and pinswg_publishtoweb eq true&$count=true&$orderby=createdon desc",
azureHeaders(getToken())
)
.get(queryUrl + hashAPIPath(queryUrl))
.then((res) => res.data)
.catch((error) => {
console.log("this serror", error);
@@ -895,13 +900,12 @@ export const getRepresentations = (incidentID) => {
};
export const getRepresentationsProxy = (token, incidentID) => {
var queryUrl =
"/api/proxy/pinswg_representationses?$filter= _pinswg_case_value eq " +
incidentID +
"&$count=true&$orderby=createdon desc";
return axios
.get(
"/api/proxy/pinswg_representationses?$filter= _pinswg_case_value eq " +
incidentID +
"&$count=true&$orderby=createdon desc",
azureHeaders(token)
)
.get(queryUrl + hashAPIPath(queryUrl))
.then((res) => res.data)
.catch((error) => {
console.log("this serror", error);
@@ -909,14 +913,12 @@ export const getRepresentationsProxy = (token, incidentID) => {
};
export const getWatchedCases = (token, loggedInUserId) => {
var queryUrl =
"pinswg_watchlists?$filter= _pinswg_contact_value eq " +
loggedInUserId +
"&$count=true&$orderby=createdon desc";
return axios
.get(
WEBAPI_URL +
"pinswg_watchlists?$filter= _pinswg_contact_value eq " +
loggedInUserId +
"&$count=true&$orderby=createdon desc",
azureHeaders(token)
)
.get(WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), azureHeaders(token))
.then((res) => res.data)
.catch((error) => {
console.log("this serror", error);
@@ -924,13 +926,12 @@ export const getWatchedCases = (token, loggedInUserId) => {
};
export const getWatchedCasesProxy = (token, loggedInUserId) => {
var queryUrl =
"/api/proxy/pinswg_watchlists?$filter= _pinswg_contact_value eq " +
loggedInUserId +
"&$count=true&$orderby=createdon desc";
return axios
.get(
"/api/proxy/pinswg_watchlists?$filter= _pinswg_contact_value eq " +
loggedInUserId +
"&$count=true&$orderby=createdon desc",
azureHeaders(token)
)
.get(queryUrl + hashAPIPath(queryUrl))
.then((res) => res.data)
.catch((error) => {
console.log("this serror", error);
@@ -939,10 +940,11 @@ export const getWatchedCasesProxy = (token, loggedInUserId) => {
export const createWatchedCases = (formValues) => {
var data = JSON.stringify(formValues);
var queryUrl = "/api/proxy/pinswg_watchlists";
var config = {
method: "post",
url: "/api/proxy/pinswg_watchlists",
url: queryUrl + hashAPIPath(queryUrl),
headers: {
"OData-MaxVersion": "4.0",
"OData-Version": "4.0",
@@ -965,9 +967,10 @@ export const createWatchedCases = (formValues) => {
};
export const deleteWatchedCases = (watchedCaseID) => {
var queryUrl = "/api/proxy/pinswg_watchlists(" + watchedCaseID + ")";
var config = {
method: "delete",
url: "/api/proxy/pinswg_watchlists(" + watchedCaseID + ")",
url: queryUrl + hashAPIPath(queryUrl),
headers: {
"OData-MaxVersion": "4.0",
"OData-Version": "4.0",
@@ -1000,15 +1003,13 @@ export const getAwaitingSubmission = (token) => {
};
export const getPortalModuleDetails = (token, appealType, caseReference) => {
var queryUrl =
appealType +
"?$filter=pinswg_name eq '" +
caseReference +
"'&$count=true";
return axios
.get(
WEBAPI_URL +
appealType +
"?$filter=pinswg_name eq '" +
caseReference +
"'&$count=true",
azureHeaders(token)
)
.get(WEBAPI_URL + queryUrl + hashAPIPath(queryUrl), azureHeaders(token))
.then((res) => res.data)
.catch((error) => {
console.log("thiserror", error);
@@ -1020,15 +1021,14 @@ export const getPortalModuleDetailsProxy = (
appealType,
caseReference
) => {
var queryUrl =
"/api/proxy/" +
appealType +
"?$filter=pinswg_name eq '" +
caseReference +
"'&$count=true";
return axios
.get(
"/api/proxy/" +
appealType +
"?$filter=pinswg_name eq '" +
caseReference +
"'&$count=true",
azureHeaders(token)
)
.get(queryUrl + hashAPIPath(queryUrl))
.then((res) => res.data)
.catch((error) => {
console.log("thiserror", error);
@@ -1036,13 +1036,13 @@ export const getPortalModuleDetailsProxy = (
};
export const getEmailAccountCheck = (emailAddress) => {
let token = getToken();
let token = getSASToken();
var queryUrl =
"/api/proxy/contacts?$filter=emailaddress1 eq '" +
emailAddress +
"'&$count=true&$select=emailaddress1, contactid";
return axios
.get(
"/api/proxy/contacts?$filter=emailaddress1 eq '" +
emailAddress +
"'&$count=true&$select=emailaddress1, contactid"
)
.get(queryUrl + hashAPIPath(queryUrl))
.then((res) => res.data)
.catch((error) => {
console.log("thiserror", error);
@@ -1051,10 +1051,10 @@ export const getEmailAccountCheck = (emailAddress) => {
export const createAccount = (formValues) => {
var data = JSON.stringify(formValues);
var queryUrl = "/api/proxy/contacts";
var config = {
method: "post",
url: "/api/proxy/contacts",
url: queryUrl + hashAPIPath(queryUrl),
headers: {
"OData-MaxVersion": "4.0",
"OData-Version": "4.0",
@@ -1078,10 +1078,10 @@ export const createAccount = (formValues) => {
export const updateAccount = (contactId, updateBody) => {
var data = JSON.stringify(updateBody);
var queryUrl = "/api/proxy/contacts(" + contactId + ")";
var config = {
method: "patch",
url: "/api/proxy/contacts(" + contactId + ")",
url: queryUrl + hashAPIPath(queryUrl),
headers: {
"OData-MaxVersion": "4.0",
"OData-Version": "4.0",
@@ -1106,10 +1106,10 @@ export const updateAccount = (contactId, updateBody) => {
export const updatePassword = (contactId, newpassword) => {
let updateBody = { "pinswg_custom_password": newpassword };
var data = JSON.stringify(updateBody);
var queryUrl = "/api/proxy/contacts(" + contactId + ")";
var config = {
method: "patch",
url: "/api/proxy/contacts(" + contactId + ")",
url: queryUrl + hashAPIPath(queryUrl),
headers: {
"OData-MaxVersion": "4.0",
"OData-Version": "4.0",