From 61c242b5eb6074669bb34911889cf8e8ec7a9ff1 Mon Sep 17 00:00:00 2001 From: KevinMidboe Date: Fri, 6 Oct 2017 15:03:47 +0200 Subject: [PATCH] Passes the id from request parameter and status we want to change to from the request body. --- .../controllers/plex/updateRequested.js | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 seasoned_api/src/webserver/controllers/plex/updateRequested.js diff --git a/seasoned_api/src/webserver/controllers/plex/updateRequested.js b/seasoned_api/src/webserver/controllers/plex/updateRequested.js new file mode 100644 index 0000000..4573501 --- /dev/null +++ b/seasoned_api/src/webserver/controllers/plex/updateRequested.js @@ -0,0 +1,23 @@ +const RequestRepository = require('src/searchHistory/searchHistory'); +const requestRepository = new RequestRepository(); + +/** + * Controller: Retrieves search history of a logged in user + * @param {Request} req http request variable + * @param {Response} res + * @returns {Callback} + */ +function updateRequested(req, res) { + const id = req.params.requestId; + const status = req.body.status; + + requestRepository.updateRequested(id, status) + .then(() => { + res.send({ success: true }); + }) + .catch((error) => { + res.status(401).send({ success: false, error: error.message }); + }); +} + +module.exports = updateRequested;