'use strict';

// var config = require('../config');
// var twilio = require('twilio');
// var client = twilio(config.accountSid, config.authToken);
var fallbackCall = require('../lib/fallBackCall');

module.exports = function(app) {
  app.post('/StatusCallBack/:firstName/:lastName/:phoneNumber', function(req, res) {
    console.log('call status is: ' + req.body.CallStatus);
    if (req.body.CallStatus ===  'no-answer') {
      console.log('first call failed, time to try again.');
      res.type('text/xml');
      res.render('hangupMachine');
      fallbackCall.makeCall(req.params.firstName, req.params.lastName, req.params.phoneNumber);
    }
    console.log('call status is!: ' + req.body.CallStatus);
  });
};

@@ -379,47 +379,215 @@
     
-if (req.body.CallStatus ===  'no-answer
+console.log('call answered by: ' + req.body.AnsweredBy);%0A    if (req.body.CallStatus ===  'no-answer' %7C%7C req.body.CallStatus === 'busy' %7C%7C req.body.CallStatus === 'failed' %7C%7C req.body.AnsweredBy === 'machine
 ') %7B

call status wip