index.js
function logon() {
    var dfrd = Q.defer();
    var token = cache.get('token');

    function extractToken(xml) {
      var r = _parse(xml, dfrd);
      if (r) {
        return r.response.token[0];
      }
    }

    if (token) {
      dfrd.resolve({
        token: token,
        cached: true
      });
    }

    request(format(URLs.logon, PROTOCOL, conf.host, conf.username,
        conf.password),
      function(err, res, body) {
        var newToken;
        if (err) {
          dfrd.reject(err);
        } else {
          newToken = extractToken(body);
          if (!newToken) {
            dfrd.reject(MODULE_ERRORS.unknown);
          } else {
            cache.put('token', newToken);
            dfrd.resolve({
              token: newToken,
              cached: false
            });
          }
        }
      });
    return dfrd.promise;
  }
function logon() {
    var dfrd = Q.defer();
    var token = cache.get('token');

    function extractToken(xml) {
      var r = _parse(xml, dfrd);
      if (r) {
        return r.response.token[0];
      }
    }

    if (token) {
      dfrd.resolve({
        token: token,
        cached: true
      });
    }

    request(format(URLs.logon, PROTOCOL, conf.host, conf.username,
        conf.password),
      function(err, res, body) {
        var newToken;
        if (err) {
          dfrd.reject(err);
        } else {
          newToken = extractToken(body);
          if (!newToken) {
            dfrd.reject(MODULE_ERRORS.unknown);
          } else {
            cache.put('token', newToken);
            dfrd.resolve({
              token: newToken,
              cached: false
            });
          }
        }
      });
    return dfrd.promise;
  }
function logon ( ) { var dfrd = Q . defer ( ) ; var token = cache . get ( 'token' ) ; function extractToken ( xml ) { var r = _parse ( xml , dfrd ) ; if ( r ) { return r . response . token [ 0 ] ; } } if ( token ) { dfrd . resolve ( { token : token , cached : true } ) ; } request ( format ( URLs . logon , PROTOCOL , conf . host , conf . username , conf . password ) , function ( err , res , body ) { var newToken ; if ( err ) { dfrd . reject ( err ) ; } else { newToken = extractToken ( body ) ; if ( ! newToken ) { dfrd . reject ( MODULE_ERRORS . unknown ) ; } else { cache . put ( 'token' , newToken ) ; dfrd . resolve ( { token : newToken , cached : false } ) ; } } } ) ; return dfrd . promise ; }
Logs you into FogBugz based on contents of `fogbugz.conf.json`.
@method logon
@returns {Function|promise|Q.promise} Promise
Logs you into FogBugz based on contents of fogbugz . conf . json .