/** * @swagger * /api/endpoint/getawaitingsubmissionproxy_api: * get: * tags: [Case] * summary: Phase 2 * description: get awaiting case submission proxy * responses: * 200: * description: Success */ import { respondError } from "../middleware/apiResponse"; import { relayGet } from "../middleware/relayForwarding"; export default async function ApiProxy(req, res) { const loggedInUserId = req.query.loggedInUserId; if ( typeof loggedInUserId !== "string" || loggedInUserId.trim().length === 0 ) { return respondError(res, { status: 400, code: "LOGGED_IN_USER_ID_REQUIRED", message: "loggedInUserId is required" }); } const queryUrl = "incidents?$select=pinswg_environmentalstatementlocation,modifiedon,description,numberofchildincidents,_accountid_value,_customerid_value,_pinswg_associatedlpa_value,_ownerid_value,pinswg_appealcasetype,statuscode,ticketnumber,title, _primarycontactid_value,pinswg_lpareference,pinswg_appellantlastname,pinswg_appellantfirstname,pinswg_appellantagent,pinswg_agentfirstname,pinswg_agentlastname,pinswg_agentcompanyname&$expand=primarycontactid($select=fullname)&$filter=_customerid_value eq " + loggedInUserId + " and pinswg_appealcasetype ne null&$orderby=createdon desc&$count=true"; return relayGet({ queryUrl, res, transformData: (data) => { data.value.forEach(function (element) { element.pinswg_title = element.title; }); return data; }, errorResponse: { status: 400, code: "AWAITING_SUBMISSION_PROXY_FETCH_FAILED", message: "Failed to fetch awaiting submission proxy details" } }); }