Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- api.route('/updateField')
- .patch(async (req, res, next) => {
- const customerID = res.locals.client;
- const fieldID = req.query.fieldID;
- const value = req.query.value;
- //Validation
- if (!fieldID || !value) {
- sendFailResponse(31, "A required parameter is missing.", res);
- }
- const mydb = mysql.new();
- var qry = `flawed query i removed`;
- mydb.query(qry, (err, data, fields) => {
- if(err) {
- sendFailResponse(37, "Internal database error. Please contact Limble for assistance.", res);
- }
- else {
- switch (data[0].fieldTypeID) {
- case 1:
- //Text
- break;
- case 2:
- //Date
- sendFailResponse(43, "That fieldType is not currently supported in this call.", res);
- break;
- case 3:
- //Picture
- sendFailResponse(43, "That fieldType is not currently supported in this call.", res);
- break;
- case 4:
- //Document
- sendFailResponse(43, "That fieldType is not currently supported in this call.", res);
- break;
- case 5:
- //Number
- if(!parseInt(value)) {
- sendFailResponse(43, "That field requires a numerical value.", res);
- }
- break;
- case 6:
- //Currency
- sendFailResponse(43, "That fieldType is not currently supported in this call.", res);
- break;
- default:
- sendFailResponse(44, "An unexpected error occured. Please contact Limble for assistance", res);
- }
- }
- });
- //Execution
- const bridge = new PHPBridge();
- try {
- await bridge.updateAssetField(
- customerID,
- fieldID,
- value
- );
- return sendSuccessResponse(res);
- } catch(err) {
- // TODO proper err message
- return sendFailResponse(3, err.message, res);
- }
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement