51 lines
1.3 KiB
JavaScript
51 lines
1.3 KiB
JavaScript
/**
|
|
* @swagger
|
|
* /api/endpoint/getcase_api:
|
|
* get:
|
|
* tags: [Case]
|
|
* summary: Not used
|
|
* description: Get case
|
|
* responses:
|
|
* 200:
|
|
* description: Success
|
|
*/
|
|
|
|
import _ from "lodash";
|
|
import { respondError } from "../middleware/apiResponse";
|
|
import { relayGet } from "../middleware/relayForwarding";
|
|
|
|
export default async function ApiProxy(req, res) {
|
|
const incidentID = req.query.incidentID;
|
|
|
|
if (typeof incidentID !== "string" || incidentID.trim().length === 0) {
|
|
return respondError(res, {
|
|
status: 400,
|
|
code: "INCIDENT_ID_REQUIRED",
|
|
message: "incidentID is required"
|
|
});
|
|
}
|
|
|
|
const queryUrl =
|
|
"incidents(" +
|
|
incidentID +
|
|
")?$select=ticketnumber,title,pinswg_appealcasetype";
|
|
|
|
return relayGet({
|
|
queryUrl,
|
|
res,
|
|
transformData: (data) => {
|
|
if (_.has(data, "@odata.nextLink") === true) {
|
|
const dataStr = JSON.stringify(data["@odata.nextLink"]);
|
|
data["@odata.nextLink"] = dataStr.split("/v8.2/")[1];
|
|
}
|
|
|
|
return data;
|
|
},
|
|
errorResponse: {
|
|
status: 400,
|
|
code: "CASE_FETCH_FAILED",
|
|
message: "Failed to fetch case"
|
|
}
|
|
});
|
|
}
|