Spurrya / Calfit

3 stars 1 forks source link

API for salesforce to inform work done #13

Open bhaanu77 opened 8 years ago

bhaanu77 commented 8 years ago

create a GET or POST API in Node JS so that Salesforce can call that. 1) If GET - http://calfit.azurewebsites.net/api/taskcompleted?username=bhaanu@yofit1.onmicrosoft.com 2) POST - http://calfit.azurewebsites.net/api/taskcompleted Body parameter is: username=bhaanu@yofit1.onmicrosoft.com

Note: Currently Salesforce is making this GET request http://calfit.azurewebsites.net/api/users?taskcompleted=supportcase&username=bhaanu&name=BhaanuMadhineni . it has to be modified as soon as the above REST API (Get or Post) is ready.

@Spurrya Kevin seems to be busy preparing for his exam. The earliest he will be available is Monday evening, which means he can work only on Tuesday. Since you will be much faster, could you make the above API change. The earlier we finish this and get the chrom notification working on anyone's laptop, the video work by Eva can start.

bhaanu77 commented 8 years ago

Note: All below text can be ignored if anyone else than Kevin is working on this.

@kevinkid please don't update any code in calfit nodejs instance directly.

@kevinkid you might as well modify the users get function with following psuedo code router.get('/users/', function(req, res) { if (req.anchor=="taskcompleted") {

//get username parameter from get request ?username=bhaanu@yofit1.onmicrosoft.com

// if the variable is not empty then do the following steps; also write value of this to console (console.log("value of anchor="+anchor);): var anchor = url.parse(request.url).query; // //check if right time to remind that specfic userby calling the function "canUserTakeBreak" in "Calfit/api/routes/calendar.js" already written by Spurrya //call send notification function

} User.find(function(err, users) { res.json({users: users}); }); });

I think you should use following code to get calendar data for users and then send push notification to the calendar

// Get calendar events for users graph.getEvents(token, users, res).then(function(data){

          Activity.find(function(err, activity) {

            //The number of entries for the collection will always remain 6.
            //Therefore, it is safe to get all the entries. However, this is
            //not recommended once we go above 30+ entries
            var activities = activity;

            if(canUserTakeBreak(data)==true){
             console.log("user can take break. Notification pushed to chrome extension"); 
             graph.pushNotification(activities[Math.floor(Math.random() * activities.length)])
            }
            else {
              console.log("user can not take break");
            }
          });

        })
bhaanu77 commented 8 years ago

@Spurrya I guess you are working on this today? Sorry if I am repeating myself. I just wanted to avoid misunderstandings, as it common when working remotely in different timezones.