49 lines
1.3 KiB
JavaScript
49 lines
1.3 KiB
JavaScript
/**
|
|
* @swagger
|
|
* /api/endpoint/getrepresentations_api:
|
|
* get:
|
|
* tags: [Case]
|
|
* description: Get Representations for a Case
|
|
* summary: Phase 2
|
|
* parameters:
|
|
* - name: incidentID
|
|
* in: query
|
|
* required: true
|
|
* example: 50b533aa-43f1-ec11-aade-00224800be9c
|
|
* schema:
|
|
* type: string
|
|
* responses:
|
|
* 200:
|
|
* description: Success
|
|
*/
|
|
|
|
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 =
|
|
"pinswg_representationses?$filter= _pinswg_case_value eq " +
|
|
incidentID +
|
|
" and pinswg_publishtoweb eq true&$count=true&$orderby=createdon desc";
|
|
|
|
return relayGet({
|
|
queryUrl,
|
|
res,
|
|
errorResponse: {
|
|
status: 400,
|
|
code: "REPRESENTATIONS_FETCH_FAILED",
|
|
message: "Failed to fetch representations"
|
|
}
|
|
});
|
|
}
|