1907 lines
48 KiB
JavaScript
1907 lines
48 KiB
JavaScript
import axios from "axios";
|
|
import CryptoJS from "crypto-js";
|
|
import _ from "lodash";
|
|
|
|
let BASE_URL;
|
|
const port = parseInt(process.env.PORT, 10) || 3000;
|
|
|
|
if (typeof window !== "undefined") {
|
|
BASE_URL = window.apiRoot;
|
|
} else {
|
|
BASE_URL = process.env.API_ROOT || `http://localhost:${port}`;
|
|
}
|
|
//BASE_URL = process.env.API_ROOT;
|
|
|
|
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 getIP = (req) => {
|
|
const forwarded = req.headers["x-forwarded-for"];
|
|
|
|
const ip =
|
|
typeof forwarded === "string"
|
|
? forwarded.split(/, /)[0]
|
|
: req.socket.remoteAddress;
|
|
|
|
console.info(
|
|
"\n====================\n Client IP address: " + ip,
|
|
"\n=====================\n"
|
|
);
|
|
};
|
|
|
|
export const consoleLogger = (err) => {
|
|
var errStr =
|
|
"\n\n/////////////////////////////////////////////////\nServer Error " +
|
|
"\n" +
|
|
(_.has(err, "name") ? "Name: " + err.name + "\n" : "") +
|
|
(_.has(err, "code") ? "Code: " + err.code + "\n" : "") +
|
|
(_.has(err, "message") ? "Message: " + err.message + "\n" : "") +
|
|
(_.has(err, "request.url")
|
|
? "request.url: " + err.request.url + "\n"
|
|
: "") +
|
|
(_.has(err, "response.status") ? "Status: " + err.code + "\n" : "") +
|
|
(_.has(err, "response.statusText")
|
|
? "\nStatusText: " + err.response.status + "\n"
|
|
: "") +
|
|
(_.has(err, "response.request.socket.remoteAddress")
|
|
? "\nRequest IP: " +
|
|
err.response.request.socket.remoteAddress +
|
|
"\n"
|
|
: "") +
|
|
(_.has(err, "response.data.error.message")
|
|
? "\nMessage: " + err.response.data.error.message + "\n"
|
|
: "") +
|
|
(_.has(err, "response.config.url")
|
|
? "\nRequest URL: " + err.config.url + "\n"
|
|
: "") +
|
|
(_.has(err, "response.headers.date")
|
|
? "\nRequest Time: " + err.response.headers.date + "\n"
|
|
: "") +
|
|
(_.has(err, "config.url")
|
|
? "\nAxios config url: " + err.config.url + "\n"
|
|
: "") +
|
|
(_.has(err, "config.url")
|
|
? "\nAxios message url: " + err.message + "\n"
|
|
: "") +
|
|
"\n/////////////////////////////////////////////////\n\n";
|
|
return errStr;
|
|
};
|
|
|
|
export const conLog = (err) => {
|
|
var errStr =
|
|
"\n\n/////////////////////////////////////////////////\nResponse: " +
|
|
"\n" +
|
|
err +
|
|
"\n/////////////////////////////////////////////////\n\n";
|
|
|
|
console.log(errStr);
|
|
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) => {
|
|
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 getIncidentbyID = (searchString) => {
|
|
return axios
|
|
.get(
|
|
BASE_URL +
|
|
"/api/endpoint/getincidentbyid_api?searchString=" +
|
|
searchString
|
|
)
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
//console.log(error);
|
|
return error.response;
|
|
});
|
|
};
|
|
|
|
export const getIsPublishedbyID = (searchString) => {
|
|
return axios
|
|
.get(
|
|
"/api/endpoint/getispublishedbyid_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 getAddressSearchPaged = (
|
|
searchString,
|
|
pageNumber,
|
|
orderBy,
|
|
fieldSort,
|
|
showNumberOfRecords
|
|
) => {
|
|
return axios
|
|
.get(
|
|
"/api/endpoint/getbasicsearch_by_address_paged_api?searchString=" +
|
|
searchString +
|
|
"&pageNumber=" +
|
|
pageNumber +
|
|
"&orderby=" +
|
|
orderBy +
|
|
"&fieldSort=" +
|
|
fieldSort +
|
|
"&showNumberOfRecords=" +
|
|
showNumberOfRecords
|
|
)
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
return error.response;
|
|
});
|
|
};
|
|
|
|
export const getBasicSearchPaged = (
|
|
searchString,
|
|
pageNumber,
|
|
orderBy,
|
|
fieldSort,
|
|
showNumberOfRecords
|
|
) => {
|
|
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) => {
|
|
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) => {
|
|
consoleLogger(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) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const getSearchDocumentDetails = (incidentID) => {
|
|
return axios
|
|
.get(
|
|
"/api/endpoint/getsearchdocumentdetails_api?incidentid=" +
|
|
incidentID
|
|
)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const getSearchDocumentTypes = (incidentID) => {
|
|
return axios
|
|
.get(
|
|
"/api/endpoint/getsearchdocumentTypes_api?incidentid=" + incidentID
|
|
)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
consoleLogger(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) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const getLinkedCases = (parentIncidentid) => {
|
|
return axios
|
|
.get(
|
|
"/api/endpoint/getlinkedcases_api?parentincidentid=" +
|
|
parentIncidentid
|
|
)
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const getAppealsTypes = () => {
|
|
return axios
|
|
.get(BASE_URL + "/api/endpoint/getappealtypes_api")
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
consoleLogger(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) => {
|
|
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) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const getMandatoryFields = (whichForm) => {
|
|
return axios
|
|
.get(
|
|
BASE_URL +
|
|
"/api/endpoint/getmandatoryfields_api?whichForm=" +
|
|
whichForm
|
|
)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const getPickLists = (whichForm) => {
|
|
return axios
|
|
.get(BASE_URL + "/api/endpoint/getpicklists_api?whichForm=" + whichForm)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const getPersonalAccount = (contactid) => {
|
|
return axios
|
|
.get(
|
|
BASE_URL +
|
|
"/api/endpoint/getpersonalaccount_api?contactid=" +
|
|
contactid
|
|
)
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
consoleLogger(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) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const getLogin = (emailAddress, pwd) => {
|
|
return axios
|
|
.get(
|
|
"/api/endpoint/getlogin_api?emailAddress=" +
|
|
emailAddress +
|
|
"&pwd=" +
|
|
pwd
|
|
)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const getMyCases = (loggedInUserId) => {
|
|
return axios
|
|
.get(
|
|
BASE_URL +
|
|
"/api/endpoint/getmycases_api?loggedInUserId=" +
|
|
loggedInUserId
|
|
)
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const getMyLPACases = (lpaid) => {
|
|
return axios
|
|
.get(BASE_URL + "/api/endpoint/getmylpacases_api?lpaid=" + lpaid)
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const getMyRepresentations = (loggedInUserId) => {
|
|
return axios
|
|
.get(
|
|
BASE_URL +
|
|
"/api/endpoint/getmyrepresentations_api?loggedInUserId=" +
|
|
loggedInUserId
|
|
)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const getMyRepresentationsProxy = (loggedInUserId) => {
|
|
return axios
|
|
.get(
|
|
BASE_URL +
|
|
"/api/endpoint/getmyrepresentationsproxy_api?loggedInUserId=" +
|
|
loggedInUserId
|
|
)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const getRepresentations = (incidentID) => {
|
|
return axios
|
|
.get("/api/endpoint/getrepresentations_api?incidentID=" + incidentID)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const getRepresentationsProxy = (incidentID) => {
|
|
return axios
|
|
.get(
|
|
BASE_URL +
|
|
"/api/endpoint/getrepresentationsproxy_api?incidentID=" +
|
|
incidentID
|
|
)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const getWatchedCases = (loggedInUserId) => {
|
|
return axios
|
|
.get(
|
|
BASE_URL +
|
|
"/api/endpoint/getwatchedcases_api?loggedInUserId=" +
|
|
loggedInUserId
|
|
)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const getWatchedCasesProxy = (loggedInUserId) => {
|
|
return axios
|
|
.get(
|
|
"/api/endpoint/getwatchedcasesproxy_api?loggedInUserId=" +
|
|
loggedInUserId
|
|
)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const getAwaitingSubmissionProxy = (loggedInUserId) => {
|
|
return axios
|
|
.get(
|
|
BASE_URL +
|
|
"/api/endpoint/getawaitingsubmissionproxy_api?loggedInUserId=" +
|
|
loggedInUserId
|
|
)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const getAwaitingSubmission = (loggedInUserId) => {
|
|
return axios
|
|
.get(
|
|
BASE_URL +
|
|
"/api/endpoint/getawaitingsubmission_api?loggedInUserId=" +
|
|
loggedInUserId
|
|
)
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const getAwaitingSubmissionFromBlob = (containerName) => {
|
|
//console.log(
|
|
// "///////////////////////\ngetAwaitingSubmissionFromBlob: " +
|
|
// containerName,
|
|
// BASE_URL +
|
|
// "/api/file/getawaitingsubmissionfromblob?container=" +
|
|
// containerName +
|
|
// hashAPIPath(
|
|
// "/api/file/getawaitingsubmissionfromblob?container=" +
|
|
// 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) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const getRepsFromBlob = (containerName) => {
|
|
//console.log(
|
|
// "///////////////////////\ngetRepsFromBlob function: " +
|
|
// containerName +
|
|
// "\n///////////////////////\n",
|
|
// BASE_URL +
|
|
// "/api/file/getrepsblob?container=" +
|
|
// containerName +
|
|
// hashAPIPath("/api/file/getrepsblob?container=" + containerName)
|
|
// );
|
|
|
|
return axios
|
|
.get(
|
|
BASE_URL +
|
|
"/api/file/getrepsblob?container=" +
|
|
containerName +
|
|
hashAPIPath("/api/file/getrepsblob?container=" + containerName)
|
|
)
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
//console.log(
|
|
// "///////////////////////\ngetRepsFromBlob error response: " +
|
|
// error +
|
|
// "\n///////////////////////\n"
|
|
// );
|
|
console.log(consoleLogger(error));
|
|
//console.log("API call error", error);
|
|
});
|
|
};
|
|
|
|
export const getRepsFromBlobProxy = (containerName) => {
|
|
//console.log(
|
|
// "///////////////////////getRepsFromBlobProxy: " + containerName,
|
|
// "/api/file/getawaitingsubmissionfromblobproxy?container=" +
|
|
// containerName,
|
|
// "\n///////////////////////\n"
|
|
// );
|
|
|
|
return axios
|
|
.get(
|
|
// BASE_URL +
|
|
"/api/file/getrepsblobproxy?container=" + containerName
|
|
// +
|
|
// hashAPIPath(
|
|
// "/api/file/getawaitingsubmissionfromblob?container=" +
|
|
// containerName
|
|
// )
|
|
)
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const getAwaitingSubmissionFromBlobProxy = (containerName) => {
|
|
console.log(
|
|
"///////////////////////getAwaitingSubmissionFromBlobProxy: " +
|
|
containerName,
|
|
"/api/file/getawaitingsubmissionfromblobproxy?container=" +
|
|
containerName,
|
|
"\n///////////////////////\n"
|
|
);
|
|
|
|
return axios
|
|
.get(
|
|
// BASE_URL +
|
|
"/api/file/getawaitingsubmissionfromblobproxy?container=" +
|
|
containerName
|
|
// +
|
|
// hashAPIPath(
|
|
// "/api/file/getawaitingsubmissionfromblob?container=" +
|
|
// containerName
|
|
// )
|
|
)
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
consoleLogger(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) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const getPortalModuleDetailsProxy = (appealType, caseReference) => {
|
|
return axios
|
|
.get(
|
|
"/api/endpoint/getportalmoduledetailsproxy_api?appealType=" +
|
|
appealType +
|
|
"&caseReference=" +
|
|
caseReference.replace(/\'/g, "''")
|
|
)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const getEmailAccountCheck = (emailAddress) => {
|
|
return axios
|
|
.get(
|
|
"/api/endpoint/getemailaccountcheck_api?emailAddress=" +
|
|
emailAddress
|
|
)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
consoleLogger(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) => {
|
|
consoleLogger(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 queryUrl = "/api/endpoint/createwatchedcases_api";
|
|
|
|
var config = {
|
|
method: "post",
|
|
url: queryUrl,
|
|
data: data,
|
|
};
|
|
|
|
return axios(config)
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
consoleLogger(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) => {
|
|
consoleLogger(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;
|
|
//+
|
|
// hashAPIPath(
|
|
// "/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) => {
|
|
consoleLogger(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) => {
|
|
consoleLogger(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) => {
|
|
consoleLogger(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) => {
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
consoleLogger(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) => {
|
|
consoleLogger(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) => {
|
|
consoleLogger(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) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const deleteMyRepresentationsFromBlob = (
|
|
containerID,
|
|
casefolderID,
|
|
repfile
|
|
) => {
|
|
var queryUrl =
|
|
"/api/file/deleteblobrep?container=" +
|
|
containerID +
|
|
"&casefolderID=" +
|
|
casefolderID +
|
|
"&repfile=" +
|
|
repfile;
|
|
|
|
var config = {
|
|
method: "get",
|
|
url: queryUrl,
|
|
};
|
|
//console.log(config);
|
|
return axios(config)
|
|
.then((res) => {
|
|
//console.log("deleted ", res.data);
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
consoleLogger(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) => {
|
|
consoleLogger(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) => {
|
|
consoleLogger(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("upload files:", 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) {
|
|
consoleLogger(error);
|
|
}
|
|
};
|
|
|
|
export const uploadRepFiles = 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);
|
|
formData.append("repOrAppeal", true);
|
|
|
|
// 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("upload rep files:", 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) {
|
|
consoleLogger(error);
|
|
}
|
|
};
|
|
|
|
export const generateRepPDF = async (formValues, containerID, casefolderID) => {
|
|
//let files = filesObj;
|
|
|
|
console.log("generateRepPDF function: " + formValues);
|
|
// var formData = new FormData();
|
|
// formValues.append("appealData", JSON.stringify(formValues));
|
|
// formValues.append("containerID", containerID);
|
|
// formValues.append("casefolderID", casefolderID);
|
|
|
|
// Object.assign(formValues, {
|
|
// "containerID": containerID,
|
|
// "casefolderID": casefolderID,
|
|
// });
|
|
|
|
var queryUrl = "/api/file/generatepdf";
|
|
|
|
const config = {
|
|
method: "post",
|
|
url: queryUrl,
|
|
data: formValues,
|
|
//headers: { "content-type": "multipart/form-data" },
|
|
};
|
|
|
|
//console.log(config);
|
|
try {
|
|
const res = await axios(config);
|
|
return res.data;
|
|
} catch (error) {
|
|
consoleLogger(error);
|
|
}
|
|
};
|
|
|
|
export const generateAppealPDF = async (
|
|
formValues,
|
|
containerID,
|
|
casefolderID,
|
|
appealType,
|
|
fileList
|
|
) => {
|
|
//let files = filesObj;
|
|
|
|
//console.log("generateAppealPDF function: " + formValues);
|
|
// var formData = new FormData();
|
|
// formValues.append("appealData", JSON.stringify(formValues));
|
|
// formValues.append("containerID", containerID);
|
|
//formValues.append("filesList", fileList);
|
|
|
|
Object.assign(formValues, {
|
|
"filesList": fileList,
|
|
});
|
|
|
|
var queryUrl = "/api/file/generateappealpdf?appealType=" + appealType;
|
|
|
|
const config = {
|
|
method: "post",
|
|
url: queryUrl,
|
|
data: formValues,
|
|
//headers: { "content-type": "multipart/form-data" },
|
|
};
|
|
|
|
//console.log(config);
|
|
try {
|
|
const res = await axios(config);
|
|
return res.data;
|
|
} catch (error) {
|
|
consoleLogger(error);
|
|
}
|
|
};
|
|
|
|
export const getFilesFromBlob = (containerName, casefolderID) => {
|
|
//console.log(
|
|
// " get files from blob",
|
|
// BASE_URL +
|
|
// "/api/file/getbloblist?container=" +
|
|
// containerName +
|
|
// "&casefolderID=" +
|
|
// casefolderID +
|
|
// hashAPIPath(
|
|
// "/api/file/getbloblist?container=" +
|
|
// containerName +
|
|
// "&casefolderID=" +
|
|
// 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) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const getFilesFromBlobHashed = (
|
|
containerName,
|
|
getblobshash,
|
|
casefolderID
|
|
) => {
|
|
return axios
|
|
.get(
|
|
"/api/file/getbloblist?container=" +
|
|
containerName +
|
|
"&casefolderID=" +
|
|
casefolderID +
|
|
getblobshash
|
|
)
|
|
.then((res) => {
|
|
//console.log("//////////----", res.data);
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const deleteBlob = async (
|
|
containerName,
|
|
blobName,
|
|
deleteblobhash,
|
|
casefolderID
|
|
) => {
|
|
try {
|
|
const res = await axios.get(
|
|
"/api/file/deleteblob?container=" +
|
|
containerName +
|
|
"&casefolderID=" +
|
|
casefolderID +
|
|
"&blobname=" +
|
|
blobName +
|
|
deleteblobhash
|
|
);
|
|
return res.data;
|
|
} catch (error) {
|
|
consoleLogger(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) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const getProgressFromBlob = async (containerName, casereference) => {
|
|
//console.log(
|
|
// /////////////////\ngetProgressFromBlob",
|
|
// BASE_URL +
|
|
// "/api/file/getprogressobjblob?container=" +
|
|
// containerName +
|
|
// "&casefolderID=" +
|
|
// casereference +
|
|
// hashAPIPath(
|
|
// "/api/file/getprogressobjblob?container=" +
|
|
// containerName +
|
|
// "&casefolderID=" +
|
|
// 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) {
|
|
consoleLogger(error);
|
|
}
|
|
};
|
|
|
|
export const sendEmail = async (
|
|
templateId,
|
|
emailAddress,
|
|
personalisation,
|
|
reference
|
|
) => {
|
|
var mailData = {
|
|
"templateId": templateId,
|
|
"emailAddress": emailAddress,
|
|
"reference": reference,
|
|
"personalisation": personalisation,
|
|
};
|
|
|
|
//console.log(
|
|
// "hwewwew: ",
|
|
// templateId,
|
|
// emailAddress,
|
|
// personalisation,
|
|
// reference
|
|
// );
|
|
var queryUrl = "/api/email/notify";
|
|
|
|
var config = {
|
|
method: "post",
|
|
url: queryUrl,
|
|
data: mailData,
|
|
};
|
|
|
|
return axios(config)
|
|
.then((res) => {
|
|
//console.log("posted ", res.data);
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const getNotice = () => {
|
|
return axios
|
|
.get(BASE_URL + "/api/notices")
|
|
.then((res) => {
|
|
//console.log("//////////----", res.data);
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const getPortalLogin = async (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));
|
|
|
|
return JSON.stringify(error);
|
|
});
|
|
};
|
|
|
|
export const createContainerProxy = (containerName) => {
|
|
var queryUrl =
|
|
"/api/file/setupcontainer?ident=" +
|
|
containerName +
|
|
hashAPIPath("/api/file/setupcontainer?ident=" + containerName);
|
|
|
|
return axios
|
|
.get(BASE_URL + queryUrl)
|
|
.then((res) => res.data)
|
|
.catch((error) => {
|
|
console.log(consoleLogger(error));
|
|
|
|
return JSON.stringify(error);
|
|
});
|
|
};
|
|
|
|
export const sendCaseCompleteMessage = async (containerID, caseReference) => {
|
|
var queryUrl =
|
|
"/api/file/createappealcompletemessage_api?container=" +
|
|
containerID +
|
|
"&tempcaseref=" +
|
|
caseReference;
|
|
|
|
var config = {
|
|
method: "get",
|
|
url: queryUrl,
|
|
};
|
|
|
|
//console.log(data);
|
|
|
|
return axios(config)
|
|
.then((res) => {
|
|
console.log("sendCaseCompleteMessage: ", res.data);
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const sendCaseCompleteMessageProxy = async (
|
|
containerID,
|
|
caseReference
|
|
) => {
|
|
var queryUrl =
|
|
"/api/file/createappealcompletemessageproxy_api?container=" +
|
|
containerID +
|
|
"&tempcaseref=" +
|
|
caseReference;
|
|
|
|
var config = {
|
|
method: "get",
|
|
url: queryUrl,
|
|
};
|
|
|
|
//console.log(data);
|
|
|
|
return axios(config)
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const sendRepCompleteMessage = async (
|
|
containerID,
|
|
caseReference,
|
|
fileName
|
|
) => {
|
|
var queryUrl =
|
|
"/api/file/createrepcompletemessage_api?container=" +
|
|
containerID +
|
|
"&tempcaseref=" +
|
|
caseReference +
|
|
"&repid=" +
|
|
fileName;
|
|
|
|
var config = {
|
|
method: "get",
|
|
url: queryUrl,
|
|
};
|
|
|
|
//console.log(data);
|
|
|
|
return axios(config)
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const getAddressSearch = async (searchString) => {
|
|
const params = new URLSearchParams(searchString);
|
|
const str = params.toString();
|
|
|
|
//console.log(
|
|
// "the url",
|
|
// BASE_URL + "/api/endpoint/getbasicsearch_by_address_api?" + str
|
|
// );
|
|
try {
|
|
const res = await axios.get(
|
|
BASE_URL + "/api/endpoint/getbasicsearch_by_address_api?" + str
|
|
);
|
|
return res.data;
|
|
} catch (error) {
|
|
let ErrResponse = {
|
|
value: [],
|
|
errorCode: error.response.status,
|
|
errorMsg: error.response.statusText,
|
|
};
|
|
return ErrResponse;
|
|
}
|
|
};
|