333 lines
7.6 KiB
JavaScript
333 lines
7.6 KiB
JavaScript
import axios from "axios";
|
|
import { BASE_URL } from "../core/env";
|
|
import { consoleLogger } from "../core/logger";
|
|
import { logAndReturnResponse } from "./httpServiceUtils";
|
|
import { getJson } from "../clients/endpointClient";
|
|
|
|
export const getCaseMessage = (searchString) => {
|
|
return axios
|
|
.get(BASE_URL + "/api/endpoint/getcasemessage_api?id=" + searchString)
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch(logAndReturnResponse);
|
|
};
|
|
|
|
export const getIncidentbyID = (searchString) => {
|
|
return axios
|
|
.get(
|
|
BASE_URL +
|
|
"/api/endpoint/getincidentbyid_api?searchString=" +
|
|
searchString
|
|
)
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch(logAndReturnResponse);
|
|
};
|
|
|
|
export const getIsPublishedbyID = (searchString) => {
|
|
return axios
|
|
.get(
|
|
"/api/endpoint/getispublishedbyid_api?searchString=" + searchString
|
|
)
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch(logAndReturnResponse);
|
|
};
|
|
|
|
export const getPartSavedAppeal = (searchString) => {
|
|
return axios
|
|
.get(
|
|
BASE_URL +
|
|
"/api/endpoint/getpartsavedappeal_api?searchString=" +
|
|
searchString
|
|
)
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch(logAndReturnResponse);
|
|
};
|
|
|
|
export const getSIPSEvents = async (caseid) => {
|
|
return axios
|
|
.get(BASE_URL + "/api/endpoint/getsipsevents_api?caseid=" + caseid)
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch(logAndReturnResponse);
|
|
};
|
|
|
|
export const getSIPSMedia = async (caseid) => {
|
|
return axios
|
|
.get(BASE_URL + "/api/endpoint/getsipsmedia_api?caseid=" + caseid)
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch(logAndReturnResponse);
|
|
};
|
|
|
|
export const getAppealID = (
|
|
caseReference,
|
|
updateFormCollection,
|
|
primaryAttribute
|
|
) => {
|
|
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];
|
|
var appealID = result;
|
|
return appealID;
|
|
})
|
|
.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;
|
|
|
|
var config = {
|
|
method: "post",
|
|
url: queryUrl,
|
|
data: data
|
|
};
|
|
|
|
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
|
|
};
|
|
|
|
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
|
|
};
|
|
|
|
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) => {
|
|
return axios
|
|
.get(BASE_URL + "/api/endpoint/getcase_api?incidentID=" + incidentID)
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const getCaseByID = (incidentID) => {
|
|
return axios
|
|
.get(
|
|
BASE_URL + "/api/endpoint/getcasebyid_api?incidentID=" + incidentID
|
|
)
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const getAppealPDFDocs = (incidentID) => {
|
|
return getJson(
|
|
BASE_URL +
|
|
"/api/endpoint/getappealpdfdocuments_api?incidentid=" +
|
|
incidentID
|
|
).catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const getAppealPDFDocument = async (incidentid) => {
|
|
return axios
|
|
.get(
|
|
BASE_URL +
|
|
"/api/endpoint/getappealpdfdocuments_api?incidentid=" +
|
|
incidentid
|
|
)
|
|
.then((res) => {
|
|
return res.data;
|
|
})
|
|
.catch((error) => {
|
|
consoleLogger(error);
|
|
return error.response;
|
|
});
|
|
};
|
|
|
|
export const getPortalModuleDetails = async (appealType, caseReference) => {
|
|
return getJson(
|
|
BASE_URL +
|
|
"/api/endpoint/getportalmoduledetails_api?appealType=" +
|
|
appealType +
|
|
"&caseReference=" +
|
|
encodeURI(caseReference)
|
|
).catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|
|
|
|
export const getPortalModuleDetailsProxy = (appealType, caseReference) => {
|
|
return getJson(
|
|
"/api/endpoint/getportalmoduledetailsproxy_api?appealType=" +
|
|
appealType +
|
|
"&caseReference=" +
|
|
caseReference.replace(/\'/g, "''")
|
|
).catch((error) => {
|
|
consoleLogger(error);
|
|
});
|
|
};
|