53 lines
1.5 KiB
JavaScript
53 lines
1.5 KiB
JavaScript
/**
|
|
* @swagger
|
|
* /api/endpoint/getpersonalaccount_api:
|
|
* get:
|
|
* tags: [Account]
|
|
* description: Get personal account
|
|
* summary: Phase 2
|
|
* parameters:
|
|
* - name: contactid
|
|
* in: query
|
|
* required: true
|
|
* example: 726158c6-708d-ec11-aad8-00224800be9c
|
|
* schema:
|
|
* type: string
|
|
* responses:
|
|
* 200:
|
|
* description: hello world
|
|
*/
|
|
|
|
import { respondError } from "../middleware/apiResponse";
|
|
import { relayGet } from "../middleware/relayForwarding";
|
|
import { RELAY_POLICY_LOOKUP } from "../middleware/relayPolicyPresets";
|
|
|
|
export default async function ApiProxy(req, res) {
|
|
const contactid = req.query.contactid;
|
|
|
|
if (typeof contactid !== "string" || contactid.trim().length === 0) {
|
|
return respondError(res, {
|
|
status: 400,
|
|
code: "CONTACT_ID_REQUIRED",
|
|
message: "contactid is required"
|
|
});
|
|
}
|
|
|
|
const queryUrl =
|
|
"contacts(" +
|
|
contactid +
|
|
")?$select=firstname, lastname, emailaddress1, telephone1, pinswg_companyname, address1_line1,address1_line2,address1_city, address1_county,address1_postalcode,pinswg_typeofinvolvement,pinswg_contact_associatedlpa,pinswg_preferredlanguage&$count=true";
|
|
|
|
const relayPolicy = RELAY_POLICY_LOOKUP;
|
|
|
|
return relayGet({
|
|
queryUrl,
|
|
res,
|
|
relayPolicy,
|
|
errorResponse: {
|
|
status: 400,
|
|
code: "PERSONAL_ACCOUNT_FETCH_FAILED",
|
|
message: "Failed to fetch personal account"
|
|
}
|
|
});
|
|
}
|