diff --git a/seasoned_api/src/plex/requestRepository.js b/seasoned_api/src/plex/requestRepository.js index 8aef0ca..e72dc72 100644 --- a/seasoned_api/src/plex/requestRepository.js +++ b/seasoned_api/src/plex/requestRepository.js @@ -67,13 +67,16 @@ class RequestRepository { }); } - sendRequest(identifier) { + /** + * Send request for given media id. + * @param {identifier, type} the id of the media object and type of media must be defined + * @returns {Promise} If nothing has gone wrong. + */ + sendRequest(identifier, type) { // TODO add to DB so can have a admin page // TODO try a cache hit on the movie item - tmdb.lookup(identifier).then(movie => { - console.log(movie.title) - + tmdb.lookup(identifier, type).then(movie => { // create reusable transporter object using the default SMTP transport let transporter = nodemailer.createTransport({ @@ -110,6 +113,7 @@ class RequestRepository { }) + // TODO add better response when done. return Promise.resolve(); } diff --git a/seasoned_api/src/webserver/controllers/plex/submitRequest.js b/seasoned_api/src/webserver/controllers/plex/submitRequest.js index 80e1355..fd6345f 100644 --- a/seasoned_api/src/webserver/controllers/plex/submitRequest.js +++ b/seasoned_api/src/webserver/controllers/plex/submitRequest.js @@ -11,8 +11,9 @@ const requestRepository = new RequestRepository(); function submitRequestController(req, res) { // This is the id that is the param of the url const id = req.params.mediaId; + const type = req.query.type; - requestRepository.sendRequest(id) + requestRepository.sendRequest(id, type) .then(() => { res.send({ success: true, message: 'Media item sucessfully requested!' }); })