TASK22211: normalize myportal retrieval endpoint contracts

This commit is contained in:
2026-03-23 11:12:19 +00:00
parent b57f3de06f
commit 9af541ac6b
5 changed files with 339 additions and 106 deletions
+30 -17
View File
@@ -18,37 +18,50 @@
*/
import axios from "axios";
import CryptoJS from "crypto-js";
import { azureHeaders } from "../../../actions/core/headers";
import { consoleLogger } from "../../../actions/core/logger";
import { getToken } from "../../../actions/core/token";
import { hashAPIPath } from "../../../actions/core/hash";
import { respondError, respondSuccess } from "../middleware/apiResponse";
const WEBAPI_URL =
process.env.RELAY_ROOT ||
"https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/";
export default async function ApiProxy(req, res) {
var loggedInUserId = req.query.loggedInUserId;
var token = await getToken();
const loggedInUserId = req.query.loggedInUserId;
var queryUrl =
"pinswg_representationses?$filter= _pinswg_contact_value eq " +
loggedInUserId +
"&$count=true&$orderby=createdon desc";
if (
typeof loggedInUserId !== "string" ||
loggedInUserId.trim().length === 0
) {
return respondError(res, {
status: 400,
code: "LOGGED_IN_USER_ID_REQUIRED",
message: "loggedInUserId is required"
});
}
//console.log(WEBAPI_URL + queryUrl + hashAPIPath(queryUrl));
try {
const token = await getToken();
return axios
.get(
const queryUrl =
"pinswg_representationses?$filter= _pinswg_contact_value eq " +
loggedInUserId +
"&$count=true&$orderby=createdon desc";
const { data } = await axios.get(
WEBAPI_URL + queryUrl + hashAPIPath(queryUrl),
azureHeaders(token.access_token)
)
.then(({ data }) => {
res.status(200).json(data);
})
.catch((error) => {
consoleLogger(error);
res.status(400).json(error);
);
return respondSuccess(res, data);
} catch (error) {
consoleLogger(error);
return respondError(res, {
status: 400,
code: "MY_REPRESENTATIONS_FETCH_FAILED",
message: "Failed to fetch my representations"
});
}
}