58 lines
1.6 KiB
JavaScript
58 lines
1.6 KiB
JavaScript
/**
|
|
* @swagger
|
|
* /api/endpoint/getpicklists_api:
|
|
* get:
|
|
* tags: [Case]
|
|
* description: Returns picklists for appeal tpyes
|
|
* summary: Phase 2
|
|
* parameters:
|
|
* - name: whichForm
|
|
* in: query
|
|
* required: true
|
|
* example: planningappeals78
|
|
* schema:
|
|
* type: string
|
|
* responses:
|
|
* 200:
|
|
* description: hello world
|
|
*/
|
|
|
|
import { respondError, respondSuccess } from "../middleware/apiResponse";
|
|
|
|
const WORDKEY = process.env.HASHKEY;
|
|
|
|
const WEBAPI_URL =
|
|
process.env.RELAY_ROOT ||
|
|
"https://dev-pedw-ns.servicebus.windows.net/dev-pedw-hc/";
|
|
|
|
export default async function ApiProxy(req, res) {
|
|
const whichForm = req.query.whichForm;
|
|
|
|
if (typeof whichForm !== "string" || whichForm.trim().length === 0) {
|
|
return respondError(res, {
|
|
status: 400,
|
|
code: "WHICH_FORM_REQUIRED",
|
|
message: "whichForm is required"
|
|
});
|
|
}
|
|
|
|
// var queryUrl =
|
|
// "EntityDefinitions(LogicalName='pinswg_" +
|
|
// whichForm +
|
|
// "')/Attributes/Microsoft.Dynamics.CRM.PicklistAttributeMetadata?$select=LogicalName&$expand=OptionSet,GlobalOptionSet&$count=true";
|
|
|
|
try {
|
|
const pickListData = require(
|
|
"../../../data/picklistdata/pinswg_" + whichForm + ".json"
|
|
);
|
|
|
|
return respondSuccess(res, pickListData);
|
|
} catch (error) {
|
|
return respondError(res, {
|
|
status: 404,
|
|
code: "PICKLISTS_NOT_FOUND",
|
|
message: "Picklist data not found for requested form"
|
|
});
|
|
}
|
|
}
|