Spurrya / Calfit

3 stars 1 forks source link

Rest API to inform reminder accept / reject #22

Closed bhaanu77 closed 7 years ago

bhaanu77 commented 8 years ago
  1. on YOUR LOCAL MACHINE Create a different API routes file similar to https://github.com/Spurrya/Calfit/blob/master/api/routes/calendar.js
  2. call it https://github.com/Spurrya/Calfit/tree/master/api/userresponse
  3. First write the test route with name "userresponse" and to make sure REST API post request is being succesfully received, log to the console the parameters req.body.email, req.body.isaccepted
  4. Create a calendar event to the user if the user has accepted invite
  5. Get a list of all users in the office 365 as done in below code
  6. loop through the users e.g. for loop and then check if the user's email is same as current user's email (req.body.email) and user has "accepted" the workout reminder (know if(req.body.isaccepted=="true") ) received in the current api request, then create calendar event for the user with title "Break taken" and status "Away". duration of break should be 15 minutes.

NOTE: below is example code from https://github.com/Spurrya/Calfit/blob/master/api/routes/calendar.js

router.route('/calendar') .post(function(req, res) { // Get an access token for the app. auth.getAccessToken().then(function (token) {

// Check if the current user from whom accept is received is the same as the
graph.getUsers(token) .then(function (users) { // Create an event on each user's calendar. graph.createEvent(token, users); }, function (error) { console.error('>>> Error getting users: ' + error); }) }, function (error) { console.error('>>> Error getting access token: ' + error); } ); });

bhaanu77 commented 8 years ago

@Spurrya if you happen to complete this today, please inform @kevinkid so that he can start working on https://github.com/Spurrya/Calfit/issues/23

Spurrya commented 8 years ago

Really late reply, but we finished this task :)

kevinkid commented 7 years ago

Am hoping to make updates on the project guys