{"size": 1358, "ext": "js", "max_stars_repo_path": "orchestratorjs/resources/observers/ModuleTestApp/2c4671a1e4097f19ebc48d556fda892a.js", "max_stars_repo_name": "nikkis/OrchestratorJS", "max_stars_repo_stars_event_min_datetime": "2015-06-27T17:34:50.000Z", "max_stars_repo_stars_event_max_datetime": "2017-05-23T07:38:08.000Z", "max_issues_repo_path": "orchestratorjs/resources/observers/ModuleTestApp/2c4671a1e4097f19ebc48d556fda892a.js", "max_issues_repo_name": "nikkis/OrchestratorJS", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "orchestratorjs/resources/observers/ModuleTestApp/2c4671a1e4097f19ebc48d556fda892a.js", "max_forks_repo_name": "nikkis/OrchestratorJS", "max_forks_repo_forks_event_min_datetime": "2018-09-27T19:40:17.000Z", "max_forks_repo_forks_event_max_datetime": "2018-09-27T19:40:17.000Z"}
{"max_stars_count": 2, "max_issues_count": null, "max_forks_count": 1, "avg_line_length": 24.25, "max_line_length": 76, "alphanum_fraction": 0.5567010309}
var httprequest = require('../../tools.js').httprequest;
var pubsub      = require('../../tools.js').pubsub();


var TheAppModule =  module.exports = {

settings: {"coffeeMachineId":"nikkis@gadgeteer"},

logic: function () {
    
    console.log('naa naa naaaa');
    
    pubsub.on( 'online', function ( contextValue, deviceIdentity ) {
    
      if ( contextValue != true || deviceIdentity != 'nikkis@s3mini' )
        return;

      var params = {};
      params[ 'actionName' ] = 'Monolog';
      params[ 'parameters' ] = [ 'device:nikkis@s3mini', 'hellou' ];

      httprequest( {
        uri: '/api/1/actioninstance',
        method: "POST",
        form: params
      }, function( error, response, body ) {
        console.log( 'body: '+body );
      } );
  
    });
    
    pubsub.on( 'coffeeReady', function ( contextValue, deviceIdentity ) {
      if ( contextValue != true )
        return;
  
      var params = {};
      params[ 'actionName' ] = 'InviteForCoffee';
      params[ 'parameters' ] = [ settings.coffeeMachineId, deviceIdentity ];

      httprequest( {
        uri: '/api/1/actioninstance',
        method: "POST",
        form: params
      }, function( error, response, body ) {
        console.log( 'body: '+body );
      } );
  
   });
     
  }

};

var settings = {"coffeeMachineId":"nikkis@gadgeteer"};

TheAppModule.logic();