cylon/examples/salesforce/salesforce.js

46 lines
1.0 KiB
JavaScript
Raw Normal View History

2014-12-14 08:19:25 +08:00
"use strict";
var Cylon = require("../..");
Cylon.robot({
2014-11-26 08:01:31 +08:00
connections: {
sfcon: {
2014-12-14 08:19:25 +08:00
adaptor: "force",
2014-11-26 08:01:31 +08:00
sfuser: process.env.SF_USERNAME,
sfpass: process.env.SF_SECURITY_TOKEN,
orgCreds: {
clientId: process.env.SF_CLIENT_ID,
clientSecret: process.env.SF_CLIENT_SECRET,
2014-12-14 08:19:25 +08:00
redirectUri: "http://localhost:3000/oauth/_callback"
2014-11-26 08:01:31 +08:00
}
}
},
2014-11-26 08:01:31 +08:00
devices: {
2014-12-14 08:19:25 +08:00
salesforce: { driver: "force" }
2014-11-26 08:01:31 +08:00
},
2014-11-26 06:39:24 +08:00
work: function(my) {
2014-12-14 08:19:25 +08:00
my.salesforce.on("start", function() {
my.salesforce.subscribe("/topic/SpheroMsgOutbound", function(data) {
var msg = "Sphero: " + data.sobject.Sphero_Name__c + ",";
msg += "Bucks: " + data.sobject.Bucks__c + ",";
msg += "SM_Id: " + data.sobject.Id;
console.log(msg);
});
});
var i = 0;
every((2).seconds(), function() {
var data = JSON.stringify({
2014-12-14 08:19:25 +08:00
spheroName: "" + my.name,
bucks: "" + i
});
2014-12-14 08:19:25 +08:00
my.salesforce.push("SpheroController", "POST", data);
});
}
}).start();