import axios from "axios"; import { BASE_URL } from "../core/env"; import { consoleLogger } from "../core/logger"; import { logAndReturnResponse, logAndReturnEmptyValueErrorResponse } from "./httpServiceUtils"; export const getBasicSearch = (searchString) => { return axios .get( BASE_URL + "/api/endpoint/getbasicsearch_api?searchString=" + searchString ) .then((res) => { return res.data; }) .catch(logAndReturnResponse); }; export const getBasicDNSURLSearch = (searchString) => { return axios .get( BASE_URL + "/api/endpoint/getbasicdnsurlsearch_api?searchString=" + searchString ) .then((res) => { return res.data; }) .catch(logAndReturnResponse); }; 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(logAndReturnResponse); }; 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(logAndReturnResponse); }; export const getDNSCoords = () => { return axios .get(BASE_URL + "/api/endpoint/getdnscoords_api") .then((res) => { return res.data; }) .catch(logAndReturnEmptyValueErrorResponse); }; export const getDNSList = (searchString) => { return axios .get(BASE_URL + "/api/endpoint/getdnslist_api") .then((res) => res.data) .catch(logAndReturnResponse); }; export const getBasicDNSSearch = (searchString) => { return axios .get(BASE_URL + "/api/endpoint/getbasicdnssearch_api") .then((res) => res.data) .catch(logAndReturnResponse); }; 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(logAndReturnResponse); }; export const getAdvancedSearch = (searchString) => { return axios .get( BASE_URL + "/api/endpoint/getadvancedsearch_api?searchstring=" + JSON.stringify(searchString) ) .then((res) => res.data) .catch(logAndReturnEmptyValueErrorResponse); }; 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(logAndReturnEmptyValueErrorResponse); }; export const getBasicSearchDetails = async ( 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 ) => { return axios .get( BASE_URL + "/api/endpoint/getbasicpartsaveddetails_api?appealTypeName=" + appealTypeName + "&primaryIdAttribute=" + primaryIdAttribute + "&incidentID=" + incidentID ) .then((res) => res.data) .catch((error) => { consoleLogger(error); }); }; export const getBasicSearchDetailsPaged = async ( appealTypeName, caseReference, primaryIdAttribute, incidentIDs ) => { if (!incidentIDs || incidentIDs.length === 0) return []; const filter = incidentIDs .map((id) => { const suffix = primaryIdAttribute === "pinswg_sipscase" ? `_${primaryIdAttribute}_value` : `_${primaryIdAttribute}s_value`; return `${suffix} eq ${id}`; }) .join(" or "); const url = `/api/endpoint/getbasicsearchdetailspaged_api?appealTypeName=${appealTypeName}&primaryIdAttribute=${primaryIdAttribute}&incidentID=${encodeURIComponent( filter )}`; try { const res = await axios.get(url); return res.data.value || []; } catch (error) { consoleLogger(error); return []; } }; export const getSearchDocumentDetails = (incidentID) => { return axios .get( "/api/endpoint/getsearchdocumentdetails_api?incidentid=" + incidentID ) .then((res) => res.data) .catch((error) => { consoleLogger(error); throw 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 ) => { 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 getAddressSearch = async (searchString) => { const params = new URLSearchParams(searchString); const str = params.toString(); var queryUrl = BASE_URL + "/api/endpoint/getbasicsearch_by_address_api?" + str; var config = { method: "get", url: queryUrl }; return axios(config) .then((res) => { return res.data; }) .catch(logAndReturnEmptyValueErrorResponse); };