Removed proxy and added api calls, has gov gateway auth

This commit is contained in:
2022-01-20 10:56:26 +00:00
parent 6f37064eba
commit 5a536e158c
127 changed files with 5829 additions and 3097 deletions
+49
View File
@@ -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 token = await getToken();
var queryUrl = "contacts";
var data = JSON.stringify(req.body);
var config = {
method: "post",
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,
};
return axios(config)
.then(({ data }) => {
res.status(200).json(data);
})
.catch(({ err }) => {
res.status(400).json(err);
});
}
+65
View File
@@ -0,0 +1,65 @@
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 contactid = req.query.contactid;
var appealTypeId = req.query.appealTypeId;
var lpaID = req.query.lpaID;
var queryUrl = "incidents";
var token = await getToken();
var data = JSON.stringify({
"title": "insertion test case",
"caseorigincode": 3,
"customerid_contact@odata.bind": "/contacts(" + contactid + ")",
"pinswg_appealcasetype": appealTypeId,
"pinswg_AssociatedLPA@odata.bind": "/accounts(" + lpaID + ")",
});
var config = {
method: "post",
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 }) => {
console.log(data);
res.status(200).json(data);
})
.catch(({ err }) => {
res.status(400).json(err);
});
return apiResponse;
}
@@ -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 token = await getToken();
var data = JSON.stringify(req.body);
var queryUrl = "pinswg_watchlists";
var config = {
method: "post",
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",
},
data: data,
};
return axios(config)
.then(({ data }) => {
res.status(200).json(data);
})
.catch(({ err }) => {
res.status(400).json(err);
});
}
@@ -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 myRepresentationsID = req.query.myRepresentationsID;
var token = await getToken();
var queryUrl = "pinswg_representationses(" + myRepresentationsID + ")";
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 ");
res.status(200).json(data);
})
.catch(({ err }) => {
res.status(400).json(err);
});
}
@@ -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 watchedCaseID = req.query.watchedCaseID;
var token = await getToken();
var queryUrl = "pinswg_watchlists(" + watchedCaseID + ")";
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 watched case - " + watchedCaseID);
res.status(200).json(data);
})
.catch(({ err }) => {
res.status(400).json(err);
});
}
@@ -0,0 +1,83 @@
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 searchString = req.query.searchstring;
var token = await getToken();
searchString = _.isEmpty(searchString)
? searchString
: JSON.parse(decodeURI(searchString));
var queryString = "";
queryString +=
_.has(searchString, "q") && searchString.q != null
? "(contains(title, '" +
searchString.q +
"') or contains(ticketnumber,'" +
searchString.q +
"'))"
: "";
queryString +=
_.has(searchString, "lpa") && searchString.lpa != null
? (typeof searchString.q == "undefined" ? "" : " and ") +
"_pinswg_associatedlpa_value eq " +
searchString.lpa
: "";
queryString +=
_.has(searchString, "apt") && searchString.apt != null
? (typeof searchString.q == "undefined" &&
typeof searchString.lpa == "undefined"
? ""
: " and ") +
"pinswg_appealcasetype eq " +
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";
var apiResponse = _.isEmpty(searchString)
? res.status(400).json()
: axios
.get(
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
azureHeadersPaged(token.access_token)
)
.then(({ data }) => {
var dataStr;
_.has(data, "@odata.nextLink") == true &&
((dataStr = JSON.stringify(data["@odata.nextLink"])),
(data["@odata.nextLink"] = dataStr.split("/v8.2/")[1]));
res.status(200).json(data);
})
.catch(({ err }) => {
res.status(400).json(err);
});
return apiResponse;
}
@@ -0,0 +1,87 @@
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 searchString = req.query.searchstring;
var pageNumber = req.query.pageNumber;
var token = await getToken();
searchString = _.isEmpty(searchString)
? searchString
: JSON.parse(decodeURI(searchString));
var queryString = "";
queryString +=
_.has(searchString, "q") && searchString.q != null
? "(contains(title, '" +
searchString.q +
"') or contains(ticketnumber,'" +
searchString.q +
"'))"
: "";
queryString +=
_.has(searchString, "lpa") && searchString.lpa != null
? (typeof searchString.q == "undefined" ? "" : " and ") +
"_pinswg_associatedlpa_value eq " +
searchString.lpa
: "";
queryString +=
_.has(searchString, "apt") && searchString.apt != null
? (typeof searchString.q == "undefined" &&
typeof searchString.lpa == "undefined"
? ""
: " and ") +
"pinswg_appealcasetype eq " +
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" +
(typeof pageNumber != "undefined"
? "&$skiptoken=" + ('<cookie pagenumber="' + pageNumber + '" />')
: "");
var apiResponse = _.isEmpty(searchString)
? res.status(400).json()
: axios
.get(
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
azureHeadersPaged(token.access_token)
)
.then(({ data }) => {
var dataStr;
_.has(data, "@odata.nextLink") == true &&
((dataStr = JSON.stringify(data["@odata.nextLink"])),
(data["@odata.nextLink"] = dataStr.split("/v8.2/")[1]));
res.status(200).json(data);
})
.catch(({ err }) => {
res.status(400).json(err);
});
return apiResponse;
}
+45
View File
@@ -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 caseReference = req.query.caseReference;
var updateFormCollection = req.query.updateFormCollection;
var primaryAttribute = req.query.primaryAttribute;
var token = await getToken();
const queryUrl =
updateFormCollection +
"?$count=true&$select=_" +
primaryAttribute +
"s_value&$filter=pinswg_name eq '" +
caseReference +
"'";
return axios
.get(
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
azureHeaders(token.access_token)
)
.then(({ data }) => {
res.status(200).json(data);
})
.catch(({ err }) => {
res.status(400).json(err);
});
}
+50
View File
@@ -0,0 +1,50 @@
import axios from "axios";
import CryptoJS from "crypto-js";
import { getToken, azureHeadersPaged, azureHeaders } from "../../../actions";
/**
* @swagger
* /api/endpoint/getappealtypes_api:
* get:
* description: Returns appeal types
* responses:
* 200:
* description:
*
*/
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 token = await getToken();
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 + queryUrl + hashAPIPath(queryUrl),
azureHeaders(token.access_token)
)
.then(({ data }) => {
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 _ from "lodash";
import { getToken, azureHeaders, 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 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=pinswg_appealcasetype eq 846040011 and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true";
return axios
.get(
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
azureHeadersPaged(token.access_token)
)
.then(({ data }) => {
var dataStr;
_.has(data, "@odata.nextLink") == true &&
((dataStr = JSON.stringify(data["@odata.nextLink"])),
(data["@odata.nextLink"] = dataStr.split("/v8.2/")[1]));
res.status(200).json(data);
})
.catch(({ err }) => {
res.status(400).json(err);
});
}
@@ -0,0 +1,53 @@
import axios from "axios";
import CryptoJS from "crypto-js";
import _ from "lodash";
import { getToken, azureHeadersPaged } from "../../../actions";
import { getSelectQuery } from "../../../actions/selectQueryTypes";
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 caseReference = req.query.caseReference;
var token = await getToken();
var queryUrl =
"pinswg_dnses?$filter=pinswg_name eq '" +
caseReference +
"'&$count=true";
queryUrl = queryUrl + getSelectQuery("pinswg_dnses");
var apiResponse = _.isEmpty(req.query)
? res.status(400).json()
: typeof caseReference != "undefined" && caseReference.length > 0
? axios
.get(
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
azureHeaders(token.access_token)
)
.then(({ data }) => {
res.status(200).json(data);
})
.catch(({ err }) => {
res.status(400).json(err);
})
: res.status(400).json();
return apiResponse;
}
@@ -0,0 +1,57 @@
import axios from "axios";
import CryptoJS from "crypto-js";
import _ from "lodash";
import { getToken, azureHeadersPaged } from "../../../actions";
import { getSelectQuery } from "../../../actions/selectQueryTypes";
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 caseReference = req.query.caseReference;
var token = await getToken();
var queryUrl =
"pinswg_dnses?$filter=pinswg_name eq '" +
caseReference +
"'&$count=true";
queryUrl = queryUrl + getSelectQuery("pinswg_dnses");
var apiResponse = _.isEmpty(req.query)
? res.status(400).json()
: typeof caseReference != "undefined" && caseReference.length > 0
? axios
.get(
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
azureHeadersPaged(token.access_token)
)
.then(({ data }) => {
var dataStr;
_.has(data, "@odata.nextLink") == true &&
((dataStr = JSON.stringify(data["@odata.nextLink"])),
(data["@odata.nextLink"] = dataStr.split("/v8.2/")[1]));
return res.status(200).json(data);
})
.catch(({ err }) => {
res.status(400).json(err);
})
: res.status(400).json();
return apiResponse;
}
@@ -0,0 +1,49 @@
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;
//console.log(hashlink);
return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink;
};
export default async function ApiProxy(req, res) {
var pageNumber = req.query.pageNumber;
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=pinswg_appealcasetype eq 846040011 and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true" +
(typeof pageNumber != "undefined"
? "&$skiptoken=" + '<cookie pagenumber="' + pageNumber + '" />'
: "");
return axios
.get(
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
azureHeadersPaged(token.access_token)
)
.then(({ data }) => {
var dataStr;
_.has(data, "@odata.nextLink") == true &&
((dataStr = JSON.stringify(data["@odata.nextLink"])),
(data["@odata.nextLink"] = dataStr.split("/v8.2/")[1]));
return res.status(200).json(data);
})
.catch(({ err }) => {
res.status(400).json(err);
});
}
+56
View File
@@ -0,0 +1,56 @@
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 searchString = req.query.searchString;
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=(contains(title, '" +
searchString +
"') or contains(ticketnumber, '" +
searchString +
"')) and pinswg_appealcasetype ne null and pinswg_publishtoweb eq true&$orderby=createdon desc&$count=true";
var apiResponse = _.isEmpty(req.query)
? res.status(400).json()
: searchString.length > 0
? axios
.get(
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
azureHeadersPaged(token.access_token)
)
.then(({ data }) => {
var dataStr;
_.has(data, "@odata.nextLink") == true &&
((dataStr = JSON.stringify(data["@odata.nextLink"])),
(data["@odata.nextLink"] = dataStr.split("/v8.2/")[1]));
res.status(200).json(data);
})
.catch(({ err }) => {
res.status(400).json(err);
})
: res.status(400).json();
return apiResponse;
}
@@ -0,0 +1,53 @@
import axios from "axios";
import CryptoJS from "crypto-js";
import { getToken, azureHeaders } from "../../../actions";
import { getSelectQuery } from "../../../actions/selectQueryTypes";
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 appealTypeName = req.query.appealTypeName;
var primaryIdAttribute = req.query.primaryIdAttribute;
var incidentID = req.query.incidentID;
var token = await getToken();
var queryUrl =
appealTypeName +
"?$filter=_" +
primaryIdAttribute +
"s_value eq " +
incidentID +
"&$count=true";
queryUrl = queryUrl + getSelectQuery(appealTypeName);
console.log("query: ", queryUrl, "<<<<end query");
return axios
.get(
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
azureHeaders(token.access_token)
)
.then(({ data }) => {
res.status(200).json(data);
})
.catch(({ err }) => {
res.status(400).json(err);
});
}
@@ -0,0 +1,58 @@
import axios from "axios";
import CryptoJS from "crypto-js";
import _ from "lodash";
import { getToken, azureHeadersPaged } from "../../../actions";
import { getSelectQuery } from "../../../actions/selectQueryTypes";
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 appealTypeName = req.query.appealTypeName;
var primaryIdAttribute = req.query.primaryIdAttribute;
var incidentID = req.query.incidentID;
var token = await getToken();
var queryUrl =
appealTypeName +
"?$filter=_" +
primaryIdAttribute +
"s_value eq " +
incidentID +
"&$count=true";
queryUrl = queryUrl + getSelectQuery(appealTypeName);
console.log("query: ", queryUrl, "<<<<end query");
return axios
.get(
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
azureHeadersPaged(token.access_token)
)
.then(({ data }) => {
var dataStr;
_.has(data, "@odata.nextLink") == true &&
((dataStr = JSON.stringify(data["@odata.nextLink"])),
(data["@odata.nextLink"] = dataStr.split("/v8.2/")[1]));
return res.status(200).json(data);
})
.catch(({ err }) => {
res.status(400).json(err);
});
}
@@ -0,0 +1,58 @@
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 (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink;
};
export default async function ApiProxy(req, res) {
var searchString = req.query.searchString;
var pageNumber = req.query.pageNumber;
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=(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 + '" />'
: "");
var apiResponse =
searchString.length > 0
? axios
.get(
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
azureHeadersPaged(token.access_token)
)
.then(({ data }) => {
var dataStr;
_.has(data, "@odata.nextLink") == true &&
((dataStr = JSON.stringify(data["@odata.nextLink"])),
(data["@odata.nextLink"] =
dataStr.split("/v8.2/")[1]));
res.status(200).json(data);
})
.catch(({ err }) => {
res.status(400).json(err);
})
: res.status(400).json();
return apiResponse;
}
@@ -0,0 +1,47 @@
import axios from "axios";
import CryptoJS from "crypto-js";
import _ from "lodash";
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 emailAddress = req.query.emailAddress;
var token = await getToken();
var queryUrl =
"contacts?$filter=emailaddress1 eq '" +
emailAddress +
"'&$count=true&$select=emailaddress1, contactid";
var apiResponse = _.isEmpty(req.query)
? res.status(400).json()
: typeof emailAddress != "undefined" && emailAddress.length > 0
? axios
.get(
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
azureHeaders(token.access_token)
)
.then(({ data }) => {
res.status(200).json(data);
})
.catch(({ err }) => {
res.status(400).json(err);
})
: res.status(400).json();
return apiResponse;
}
+43
View File
@@ -0,0 +1,43 @@
import axios from "axios";
import CryptoJS from "crypto-js";
import { getToken, azureHeadersPaged, 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 "&hash=" + hashlink;
return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink;
};
export default async function ApiProxy(req, res) {
var whichForm = req.query.whichForm;
var token = await getToken();
var queryUrl =
"systemforms?$select=formid,name,formxml,type,objecttypecode&$filter=(objecttypecode eq 'pinswg_" +
whichForm +
"' and type eq 2)&$count=true&$top=201";
return axios
.get(
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
azureHeaders(token.access_token)
)
.then(({ data }) => {
res.status(200).json(data);
})
.catch(({ err }) => {
res.status(400).json(err);
});
}
+43
View File
@@ -0,0 +1,43 @@
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 parentIncidentid = req.query.parentincidentid;
var token = await getToken();
var queryUrl =
"incidents?$count=true&$filter=_parentcaseid_value eq " +
parentIncidentid +
" and pinswg_appealcasetype ne null and pinswg_publishtoweb eq true &$select=title, incidentid";
return axios
.get(
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
azureHeadersPaged(token.access_token)
)
.then(({ data }) => {
res.status(200).json(data);
})
.catch(({ err }) => {
res.status(400).json(err);
});
}
+55
View File
@@ -0,0 +1,55 @@
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 (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink;
};
export default async function ApiProxy(req, res) {
var emailAddress = req.query.emailAddress;
var pwd = req.query.pwd;
var token = await getToken();
var queryUrl =
"contacts?$filter=emailaddress1 eq '" +
emailAddress +
"' and pinswg_custom_password eq '" +
pwd +
"'&$count=true&$select=emailaddress1,contactid,pinswg_custom_password,yomifullname,firstname,lastname";
console.log(_.isEmpty(req.query));
var apiResponse = _.isEmpty(req.query)
? res.status(400).json()
: typeof emailAddress != "undefined" &&
emailAddress.length > 0 &&
typeof pwd != "undefined" &&
pwd.length > 0
? axios
.get(
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
azureHeadersPaged(token.access_token)
)
.then(({ data }) => {
res.status(200).json(data);
})
.catch(({ err }) => {
res.status(400).json(err);
})
: res.status(400).json();
return apiResponse;
}
+40
View File
@@ -0,0 +1,40 @@
import axios from "axios";
import CryptoJS from "crypto-js";
import { getToken, azureHeadersPaged, 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 "&hash=" + hashlink;
return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink;
};
export default async function ApiProxy(req, res) {
var token = await getToken();
var queryUrl =
"accounts?$count=true&$filter=pinswg_isalocalplanningauthorityaccount eq 846040000&$select=name&$orderby=name asc";
return axios
.get(
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
azureHeaders(token.access_token)
)
.then(({ data }) => {
res.status(200).json(data);
})
.catch(({ err }) => {
res.status(400).json(err);
});
}
@@ -0,0 +1,43 @@
import axios from "axios";
import CryptoJS from "crypto-js";
import { getToken, azureHeadersPaged, 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 "&hash=" + hashlink;
return (queryPath.indexOf("?") > -1 ? "&hash=" : "?hash=") + hashlink;
};
export default async function ApiProxy(req, res) {
var whichForm = req.query.whichForm;
var token = await getToken();
var queryUrl =
"EntityDefinitions(LogicalName='pinswg_" +
whichForm +
"')/Attributes?$count=true&$select=LogicalName,RequiredLevel";
return axios
.get(
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
azureHeaders(token.access_token)
)
.then(({ data }) => {
res.status(200).json(data);
})
.catch(({ err }) => {
res.status(400).json(err);
});
}
+40
View File
@@ -0,0 +1,40 @@
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=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 + queryUrl + hashAPIPath(queryUrl),
azureHeaders(token.access_token)
)
.then(({ data }) => {
res.status(200).json(data);
})
.catch(({ err }) => {
res.status(400).json(err);
});
}
@@ -0,0 +1,40 @@
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 =
"pinswg_representationses?$filter= _pinswg_contact_value eq " +
loggedInUserId +
"&$count=true&$orderby=createdon desc";
return axios
.get(
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
azureHeaders(token.access_token)
)
.then(({ data }) => {
res.status(200).json(data);
})
.catch(({ err }) => {
res.status(400).json(err);
});
}
@@ -0,0 +1,40 @@
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 =
"pinswg_representationses?$filter= _pinswg_contact_value eq " +
loggedInUserId +
"&$count=true&$orderby=createdon desc";
return axios
.get(
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
azureHeaders(token.access_token)
)
.then(({ data }) => {
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 contactid = req.query.contactid;
var token = await getToken();
var queryUrl =
"contacts(" +
contactid +
")?$select=firstname, lastname, emailaddress1, telephone1, company, address1_line1,address1_line2,address1_city, address1_county,address1_postalcode&$count=true";
var apiResponse =
contactid.length > 0
? axios
.get(
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
azureHeaders(token.access_token)
)
.then(({ data }) => {
res.status(200).json(data);
})
.catch(({ err }) => {
res.status(400).json(err);
})
: res.status(400).json();
return apiResponse;
}
+40
View File
@@ -0,0 +1,40 @@
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 whichForm = req.query.whichForm;
var token = await getToken();
var queryUrl =
"EntityDefinitions(LogicalName='pinswg_" +
whichForm +
"')/Attributes/Microsoft.Dynamics.CRM.PicklistAttributeMetadata?$select=LogicalName&$expand=OptionSet,GlobalOptionSet&$count=true";
return axios
.get(
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
azureHeaders(token.access_token)
)
.then(({ data }) => {
res.status(200).json(data);
})
.catch(({ err }) => {
res.status(400).json(err);
});
}
@@ -0,0 +1,42 @@
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 appealType = req.query.appealType;
var caseReference = req.query.caseReference;
var token = await getToken();
var queryUrl =
appealType +
"?$filter=pinswg_name eq '" +
caseReference +
"'&$count=true";
return axios
.get(
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
azureHeaders(token.access_token)
)
.then(({ data }) => {
res.status(200).json(data);
})
.catch(({ err }) => {
res.status(400).json(err);
});
}
@@ -0,0 +1,42 @@
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 appealType = req.query.appealType;
var caseReference = req.query.caseReference;
var token = await getToken();
var queryUrl =
appealType +
"?$filter=pinswg_name eq '" +
caseReference +
"'&$count=true";
return axios
.get(
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
azureHeaders(token.access_token)
)
.then(({ data }) => {
res.status(200).json(data);
})
.catch(({ err }) => {
res.status(400).json(err);
});
}
@@ -0,0 +1,40 @@
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 =
"pinswg_representationses?$filter= _pinswg_case_value eq " +
incidentID +
" and pinswg_publishtoweb eq true&$count=true&$orderby=createdon desc";
return axios
.get(
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
azureHeaders(token.access_token)
)
.then(({ data }) => {
res.status(200).json(data);
})
.catch(({ err }) => {
res.status(400).json(err);
});
}
@@ -0,0 +1,40 @@
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 incidentID = req.query.incidentID;
var token = await getToken();
var queryUrl =
"pinswg_representationses?$filter= _pinswg_case_value eq " +
incidentID +
"&$count=true&$orderby=createdon desc";
return axios
.get(
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
azureHeaders(token.access_token)
)
.then(({ data }) => {
res.status(200).json(data);
})
.catch(({ err }) => {
res.status(400).json(err);
});
}
@@ -0,0 +1,67 @@
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;
};
const encryptDocReference = (documentRef) => {
var hashlink = CryptoJS.HmacSHA256(
"documents/download/" + documentRef,
CryptoJS.enc.Hex.parse(WORDKEY)
);
hashlink = hashlink.toString(CryptoJS.enc.Hex);
var hashStr =
"/api/documents/download/" + documentRef + "?hash=" + hashlink;
return hashStr;
};
export default async function ApiProxy(req, res) {
var incidentID = req.query.incidentid;
var token = await getToken();
var queryUrl =
"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(
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
azureHeadersPaged(token.access_token)
)
.then(({ data }) => {
data.value.forEach(function (element) {
element.pinswg_hashlink = encryptDocReference(
element.pinswg_isharedocumentreference
);
});
var dataStr;
_.has(data, "@odata.nextLink") == true &&
((dataStr = JSON.stringify(data["@odata.nextLink"])),
(data["@odata.nextLink"] = dataStr.split("/v8.2/")[1]));
res.status(200).json(data);
})
.catch(({ err }) => {
res.status(400).json(err);
});
}
@@ -0,0 +1,70 @@
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;
};
const encryptDocReference = (documentRef) => {
var hashlink = CryptoJS.HmacSHA256(
"documents/download/" + documentRef,
CryptoJS.enc.Hex.parse(WORDKEY)
);
hashlink = hashlink.toString(CryptoJS.enc.Hex);
var hashStr =
"/api/documents/download/" + documentRef + "?hash=" + hashlink;
return hashStr;
};
export default async function ApiProxy(req, res) {
var pageNumber = req.query.pageNumber;
var incidentID = req.query.incidentid;
var token = await getToken();
var queryUrl =
"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(
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
azureHeadersPaged(token.access_token)
)
.then(({ data }) => {
data.value.forEach(function (element) {
element.pinswg_hashlink = encryptDocReference(
element.pinswg_isharedocumentreference
);
});
var dataStr;
_.has(data, "@odata.nextLink") == true &&
((dataStr = JSON.stringify(data["@odata.nextLink"])),
(data["@odata.nextLink"] = dataStr.split("/v8.2/")[1]));
return res.status(200).json(data);
})
.catch(({ err }) => {
res.status(400).json(err);
});
}
@@ -0,0 +1,42 @@
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 documentID = req.query.documentid;
var token = await getToken();
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 + queryUrl + hashAPIPath(queryUrl),
azureHeadersPaged(token.access_token)
)
.then(({ data }) => {
res.status(200).json(data);
})
.catch(({ err }) => {
res.status(400).json(err);
});
}
@@ -0,0 +1,47 @@
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 documentID = req.query.documentid;
var pageNumber = req.query.pageNumber;
var token = await getToken();
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;
// +
// (typeof pageNumber != "undefined"
// ? "&$skiptoken=" + ('<cookie pagenumber="' + pageNumber + '" />')
// : "");
return axios
.get(
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
azureHeadersPaged(token.access_token)
)
.then(({ data }) => {
res.status(200).json(data);
})
.catch(({ err }) => {
res.status(400).json(err);
});
}
@@ -0,0 +1,40 @@
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 =
"pinswg_watchlists?$filter= _pinswg_contact_value eq " +
loggedInUserId +
"&$count=true&$orderby=createdon desc";
return axios
.get(
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
azureHeaders(token.access_token)
)
.then(({ data }) => {
res.status(200).json(data);
})
.catch(({ err }) => {
res.status(400).json(err);
});
}
+40
View File
@@ -0,0 +1,40 @@
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 =
"pinswg_watchlists?$filter= _pinswg_contact_value eq " +
loggedInUserId +
"&$count=true&$orderby=createdon desc";
return axios
.get(
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
azureHeaders(token.access_token)
)
.then(({ data }) => {
res.status(200).json(data);
})
.catch(({ err }) => {
res.status(400).json(err);
});
}
@@ -0,0 +1,40 @@
import axios from "axios";
import CryptoJS from "crypto-js";
import { azureHeaders, getToken } 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 =
"pinswg_watchlists?$filter= _pinswg_contact_value eq " +
loggedInUserId +
"&$count=true&$orderby=createdon desc";
return axios
.get(
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
azureHeaders(token.access_token)
)
.then(({ data }) => {
res.status(200).json(data);
})
.catch(({ err }) => {
res.status(400).json(err);
});
}
+50
View File
@@ -0,0 +1,50 @@
import axios from "axios";
import CryptoJS from "crypto-js";
import { getToken } 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 contactId = req.query.contactId;
var token = await getToken();
var data = JSON.stringify(req.body);
var queryUrl = "contacts(" + contactId + ")";
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="*"',
"Authorization": "Bearer " + token.access_token,
"Content-Type": "application/json",
},
data: data,
};
return axios(config)
.then(({ data }) => {
res.status(200).json(data);
})
.catch(({ err }) => {
res.status(400).json(err);
});
}
+52
View File
@@ -0,0 +1,52 @@
import axios from "axios";
import CryptoJS from "crypto-js";
import { getToken } 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 data = JSON.stringify(req.body);
var appealObj = rea.query.appealObj;
var updateFormCollection = req.query.updateFormCollection;
var queryUrl = updateFormCollection + "(" + appealObj + ")";
var token = await getToken();
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="*"',
"Authorization": "Bearer " + token.access_token,
"Content-Type": "application/json",
},
data: data,
};
return axios(config)
.then(({ data }) => {
res.status(200).json(data);
})
.catch(({ err }) => {
res.status(400).json(err);
});
}
+50
View File
@@ -0,0 +1,50 @@
import axios from "axios";
import CryptoJS from "crypto-js";
import { getToken } 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 contactId = req.query.contactId;
var token = await getToken();
var data = JSON.stringify(req.body);
var queryUrl = "contacts(" + contactId + ")";
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="*"',
"Authorization": "Bearer " + token.access_token,
"Content-Type": "application/json",
},
data: data,
};
return axios(config)
.then(({ data }) => {
res.status(200).json(data);
})
.catch(({ err }) => {
res.status(400).json(err);
});
}