1418 lines
36 KiB
JavaScript
1418 lines
36 KiB
JavaScript
import axios from "axios";
|
|
import https from "https";
|
|
import CryptoJS from "crypto-js";
|
|
import HmacSHA256 from "crypto-js/hmac-sha256";
|
|
import { getFormCollection } from "../components/utils";
|
|
import { downloadFile, getCaseBlob } from "./azurestorage";
|
|
|
|
let BASE_URL;
|
|
const port = parseInt(process.env.PORT, 10) || 3000;
|
|
|
|
if (process.browser) {
|
|
BASE_URL = window.apiRoot;
|
|
} else {
|
|
BASE_URL = process.env.API_ROOT || `http://localhost:${port}`;
|
|
}
|
|
const WORDKEY = process.env.HASHKEY;
|
|
|
|
const cache = {};
|
|
const API_PATH = "/api/data/v8.2/";
|
|
|
|
const accessTokenEndpoint = process.env.ACCESS_TOKEN_ENDPOINT;
|
|
const tenantId = process.env.TENANT;
|
|
|
|
const WEBAPI_URL =
|
|
process.env.RELAY_ROOT ||
|
|
"https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/";
|
|
|
|
export const consoleLogger = (err) => {
|
|
var errStr =
|
|
"\n\n/////////////////////////////////////////////////\nServer Error " +
|
|
"\n" +
|
|
err.response.status +
|
|
" : " +
|
|
err.response.statusText +
|
|
"\nRequest URL: " +
|
|
err.response.config.url +
|
|
"\nRequest Time: " +
|
|
err.response.headers.date +
|
|
"\n/////////////////////////////////////////////////\n\n";
|
|
return errStr;
|
|
};
|
|
|
|
export const getToken = () => {
|
|
return axios
|
|
.post(
|
|
`${accessTokenEndpoint}${tenantId}/oauth2/v2.0/token`,
|
|
tokenBody,
|
|
tokenConfig
|
|
)
|
|
.then((res) => res.data)
|
|
.then((data) => {
|
|
cache.tokenResponse = data;
|
|
return data;
|
|
})
|
|
.catch((error) => {
|
|
//console.log("error :", error.response);
|
|
consoleLogger(error);
|
|
return error;
|
|
});
|
|
};
|
|
|
|
const tokenBody =
|
|
"grant_type=" +
|
|
process.env.GRANT_TYPE +
|
|
"&client_id=" +
|
|
process.env.CLIENT_ID +
|
|
"&client_secret=" +
|
|
process.env.CLIENT_SECRET +
|
|
"&scope=" +
|
|
"https://" +
|
|
process.env.RELAYURI +
|
|
"/.default";
|
|
|
|
const tokenConfig = {
|
|
headers: {
|
|
"Content-Type": "application/x-www-form-urlencoded",
|
|
"Cache-Control": "no-cache",
|
|
},
|
|
};
|
|
|
|
export const azureHeaders = (access_token) => {
|
|
return {
|
|
headers: {
|
|
"OData-MaxVersion": "4.0",
|
|
"OData-Version": "4.0",
|
|
"Accept": "application/json;odata.metadata=none",
|
|
"Prefer": 'odata.include-annotations="*",return=representation',
|
|
"Content-Type": "application/json",
|
|
"Authorization": "Bearer " + access_token,
|
|
},
|
|
};
|
|
};
|
|
|
|
export const azureHeadersNoOdata = (access_token) => {
|
|
return {
|
|
headers: {
|
|
//"OData-MaxVersion": "4.0",
|
|
//"OData-Version": "4.0",
|
|
//"Accept": "application/json;odata.metadata=none",
|
|
//"Prefer": 'odata.include-annotations="*",return=representation',
|
|
"Content-Type": "application/json",
|
|
"Authorization": "Bearer " + access_token,
|
|
},
|
|
};
|
|
};
|
|
|
|
export const azureHeadersPaged = (access_token) => {
|
|
return {
|
|
headers: {
|
|
"OData-MaxVersion": "4.0",
|
|
"OData-Version": "4.0",
|
|
"Accept": "application/json;odata.metadata=none",
|
|
"Prefer":
|
|
'odata.include-annotations="*",return=representation, odata.maxpagesize=10',
|
|
"Content-Type": "application/json",
|
|
"Authorization": "Bearer " + access_token,
|
|
},
|
|
};
|
|
};
|
|
export const azureHeadersPagedCustom = (access_token, showNumberOfRecords) => {
|
|
return {
|
|
headers: {
|
|
"OData-MaxVersion": "4.0",
|
|
"OData-Version": "4.0",
|
|
"Accept": "application/json;odata.metadata=none",
|
|
"Prefer":
|
|
'odata.include-annotations="*",return=representation, odata.maxpagesize=' +
|
|
showNumberOfRecords,
|
|
"Content-Type": "application/json",
|
|
"Authorization": "Bearer " + access_token,
|
|
},
|
|
};
|
|
};
|
|
|
|
export 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 const hashString = (stringToHash) => {
|
|
//console.log("string to hash", stringToHash);
|
|
let hashedStr = CryptoJS.AES.encrypt(stringToHash, "pedw");
|
|
//console.log("hashed String", hashedStr.toString());
|
|
return hashedStr.toString();
|
|
};
|
|
|
|
export const dehashString = (stringToDeHash) => {
|
|
//console.log("string to dehash", stringToDeHash);
|
|
let dehashedStr = CryptoJS.AES.decrypt(decodeURI(stringToDeHash), "pedw");
|
|
//console.log("dehshed string:", dehashedStr.toString(CryptoJS.enc.Utf8));
|
|
return dehashedStr.toString(CryptoJS.enc.Utf8);
|
|
};
|
|
|
|
export const getBasicSearch = (searchString) => {
|
|
return axios
|
|
.get(
|
|
BASE_URL +
|
|
"/api/endpoint/getbasicsearch_api?searchString=" +
|
|
searchString
|
|
)
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
//console.log(error);
|
|
return error.response;
|
|
});
|
|
};
|
|
|
|
export const getPartSavedAppeal = (searchString) => {
|
|
return axios
|
|
.get(
|
|
BASE_URL +
|
|
"/api/endpoint/getpartsavedappeal_api?searchString=" +
|
|
searchString
|
|
)
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
//console.log(error);
|
|
return error.response;
|
|
});
|
|
};
|
|
|
|
export const getBasicDNSURLSearch = (searchString) => {
|
|
return axios
|
|
.get(
|
|
BASE_URL +
|
|
"/api/endpoint/getbasicdnsurlsearch_api?searchString=" +
|
|
searchString
|
|
)
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
//console.log(error);
|
|
return error.response;
|
|
});
|
|
};
|
|
|
|
export const getBasicSearchPaged = (
|
|
searchString,
|
|
pageNumber,
|
|
orderBy,
|
|
fieldSort,
|
|
showNumberOfRecords
|
|
) => {
|
|
//console.log(queryUrl);
|
|
return axios
|
|
.get(
|
|
"/api/endpoint/getbasicsearchpaged_api?searchString=" +
|
|
searchString +
|
|
"&pageNumber=" +
|
|
pageNumber +
|
|
"&orderby=" +
|
|
orderBy +
|
|
"&fieldSort=" +
|
|
fieldSort +
|
|
"&showNumberOfRecords=" +
|
|
showNumberOfRecords
|
|
)
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
return error.response;
|
|
});
|
|
};
|
|
|
|
export const getDNSCoords = () => {
|
|
return axios
|
|
.get(BASE_URL + "/api/endpoint/getdnscoords_api")
|
|
.then((res) => {
|
|
//console.log(res.data);
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
let ErrResponse = {
|
|
value: [],
|
|
errorCode: error.response.status,
|
|
errorMsg: error.response.statusText,
|
|
};
|
|
|
|
return ErrResponse;
|
|
});
|
|
};
|
|
|
|
export const getDNSList = (searchString) => {
|
|
return axios
|
|
.get(BASE_URL + "/api/endpoint/getdnslist_api")
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
return error.response;
|
|
});
|
|
};
|
|
|
|
export const getBasicDNSSearch = (searchString) => {
|
|
return axios
|
|
.get(BASE_URL + "/api/endpoint/getbasicdnssearch_api")
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
return error.response;
|
|
});
|
|
};
|
|
|
|
export const getBasicDNSSearchPaged = (
|
|
pageNumber,
|
|
orderBy,
|
|
fieldSort,
|
|
showNumberOfRecords
|
|
) => {
|
|
return axios
|
|
.get(
|
|
"/api/endpoint/getbasicdnssearchpaged_api?pageNumber=" +
|
|
pageNumber +
|
|
"&orderby=" +
|
|
orderBy +
|
|
"&fieldSort=" +
|
|
fieldSort +
|
|
"&showNumberOfRecords=" +
|
|
showNumberOfRecords
|
|
)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
return error.response;
|
|
});
|
|
};
|
|
|
|
export const getAdvancedSearch = (searchString) => {
|
|
return axios
|
|
.get(
|
|
BASE_URL +
|
|
"/api/endpoint/getadvancedsearch_api?searchstring=" +
|
|
JSON.stringify(searchString)
|
|
)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
let ErrResponse = {
|
|
value: [],
|
|
errorCode: error.response.status,
|
|
errorMsg: error.response.statusText,
|
|
};
|
|
|
|
return ErrResponse;
|
|
});
|
|
};
|
|
|
|
export const getAdvancedSearchPaged = (
|
|
searchString,
|
|
pageNumber,
|
|
orderBy,
|
|
fieldSort,
|
|
showNumberOfRecords
|
|
) => {
|
|
return axios
|
|
.get(
|
|
"/api/endpoint/getadvancedsearchpaged_api?searchstring=" +
|
|
JSON.stringify(searchString) +
|
|
"&pageNumber=" +
|
|
pageNumber +
|
|
"&orderby=" +
|
|
orderBy +
|
|
"&fieldSort=" +
|
|
fieldSort +
|
|
"&showNumberOfRecords=" +
|
|
showNumberOfRecords
|
|
)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
let ErrResponse = {
|
|
value: [],
|
|
errorCode: error.response.status,
|
|
errorMsg: error.response.statusText,
|
|
};
|
|
|
|
return ErrResponse;
|
|
});
|
|
};
|
|
|
|
export const getBasicSearchDetails = (
|
|
appealTypeName,
|
|
caseReference,
|
|
primaryIdAttribute,
|
|
incidentID
|
|
) => {
|
|
return axios
|
|
.get(
|
|
BASE_URL +
|
|
"/api/endpoint/getbasicsearchdetails_api?appealTypeName=" +
|
|
appealTypeName +
|
|
"&primaryIdAttribute=" +
|
|
primaryIdAttribute +
|
|
"&incidentID=" +
|
|
incidentID
|
|
)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
console.log("this error", error);
|
|
});
|
|
};
|
|
|
|
export const getBasicPartSavedDetails = (
|
|
appealTypeName,
|
|
caseReference,
|
|
primaryIdAttribute,
|
|
incidentID
|
|
) => {
|
|
// console.log(
|
|
// "///////api call: ",
|
|
// BASE_URL +
|
|
// "/api/endpoint/getbasicpartsaveddetails_api?appealTypeName=" +
|
|
// appealTypeName +
|
|
// "&primaryIdAttribute=" +
|
|
// primaryIdAttribute +
|
|
// "&incidentID=" +
|
|
// incidentID
|
|
// );
|
|
return axios
|
|
.get(
|
|
BASE_URL +
|
|
"/api/endpoint/getbasicpartsaveddetails_api?appealTypeName=" +
|
|
appealTypeName +
|
|
"&primaryIdAttribute=" +
|
|
primaryIdAttribute +
|
|
"&incidentID=" +
|
|
incidentID
|
|
)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
console.log("this error", error);
|
|
});
|
|
};
|
|
|
|
export const getBasicSearchDetailsPaged = (
|
|
appealTypeName,
|
|
caseReference,
|
|
primaryIdAttribute,
|
|
incidentID
|
|
) => {
|
|
//console.log("check appealtype:", appealType, caseReference);
|
|
|
|
return axios
|
|
.get(
|
|
"/api/endpoint/getbasicsearchdetailspaged_api?appealTypeName=" +
|
|
appealTypeName +
|
|
"&primaryIdAttribute=" +
|
|
primaryIdAttribute +
|
|
"&incidentID=" +
|
|
incidentID
|
|
)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
console.log("this error", error);
|
|
});
|
|
};
|
|
|
|
export const getSearchDocumentDetails = (incidentID) => {
|
|
return axios
|
|
.get(
|
|
"/api/endpoint/getsearchdocumentdetails_api?incidentid=" +
|
|
incidentID
|
|
)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
//console.log("API call error", error);
|
|
});
|
|
};
|
|
|
|
export const getSearchDocumentTypes = (incidentID) => {
|
|
return axios
|
|
.get(
|
|
"/api/endpoint/getsearchdocumentTypes_api?incidentid=" + incidentID
|
|
)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
//console.log("API call error", error);
|
|
});
|
|
};
|
|
|
|
export const getSearchDocumentDetailsPaged = (
|
|
incidentID,
|
|
pageNumber,
|
|
orderBy,
|
|
fieldSort,
|
|
showNumberOfRecords,
|
|
documentType
|
|
) => {
|
|
//console.log("to api:", documentType);
|
|
return axios
|
|
.get(
|
|
"/api/endpoint/getsearchdocumentdetailspaged_api?incidentid=" +
|
|
incidentID +
|
|
"&pageNumber=" +
|
|
pageNumber +
|
|
"&orderby=" +
|
|
orderBy +
|
|
"&fieldSort=" +
|
|
fieldSort +
|
|
"&showNumberOfRecords=" +
|
|
showNumberOfRecords +
|
|
"&documentType=" +
|
|
documentType
|
|
)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
//console.log("API call error", error);
|
|
});
|
|
};
|
|
|
|
export const getLinkedCases = (parentIncidentid) => {
|
|
return axios
|
|
.get(
|
|
"/api/endpoint/getlinkedcases_api?parentincidentid=" +
|
|
parentIncidentid
|
|
)
|
|
.then((res) => {
|
|
//console.log(" linked date", res.data);
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
//console.log("API call error", error);
|
|
});
|
|
};
|
|
|
|
export const getAppealsTypes = () => {
|
|
return axios
|
|
.get(BASE_URL + "/api/endpoint/getappealtypes_api")
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
//console.log(error);
|
|
let ErrResponse = {
|
|
value: [],
|
|
errorCode: error.response.status,
|
|
errorMsg: error.response.statusText,
|
|
};
|
|
|
|
return ErrResponse;
|
|
});
|
|
};
|
|
|
|
export const getAppealsTypesForNewAppeal = () => {
|
|
return axios
|
|
.get(BASE_URL + "/api/endpoint/getappealtypesfornewappeal_api")
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
//console.log(error);
|
|
let ErrResponse = {
|
|
value: [],
|
|
errorCode: error.response.status,
|
|
errorMsg: error.response.statusText,
|
|
};
|
|
|
|
return ErrResponse;
|
|
});
|
|
};
|
|
|
|
export const getLPA = () => {
|
|
return axios
|
|
.get(BASE_URL + "/api/endpoint/getlpa_api")
|
|
.then((res) => {
|
|
//console.log(res.data);
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
let ErrResponse = {
|
|
value: [],
|
|
errorCode: error.response.status,
|
|
errorMsg: error.response.statusText,
|
|
};
|
|
|
|
return ErrResponse;
|
|
});
|
|
};
|
|
|
|
// iteration 2 methods
|
|
|
|
export const getFormData = (whichForm) => {
|
|
return axios
|
|
.get(BASE_URL + "/api/endpoint/getformdata_api?whichForm=" + whichForm)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
//console.log("API call error", error);
|
|
});
|
|
};
|
|
|
|
export const getMandatoryFields = (whichForm) => {
|
|
return axios
|
|
.get(
|
|
BASE_URL +
|
|
"/api/endpoint/getmandatoryfields_api?whichForm=" +
|
|
whichForm
|
|
)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
//console.log("API call error", error);
|
|
});
|
|
};
|
|
|
|
export const getPickLists = (whichForm) => {
|
|
return axios
|
|
.get(BASE_URL + "/api/endpoint/getpicklists_api?whichForm=" + whichForm)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
//console.log("API call error", error);
|
|
});
|
|
};
|
|
|
|
export const getPersonalAccount = (contactid) => {
|
|
//console.log(contactid);
|
|
return axios
|
|
.get(
|
|
BASE_URL +
|
|
"/api/endpoint/getpersonalaccount_api?contactid=" +
|
|
contactid
|
|
)
|
|
.then((res) => {
|
|
//console.log(res.data);
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
//console.log("returned:", error);
|
|
// let ErrResponse = {
|
|
// value: [],
|
|
// errorCode: error.response.status,
|
|
// errorMsg: error.response.statusText,
|
|
// };
|
|
// return ErrResponse;
|
|
});
|
|
};
|
|
|
|
export const getAppealID = (
|
|
caseReference,
|
|
updateFormCollection,
|
|
primaryAttribute
|
|
) => {
|
|
// console.log(
|
|
// "is this the collection?:",
|
|
// getFormCollection(updateFormCollection)
|
|
// )
|
|
|
|
//let formCollectionName = getFormCollection(updateFormCollection);
|
|
//console.log(formCollectionName);
|
|
return axios
|
|
.get(
|
|
"/api/endpoint/getappealid_api?updateFormCollection=" +
|
|
updateFormCollection +
|
|
"&primaryAttribute=" +
|
|
primaryAttribute +
|
|
"&caseReference=" +
|
|
caseReference
|
|
)
|
|
.then((res) => {
|
|
const result = Object.entries(res.data.value[0]).filter(
|
|
([key]) => !key.startsWith("_")
|
|
)[0][1];
|
|
console.log("result:", res.data);
|
|
var appealID = result;
|
|
return appealID;
|
|
})
|
|
.catch((error) => {
|
|
console.log("API call error", error);
|
|
});
|
|
};
|
|
|
|
export const getLogin = (emailAddress, pwd) => {
|
|
return axios
|
|
.get(
|
|
"/api/endpoint/getlogin_api?emailAddress=" +
|
|
emailAddress +
|
|
"&pwd=" +
|
|
pwd
|
|
)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
//console.log("API call error", error);
|
|
});
|
|
};
|
|
|
|
export const getMyCases = (loggedInUserId) => {
|
|
return axios
|
|
.get(
|
|
BASE_URL +
|
|
"/api/endpoint/getmycases_api?loggedInUserId=" +
|
|
loggedInUserId
|
|
)
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
//console.log("API call error", error);
|
|
});
|
|
};
|
|
|
|
export const getMyRepresentations = (loggedInUserId) => {
|
|
return axios
|
|
.get(
|
|
BASE_URL +
|
|
"/api/endpoint/getmyrepresentations_api?loggedInUserId=" +
|
|
loggedInUserId
|
|
)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
console.log("this serror", error);
|
|
});
|
|
};
|
|
|
|
export const getMyRepresentationsProxy = (loggedInUserId) => {
|
|
return axios
|
|
.get(
|
|
BASE_URL +
|
|
"/api/endpoint/getmyrepresentationsproxy_api?loggedInUserId=" +
|
|
loggedInUserId
|
|
)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
console.log("this serror", error);
|
|
});
|
|
};
|
|
|
|
export const getRepresentations = (incidentID) => {
|
|
return axios
|
|
.get("/api/endpoint/getrepresentations_api?incidentID=" + incidentID)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
console.log("this serror", error);
|
|
});
|
|
};
|
|
|
|
export const getRepresentationsProxy = (incidentID) => {
|
|
return axios
|
|
.get(
|
|
BASE_URL +
|
|
"/api/endpoint/getrepresentationsproxy_api?incidentID=" +
|
|
incidentID
|
|
)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
console.log("this serror", error);
|
|
});
|
|
};
|
|
|
|
export const getWatchedCases = (loggedInUserId) => {
|
|
return axios
|
|
.get(
|
|
BASE_URL +
|
|
"/api/endpoint/getwatchedcases_api?loggedInUserId=" +
|
|
loggedInUserId
|
|
)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
console.log("this serror", error);
|
|
});
|
|
};
|
|
|
|
export const getWatchedCasesProxy = (loggedInUserId) => {
|
|
return axios
|
|
.get(
|
|
BASE_URL +
|
|
"/api/endpoint/getwatchedcasesproxy_api?loggedInUserId=" +
|
|
loggedInUserId
|
|
)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
console.log("this serror", error);
|
|
});
|
|
};
|
|
|
|
export const getAwaitingSubmissionProxy = (loggedInUserId) => {
|
|
return axios
|
|
.get(
|
|
BASE_URL +
|
|
"/api/endpoint/getawaitingsubmissionproxy_api?loggedInUserId=" +
|
|
loggedInUserId
|
|
)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
//console.log("API call error", error);
|
|
});
|
|
};
|
|
|
|
export const getAwaitingSubmission = (loggedInUserId) => {
|
|
return axios
|
|
.get(
|
|
BASE_URL +
|
|
"/api/endpoint/getawaitingsubmission_api?loggedInUserId=" +
|
|
loggedInUserId
|
|
)
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
//console.log("API call error", error);
|
|
});
|
|
};
|
|
|
|
export const getAwaitingSubmissionFromBlob = (containerName) => {
|
|
console.log(
|
|
"///////////////////////\ngetAwaitingSubmissionFromBlob: " +
|
|
containerName +
|
|
"\n///////////////////////\n"
|
|
);
|
|
return axios
|
|
.get(
|
|
BASE_URL +
|
|
"/api/file/getawaitingsubmissionfromblob?container=" +
|
|
containerName +
|
|
hashAPIPath(
|
|
"/api/file/getawaitingsubmissionfromblob?container=" +
|
|
containerName
|
|
)
|
|
)
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
//console.log("API call error", error);
|
|
});
|
|
};
|
|
|
|
export const getAwaitingSubmissionFromBlobProxy = (containerName) => {
|
|
return axios
|
|
.get(
|
|
BASE_URL +
|
|
"/api/file/getawaitingsubmissionfromblob?container=" +
|
|
containerName
|
|
)
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
//console.log("API call error", error);
|
|
});
|
|
};
|
|
|
|
export const getPortalModuleDetails = (appealType, caseReference) => {
|
|
//console.log(
|
|
// BASE_URL +
|
|
// "/api/endpoint/getportalmoduledetails_api?appealType=" +
|
|
// appealType +
|
|
// "&caseReference=" +
|
|
// encodeURI(caseReference)
|
|
// );
|
|
return axios
|
|
.get(
|
|
BASE_URL +
|
|
"/api/endpoint/getportalmoduledetails_api?appealType=" +
|
|
appealType +
|
|
"&caseReference=" +
|
|
encodeURI(caseReference)
|
|
)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
//console.log("API call error", error);
|
|
});
|
|
};
|
|
|
|
export const getPortalModuleDetailsProxy = (appealType, caseReference) => {
|
|
return axios
|
|
.get(
|
|
BASE_URL +
|
|
"/api/endpoint/getportalmoduledetailsproxy_api?appealType=" +
|
|
appealType +
|
|
"&caseReference=" +
|
|
caseReference
|
|
)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
//console.log("API call error", error);
|
|
});
|
|
};
|
|
|
|
export const getEmailAccountCheck = (emailAddress) => {
|
|
return axios
|
|
.get(
|
|
BASE_URL +
|
|
"/api/endpoint/getemailaccountcheck_api?emailAddress=" +
|
|
emailAddress
|
|
)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
//console.log("API call error", error);
|
|
});
|
|
};
|
|
|
|
//uses more than get methods
|
|
|
|
export const updatePassword = (contactId, newpassword) => {
|
|
var queryUrl = "/api/endpoint/updateaccount_api?contactId=" + contactId;
|
|
var data = { "pinswg_custom_password": newpassword };
|
|
var config = {
|
|
method: "post",
|
|
url: queryUrl,
|
|
data: data,
|
|
};
|
|
|
|
return axios(config)
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
console.log("this serror", error);
|
|
});
|
|
};
|
|
|
|
export const updateAccount = async (contactId, updateBody) => {
|
|
var queryUrl = "/api/endpoint/updateaccount_api?contactId=" + contactId;
|
|
var data = updateBody;
|
|
var config = {
|
|
method: "post",
|
|
url: queryUrl,
|
|
data: data,
|
|
};
|
|
return axios(config)
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
//console.log("this error:", error);
|
|
});
|
|
};
|
|
|
|
export const createWatchedCases = (formValues) => {
|
|
var data = formValues;
|
|
var queryUrl = window.apiRoot + "/api/endpoint/createwatchedcases_api";
|
|
|
|
var config = {
|
|
method: "post",
|
|
url: queryUrl,
|
|
data: data,
|
|
};
|
|
|
|
return axios(config)
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
console.log("this serror", error);
|
|
});
|
|
};
|
|
|
|
export const createNewCase = (
|
|
appealTypeId,
|
|
lpaID,
|
|
contactid,
|
|
createBody,
|
|
containerName
|
|
) => {
|
|
appealTypeId = parseInt(appealTypeId);
|
|
|
|
var data = createBody;
|
|
|
|
var queryUrl =
|
|
"/api/endpoint/createcase_api?appealTypeId=" +
|
|
appealTypeId +
|
|
"&lpaID=" +
|
|
lpaID +
|
|
"&contactid=" +
|
|
contactid +
|
|
"&containername=" +
|
|
containerName;
|
|
|
|
var config = {
|
|
method: "post",
|
|
url: BASE_URL + queryUrl,
|
|
data: data,
|
|
};
|
|
|
|
return axios(config)
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
console.log("this serror", error);
|
|
});
|
|
};
|
|
|
|
export const createNewCaseBlob = (
|
|
appealTypeId,
|
|
lpaID,
|
|
contactid,
|
|
createBody,
|
|
containerName,
|
|
lpaName
|
|
) => {
|
|
appealTypeId = parseInt(appealTypeId);
|
|
|
|
var data = createBody;
|
|
|
|
data.pinswg_lpaname = lpaName;
|
|
data.createdon = new Date();
|
|
|
|
var queryUrl =
|
|
"/api/file/createcase_api?appealTypeId=" +
|
|
appealTypeId +
|
|
"&lpaID=" +
|
|
lpaID +
|
|
"&contactid=" +
|
|
contactid +
|
|
"&containername=" +
|
|
containerName;
|
|
|
|
var config = {
|
|
method: "post",
|
|
url: queryUrl,
|
|
data: data,
|
|
};
|
|
|
|
console.log("the query url for crearte csase:", queryUrl);
|
|
|
|
return axios(config)
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
console.log("this serror", error);
|
|
});
|
|
};
|
|
|
|
export const updateCase = async (
|
|
incidentId,
|
|
updateBody,
|
|
updateFormCollection,
|
|
primaryAttribute,
|
|
caseReference
|
|
) => {
|
|
var data = updateBody;
|
|
|
|
var appealObj = await getAppealID(
|
|
caseReference,
|
|
updateFormCollection,
|
|
primaryAttribute
|
|
);
|
|
|
|
var queryUrl =
|
|
"/api/endpoint/updatecase_api?updateFormCollection=" +
|
|
updateFormCollection +
|
|
"&appealObj=" +
|
|
appealObj;
|
|
|
|
var config = {
|
|
method: "post",
|
|
url: queryUrl,
|
|
data: updateBody,
|
|
};
|
|
|
|
//console.log(data);
|
|
|
|
return axios(config)
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
//console.log("API call error", error);
|
|
});
|
|
};
|
|
|
|
export const updateCaseBlob = async (
|
|
incidentId,
|
|
updateBody,
|
|
updateFormCollection,
|
|
primaryAttribute,
|
|
caseReference
|
|
) => {
|
|
var data = updateBody;
|
|
|
|
var appealObj = await getAppealID(
|
|
caseReference,
|
|
updateFormCollection,
|
|
primaryAttribute
|
|
);
|
|
|
|
var queryUrl =
|
|
"/api/file/updatecase_api?updateFormCollection=" +
|
|
updateFormCollection +
|
|
"&appealObj=" +
|
|
appealObj;
|
|
|
|
var config = {
|
|
method: "post",
|
|
url: queryUrl,
|
|
data: updateBody,
|
|
};
|
|
|
|
//console.log(data);
|
|
|
|
return axios(config)
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
//console.log("API call error", error);
|
|
});
|
|
};
|
|
|
|
export const patchCase = async (incidentid) => {
|
|
var queryUrl = "/api/endpoint/patchcase_api?incidentid=" + incidentid;
|
|
var config = {
|
|
method: "get",
|
|
url: queryUrl,
|
|
};
|
|
|
|
return axios(config)
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
//console.log("this error:", error);
|
|
});
|
|
};
|
|
|
|
export const getCase = (incidentID) => {
|
|
// console.log(
|
|
// "////////////// ------" +
|
|
// BASE_URL +
|
|
// "/api/endpoint/getcase_api?incidentID=" +
|
|
// incidentID
|
|
// );
|
|
return axios
|
|
.get(BASE_URL + "/api/endpoint/getcase_api?incidentID=" + incidentID)
|
|
.then((res) => {
|
|
//console.log("//////////----", res.data);
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
console.log("this serror", error);
|
|
});
|
|
};
|
|
|
|
export const deleteMyRepresentations = (myRepresentationsID) => {
|
|
var queryUrl =
|
|
"/api/endpoint/deletemyrepresentations_api?myRepresentationsID=" +
|
|
myRepresentationsID;
|
|
|
|
var config = {
|
|
method: "delete",
|
|
url: queryUrl + hashAPIPath(queryUrl),
|
|
headers: {
|
|
"OData-MaxVersion": "4.0",
|
|
"OData-Version": "4.0",
|
|
"Accept": "application/json;odata.metadata=none",
|
|
"Prefer": 'odata.include-annotations="*",return=representation',
|
|
"Content-Type": "application/json",
|
|
},
|
|
};
|
|
//console.log(config);
|
|
return axios(config)
|
|
.then((res) => {
|
|
//console.log("deleted ", res.data);
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
console.log("this serror", error);
|
|
});
|
|
};
|
|
|
|
export const deleteAwaitingSubmissions = (incidentID) => {
|
|
var queryUrl =
|
|
"/api/endpoint/deleteawaitingsubmissions_api?incidentID=" + incidentID;
|
|
|
|
var config = {
|
|
method: "delete",
|
|
url: queryUrl,
|
|
};
|
|
//console.log(config);
|
|
return axios(config)
|
|
.then((res) => {
|
|
//console.log("deleted ", res.data);
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
console.log("this serror", error);
|
|
});
|
|
};
|
|
|
|
export const deleteAwaitingSubmissionsFromBlob = (
|
|
containerID,
|
|
casefolderID
|
|
) => {
|
|
var queryUrl =
|
|
"/api/file/deleteblobcase?container=" +
|
|
containerID +
|
|
"&casefolderID=" +
|
|
casefolderID;
|
|
|
|
var config = {
|
|
method: "get",
|
|
url: queryUrl,
|
|
};
|
|
//console.log(config);
|
|
return axios(config)
|
|
.then((res) => {
|
|
//console.log("deleted ", res.data);
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
console.log("this serror", error);
|
|
});
|
|
};
|
|
|
|
export const deleteWatchedCases = (watchedCaseID) => {
|
|
var queryUrl =
|
|
"/api/endpoint/deletewatchedcases_api?watchedCaseID=" + watchedCaseID;
|
|
var config = {
|
|
method: "delete",
|
|
url: queryUrl,
|
|
};
|
|
|
|
return axios(config)
|
|
.then((res) => {
|
|
//console.log("deleted ", res.data);
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
console.log("this serror", error);
|
|
});
|
|
};
|
|
|
|
export const createAccount = (formValues) => {
|
|
var data = formValues;
|
|
var queryUrl = "/api/endpoint/createaccount_api";
|
|
var config = {
|
|
method: "post",
|
|
url: queryUrl,
|
|
data: data,
|
|
};
|
|
|
|
return axios(config)
|
|
.then((res) => {
|
|
//console.log("posted ", res.data);
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
console.log("this serror", error);
|
|
});
|
|
};
|
|
|
|
export const uploadFiles = async (
|
|
formValues,
|
|
filesObj,
|
|
containerID,
|
|
casefolderID
|
|
) => {
|
|
let files = filesObj;
|
|
|
|
//console.log(formValues);
|
|
var formData = new FormData();
|
|
formData.append("appealData", JSON.stringify(formValues));
|
|
formData.append("containerID", containerID);
|
|
formData.append("casefolderID", casefolderID);
|
|
|
|
// files.forEach((file) => formData.append("files", file));
|
|
|
|
for (let i = 0; i < files.length; i++) {
|
|
for (let j = 0; j < files[i].length; j++) {
|
|
console.log(files[i][j].name);
|
|
formData.append(files[i][j].name, files[i][j]);
|
|
}
|
|
}
|
|
|
|
//console.log(formData);
|
|
|
|
var queryUrl = "/api/file/upload";
|
|
|
|
const config = {
|
|
method: "post",
|
|
url: queryUrl,
|
|
data: formData,
|
|
headers: { "content-type": "multipart/form-data" },
|
|
};
|
|
|
|
//console.log(config);
|
|
try {
|
|
const res = await axios(config);
|
|
return res.data;
|
|
} catch (error) {
|
|
console.log("this serror", error);
|
|
}
|
|
};
|
|
|
|
export const getFilesFromBlob = (containerName, casefolderID) => {
|
|
return axios
|
|
.get(
|
|
BASE_URL +
|
|
"/api/file/getbloblist?container=" +
|
|
containerName +
|
|
"&casefolderID=" +
|
|
casefolderID +
|
|
hashAPIPath(
|
|
"/api/file/getbloblist?container=" +
|
|
containerName +
|
|
"&casefolderID=" +
|
|
casefolderID
|
|
)
|
|
)
|
|
.then((res) => {
|
|
//console.log("//////////----", res.data);
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
console.log("this serror", error);
|
|
});
|
|
};
|
|
|
|
export const getFilesFromBlobHashed = (
|
|
containerName,
|
|
getblobshash,
|
|
casefolderID
|
|
) => {
|
|
return axios
|
|
.get(
|
|
BASE_URL +
|
|
"/api/file/getbloblist?container=" +
|
|
containerName +
|
|
"&casefolderID=" +
|
|
casefolderID +
|
|
getblobshash
|
|
)
|
|
.then((res) => {
|
|
//console.log("//////////----", res.data);
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
console.log("this serror", error);
|
|
});
|
|
};
|
|
|
|
export const deleteBlob = async (
|
|
containerName,
|
|
blobName,
|
|
deleteblobhash,
|
|
casefolderID
|
|
) => {
|
|
try {
|
|
const res = await axios.get(
|
|
BASE_URL +
|
|
"/api/file/deleteblob?container=" +
|
|
containerName +
|
|
"&casefolderID=" +
|
|
casefolderID +
|
|
"&blobname=" +
|
|
blobName +
|
|
deleteblobhash
|
|
);
|
|
return res.data;
|
|
} catch (error) {
|
|
console.log("this serror", error);
|
|
}
|
|
};
|
|
|
|
export const downloadBlob = (containerName, blobName) => {
|
|
return axios
|
|
.get(
|
|
BASE_URL +
|
|
"/api/file/downloadblob?container=" +
|
|
containerName.toLowerCase() +
|
|
"&blobname=" +
|
|
blobName,
|
|
{ responseType: "blob" }
|
|
)
|
|
.then((response) => {
|
|
//console.log("Downloaded blob content:");
|
|
|
|
res.setHeader(
|
|
"content-disposition",
|
|
"attachment; filename=" + blobName
|
|
);
|
|
console.log("has downloaded");
|
|
|
|
return res.status(200).send(response.data);
|
|
})
|
|
.catch((error) => {
|
|
console.log("this serror", error);
|
|
});
|
|
};
|
|
|
|
export const getProgressFromBlob = async (containerName, casereference) => {
|
|
try {
|
|
const res = await axios.get(
|
|
BASE_URL +
|
|
"/api/file/getprogressobjblob?container=" +
|
|
containerName +
|
|
"&casefolderID=" +
|
|
casereference +
|
|
hashAPIPath(
|
|
"/api/file/getprogressobjblob?container=" +
|
|
containerName +
|
|
"&casefolderID=" +
|
|
casereference
|
|
)
|
|
);
|
|
return res.data;
|
|
} catch (error) {
|
|
console.log("this serror", error);
|
|
}
|
|
};
|
|
|
|
export const sendEmail = async (
|
|
emailToAddress,
|
|
emailSubject,
|
|
emailContentTitle,
|
|
emailContent
|
|
) => {
|
|
var mailData = {
|
|
"email": emailToAddress,
|
|
"subject": emailSubject,
|
|
"emailcontenttitle": emailContentTitle,
|
|
"emailcontent": emailContent,
|
|
};
|
|
|
|
var queryUrl = "/api/email";
|
|
|
|
var config = {
|
|
method: "post",
|
|
url: queryUrl,
|
|
data: mailData,
|
|
};
|
|
|
|
return axios(config)
|
|
.then((res) => {
|
|
//console.log("posted ", res.data);
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
console.log("this serror", error);
|
|
});
|
|
};
|
|
|
|
export const getNotice = () => {
|
|
return axios
|
|
.get(BASE_URL + "/api/notices")
|
|
.then((res) => {
|
|
//console.log("//////////----", res.data);
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
console.log("this serror", error);
|
|
});
|
|
};
|
|
|
|
export const getPortalLogin = (emailAddress) => {
|
|
var queryUrl =
|
|
"/api/endpoint/getportallogin_api?emailAddress=" + emailAddress;
|
|
|
|
return axios
|
|
.get(BASE_URL + queryUrl)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
//console.log(consoleLogger(error));
|
|
console.log("thiserror", error);
|
|
return JSON.stringify(error);
|
|
});
|
|
};
|