index.js
function(url,overwrite,cb) {
          if (typeof overwrite === "function") {
            cb = overwrite;
            overwrite = false;
          }
          var opts = {
            url: uri + 'device/'+device+'/callback',
            method: 'POST',
            qs: qs,
            json: { url:url }
          };
          request(opts,function(e,r,b) {
            if (!cb && !overwrite && b && b.id !== 409 ) return;
            if (e) cb(e)
            else if (b.result===1) cb(null)
            else if (b.id===409 && overwrite) {
              // A url already exists, let's update it
              var opts = {
                url: uri + 'device/'+device+'/callback',
                method: 'PUT',
                qs: qs,
                json: { url:url }
              };
              request(opts,function(e,r,b) {
                if (!cb) return;
                if (e) cb(e)
                else if (b.result===1) cb(null)
                else cb({statusCode:b.id||200,error:b.error})
              });
            }
            else {
              cb({statusCode:b.id||200,error:b.error})
            }
          });
        }
function(url,overwrite,cb) {
          if (typeof overwrite === "function") {
            cb = overwrite;
            overwrite = false;
          }
          var opts = {
            url: uri + 'device/'+device+'/callback',
            method: 'POST',
            qs: qs,
            json: { url:url }
          };
          request(opts,function(e,r,b) {
            if (!cb && !overwrite && b && b.id !== 409 ) return;
            if (e) cb(e)
            else if (b.result===1) cb(null)
            else if (b.id===409 && overwrite) {
              // A url already exists, let's update it
              var opts = {
                url: uri + 'device/'+device+'/callback',
                method: 'PUT',
                qs: qs,
                json: { url:url }
              };
              request(opts,function(e,r,b) {
                if (!cb) return;
                if (e) cb(e)
                else if (b.result===1) cb(null)
                else cb({statusCode:b.id||200,error:b.error})
              });
            }
            else {
              cb({statusCode:b.id||200,error:b.error})
            }
          });
        }
function ( url , overwrite , cb ) { if ( typeof overwrite === "function" ) { cb = overwrite ; overwrite = false ; } var opts = { url : uri + 'device/' + device + '/callback' , method : 'POST' , qs : qs , json : { url : url } } ; request ( opts , function ( e , r , b ) { if ( ! cb && ! overwrite && b && b . id !== 409 ) return ; if ( e ) cb ( e ) else if ( b . result === 1 ) cb ( null ) else if ( b . id === 409 && overwrite ) { // A url already exists, let's update it var opts = { url : uri + 'device/' + device + '/callback' , method : 'PUT' , qs : qs , json : { url : url } } ; request ( opts , function ( e , r , b ) { if ( ! cb ) return ; if ( e ) cb ( e ) else if ( b . result === 1 ) cb ( null ) else cb ( { statusCode : b . id || 200 , error : b . error } ) } ) ; } else { cb ( { statusCode : b . id || 200 , error : b . error } ) } } ) ; }
Subscribes to a device's data feed.

Optionally `overwrite`s an existing callback `url`
Default is false.

Example:
app.device(guid).subscribe('example.com',true,function(err) { ... })

@param {String} url The url that Ninja Blocks will POST data to
@param {Boolean} overwrite If a callback url exists, this flag will force an overwrite
@param {Function} cb
@api public
Subscribes to a device s data feed .