refactor(case): normalize route composition with fileRouteBuilder
This commit is contained in:
@@ -2,45 +2,54 @@ import { BASE_URL } from "../core/env";
|
||||
import { consoleLogger } from "../core/logger";
|
||||
import { logAndReturnResponse } from "./httpServiceUtils";
|
||||
import { getJson, requestJson } from "../clients/endpointClient";
|
||||
import { buildFileQuery, withBaseUrl } from "../clients/fileRouteBuilder";
|
||||
|
||||
export const getCaseMessage = (searchString) => {
|
||||
return getJson(
|
||||
BASE_URL + "/api/endpoint/getcasemessage_api?id=" + searchString
|
||||
).catch(logAndReturnResponse);
|
||||
const route = buildFileQuery("/api/endpoint/getcasemessage_api", {
|
||||
id: searchString
|
||||
});
|
||||
|
||||
return getJson(withBaseUrl(BASE_URL, route)).catch(logAndReturnResponse);
|
||||
};
|
||||
|
||||
export const getIncidentbyID = (searchString) => {
|
||||
return getJson(
|
||||
BASE_URL +
|
||||
"/api/endpoint/getincidentbyid_api?searchString=" +
|
||||
searchString
|
||||
).catch(logAndReturnResponse);
|
||||
const route = buildFileQuery("/api/endpoint/getincidentbyid_api", {
|
||||
searchString
|
||||
});
|
||||
|
||||
return getJson(withBaseUrl(BASE_URL, route)).catch(logAndReturnResponse);
|
||||
};
|
||||
|
||||
export const getIsPublishedbyID = (searchString) => {
|
||||
return getJson(
|
||||
"/api/endpoint/getispublishedbyid_api?searchString=" + searchString
|
||||
).catch(logAndReturnResponse);
|
||||
const route = buildFileQuery("/api/endpoint/getispublishedbyid_api", {
|
||||
searchString
|
||||
});
|
||||
|
||||
return getJson(route).catch(logAndReturnResponse);
|
||||
};
|
||||
|
||||
export const getPartSavedAppeal = (searchString) => {
|
||||
return getJson(
|
||||
BASE_URL +
|
||||
"/api/endpoint/getpartsavedappeal_api?searchString=" +
|
||||
searchString
|
||||
).catch(logAndReturnResponse);
|
||||
const route = buildFileQuery("/api/endpoint/getpartsavedappeal_api", {
|
||||
searchString
|
||||
});
|
||||
|
||||
return getJson(withBaseUrl(BASE_URL, route)).catch(logAndReturnResponse);
|
||||
};
|
||||
|
||||
export const getSIPSEvents = async (caseid) => {
|
||||
return getJson(
|
||||
BASE_URL + "/api/endpoint/getsipsevents_api?caseid=" + caseid
|
||||
).catch(logAndReturnResponse);
|
||||
const route = buildFileQuery("/api/endpoint/getsipsevents_api", {
|
||||
caseid
|
||||
});
|
||||
|
||||
return getJson(withBaseUrl(BASE_URL, route)).catch(logAndReturnResponse);
|
||||
};
|
||||
|
||||
export const getSIPSMedia = async (caseid) => {
|
||||
return getJson(
|
||||
BASE_URL + "/api/endpoint/getsipsmedia_api?caseid=" + caseid
|
||||
).catch(logAndReturnResponse);
|
||||
const route = buildFileQuery("/api/endpoint/getsipsmedia_api", {
|
||||
caseid
|
||||
});
|
||||
|
||||
return getJson(withBaseUrl(BASE_URL, route)).catch(logAndReturnResponse);
|
||||
};
|
||||
|
||||
export const getAppealID = (
|
||||
@@ -48,14 +57,13 @@ export const getAppealID = (
|
||||
updateFormCollection,
|
||||
primaryAttribute
|
||||
) => {
|
||||
return getJson(
|
||||
"/api/endpoint/getappealid_api?updateFormCollection=" +
|
||||
updateFormCollection +
|
||||
"&primaryAttribute=" +
|
||||
primaryAttribute +
|
||||
"&caseReference=" +
|
||||
caseReference
|
||||
)
|
||||
const route = buildFileQuery("/api/endpoint/getappealid_api", {
|
||||
updateFormCollection,
|
||||
primaryAttribute,
|
||||
caseReference
|
||||
});
|
||||
|
||||
return getJson(route)
|
||||
.then((data) => {
|
||||
const result = Object.entries(data.value[0]).filter(
|
||||
([key]) => !key.startsWith("_")
|
||||
@@ -79,19 +87,16 @@ export const createNewCase = (
|
||||
|
||||
var data = createBody;
|
||||
|
||||
var queryUrl =
|
||||
"/api/endpoint/createcase_api?appealTypeId=" +
|
||||
appealTypeId +
|
||||
"&lpaID=" +
|
||||
lpaID +
|
||||
"&contactid=" +
|
||||
contactid +
|
||||
"&containername=" +
|
||||
containerName;
|
||||
var queryUrl = buildFileQuery("/api/endpoint/createcase_api", {
|
||||
appealTypeId,
|
||||
lpaID,
|
||||
contactid,
|
||||
containername: containerName
|
||||
});
|
||||
|
||||
var config = {
|
||||
method: "post",
|
||||
url: BASE_URL + queryUrl,
|
||||
url: withBaseUrl(BASE_URL, queryUrl),
|
||||
data: data
|
||||
};
|
||||
|
||||
@@ -115,15 +120,12 @@ export const createNewCaseBlob = (
|
||||
data.pinswg_lpaname = lpaName;
|
||||
data.createdon = new Date();
|
||||
|
||||
var queryUrl =
|
||||
"/api/file/createcase_api?appealTypeId=" +
|
||||
appealTypeId +
|
||||
"&lpaID=" +
|
||||
lpaID +
|
||||
"&contactid=" +
|
||||
contactid +
|
||||
"&containername=" +
|
||||
containerName;
|
||||
var queryUrl = buildFileQuery("/api/file/createcase_api", {
|
||||
appealTypeId,
|
||||
lpaID,
|
||||
contactid,
|
||||
containername: containerName
|
||||
});
|
||||
|
||||
var config = {
|
||||
method: "post",
|
||||
@@ -151,11 +153,10 @@ export const updateCase = async (
|
||||
primaryAttribute
|
||||
);
|
||||
|
||||
var queryUrl =
|
||||
"/api/endpoint/updatecase_api?updateFormCollection=" +
|
||||
updateFormCollection +
|
||||
"&appealObj=" +
|
||||
appealObj;
|
||||
var queryUrl = buildFileQuery("/api/endpoint/updatecase_api", {
|
||||
updateFormCollection,
|
||||
appealObj
|
||||
});
|
||||
|
||||
var config = {
|
||||
method: "post",
|
||||
@@ -183,11 +184,10 @@ export const updateCaseBlob = async (
|
||||
primaryAttribute
|
||||
);
|
||||
|
||||
var queryUrl =
|
||||
"/api/file/updatecase_api?updateFormCollection=" +
|
||||
updateFormCollection +
|
||||
"&appealObj=" +
|
||||
appealObj;
|
||||
var queryUrl = buildFileQuery("/api/file/updatecase_api", {
|
||||
updateFormCollection,
|
||||
appealObj
|
||||
});
|
||||
|
||||
var config = {
|
||||
method: "post",
|
||||
@@ -201,68 +201,76 @@ export const updateCaseBlob = async (
|
||||
};
|
||||
|
||||
export const patchCase = async (incidentid) => {
|
||||
var queryUrl = "/api/endpoint/patchcase_api?incidentid=" + incidentid;
|
||||
var queryUrl = buildFileQuery("/api/endpoint/patchcase_api", {
|
||||
incidentid
|
||||
});
|
||||
return getJson(queryUrl).catch((error) => {
|
||||
//console.log("this error:", error);
|
||||
});
|
||||
};
|
||||
|
||||
export const getCase = (incidentID) => {
|
||||
return getJson(
|
||||
BASE_URL + "/api/endpoint/getcase_api?incidentID=" + incidentID
|
||||
).catch((error) => {
|
||||
const route = buildFileQuery("/api/endpoint/getcase_api", {
|
||||
incidentID
|
||||
});
|
||||
|
||||
return getJson(withBaseUrl(BASE_URL, route)).catch((error) => {
|
||||
consoleLogger(error);
|
||||
});
|
||||
};
|
||||
|
||||
export const getCaseByID = (incidentID) => {
|
||||
return getJson(
|
||||
BASE_URL + "/api/endpoint/getcasebyid_api?incidentID=" + incidentID
|
||||
).catch((error) => {
|
||||
const route = buildFileQuery("/api/endpoint/getcasebyid_api", {
|
||||
incidentID
|
||||
});
|
||||
|
||||
return getJson(withBaseUrl(BASE_URL, route)).catch((error) => {
|
||||
consoleLogger(error);
|
||||
});
|
||||
};
|
||||
|
||||
export const getAppealPDFDocs = (incidentID) => {
|
||||
return getJson(
|
||||
BASE_URL +
|
||||
"/api/endpoint/getappealpdfdocuments_api?incidentid=" +
|
||||
incidentID
|
||||
).catch((error) => {
|
||||
const route = buildFileQuery("/api/endpoint/getappealpdfdocuments_api", {
|
||||
incidentid: incidentID
|
||||
});
|
||||
|
||||
return getJson(withBaseUrl(BASE_URL, route)).catch((error) => {
|
||||
consoleLogger(error);
|
||||
});
|
||||
};
|
||||
|
||||
export const getAppealPDFDocument = async (incidentid) => {
|
||||
return getJson(
|
||||
BASE_URL +
|
||||
"/api/endpoint/getappealpdfdocuments_api?incidentid=" +
|
||||
incidentid
|
||||
).catch((error) => {
|
||||
const route = buildFileQuery("/api/endpoint/getappealpdfdocuments_api", {
|
||||
incidentid
|
||||
});
|
||||
|
||||
return getJson(withBaseUrl(BASE_URL, route)).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) => {
|
||||
const route = buildFileQuery("/api/endpoint/getportalmoduledetails_api", {
|
||||
appealType,
|
||||
caseReference: encodeURI(caseReference)
|
||||
});
|
||||
|
||||
return getJson(withBaseUrl(BASE_URL, route)).catch((error) => {
|
||||
consoleLogger(error);
|
||||
});
|
||||
};
|
||||
|
||||
export const getPortalModuleDetailsProxy = (appealType, caseReference) => {
|
||||
return getJson(
|
||||
"/api/endpoint/getportalmoduledetailsproxy_api?appealType=" +
|
||||
appealType +
|
||||
"&caseReference=" +
|
||||
caseReference.replace(/\'/g, "''")
|
||||
).catch((error) => {
|
||||
const route = buildFileQuery(
|
||||
"/api/endpoint/getportalmoduledetailsproxy_api",
|
||||
{
|
||||
appealType,
|
||||
caseReference: caseReference.replace(/\'/g, "''")
|
||||
}
|
||||
);
|
||||
|
||||
return getJson(route).catch((error) => {
|
||||
consoleLogger(error);
|
||||
});
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user