52 lines
1.3 KiB
JavaScript
52 lines
1.3 KiB
JavaScript
/**
|
|
* @swagger
|
|
* /api/endpoint/getmyrepresentationsproxy_api:
|
|
* get:
|
|
* tags: [Portal]
|
|
* description: Get My representations
|
|
* summary: Phase 2
|
|
* parameters:
|
|
* - name: loggedInUserId
|
|
* in: query
|
|
* required: true
|
|
* example: 726158c6-708d-ec11-aad8-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 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 =
|
|
"pinswg_representationses?$filter= _pinswg_contact_value eq " +
|
|
loggedInUserId +
|
|
"&$count=true&$orderby=createdon desc";
|
|
|
|
return relayGet({
|
|
queryUrl,
|
|
res,
|
|
errorResponse: {
|
|
status: 400,
|
|
code: "MY_REPRESENTATIONS_PROXY_FETCH_FAILED",
|
|
message: "Failed to fetch my representations proxy details"
|
|
}
|
|
});
|
|
}
|