Skip to content

Commit

Permalink
updated readme and and samples
Browse files Browse the repository at this point in the history
  • Loading branch information
chrismatthieu committed Dec 22, 2011
1 parent 9583b2f commit 68f50cc
Show file tree
Hide file tree
Showing 18 changed files with 61 additions and 61 deletions.
18 changes: 9 additions & 9 deletions README.md
Expand Up @@ -11,7 +11,7 @@ To get started you will first need to have Node.js installed. Howtonode has a go

If you have Node.js installed, and are using the Node Package Manager (npm), just do:

~$ npm install tropo-webapi
~$ npm install tropo-webapi -g

If you install with npm, then you can reference the tropo Node library in your node.js scripts like this:

Expand All @@ -30,10 +30,10 @@ If you do not have npm installed, then you will then want to create a directory
|-vendor
</pre>

Next copy the tropo-webapi-node/lib/tropo-webapi.js & tropo-webapi-node/lib/base.js in the project/lib directory. Then you may create a server.js file in the project directory that requires the Tropo WebAPI Node library as follows:
Add this declaration to your server.js starting file

<pre>
require('../lib/tropo-webapi');
var tropowebapi = require('tropo-webapi');
</pre>

Running
Expand All @@ -52,14 +52,14 @@ Generate a JSON Doc
-------------------

<pre>
require('tropo-webapi');
var tropowebapi = require('tropo-webapi');
var sys = require('sys');

var tropo = new TropoWebAPI();
var tropo = new tropowebapi.TropoWebAPI();

tropo.say("Hello, World.");

sys.puts(TropoJSON(tropo));
sys.puts(tropowebapi.TropoJSON(tropo));
</pre>

Respond to a Tropo WebAPI Session
Expand All @@ -72,17 +72,17 @@ Respond to a Tropo WebAPI Session
*/

var http = require('http');
require('tropo-webapi');
var tropowebapi = require('tropo-webapi');

var server = http.createServer(function (request, response) {

// Create a new instance of the TropoWebAPI object.
var tropo = new TropoWebAPI();
var tropo = new tropowebapi.TropoWebAPI();
tropo.say("Hello, World!");

// Render out the JSON for Tropo to consume.
response.writeHead(200, {'Content-Type': 'application/json'});
response.end(TropoJSON(tropo));
response.end(tropowebapi.TropoJSON(tropo));

}).listen(8000); // Listen on port 8000 for requests.
</pre>
Expand Down
6 changes: 3 additions & 3 deletions samples/express/hello-world.js
Expand Up @@ -3,18 +3,18 @@
* Express must be installed for this sample to work
*/

require('../../lib/tropo-webapi');
var tropowebapi = require('tropo-webapi');
var express = require('express');

var app = express.createServer();

app.post('/', function(req, res){
// Create a new instance of the TropoWebAPI object.
var tropo = new TropoWebAPI();
var tropo = new tropowebapi.TropoWebAPI();
// Use the say method https://www.tropo.com/docs/webapi/say.htm
tropo.say("Hello World!");

res.send(TropoJSON(tropo));
res.send(tropowebapi.TropoJSON(tropo));
});


Expand Down
14 changes: 7 additions & 7 deletions samples/express/resource-routing.js
Expand Up @@ -3,37 +3,37 @@
* Express must be installed for this sample to work
*/

require('../../lib/tropo-webapi');
var tropowebapi = require('tropo-webapi');
var express = require('express');
var app = express.createServer();

app.post('/', function(req, res){
// Create a new instance of the TropoWebAPI object.
var tropo = new TropoWebAPI();
var tropo = new tropowebapi.TropoWebAPI();
// Use the say method https://www.tropo.com/docs/webapi/say.htm
tropo.say("Welcome to my Tropo Web API node demo.");
// Use the on method https://www.tropo.com/docs/webapi/on.htm
tropo.on("continue", null, "/one", true);

res.send(TropoJSON(tropo));
res.send(tropowebapi.TropoJSON(tropo));
});

app.post('/one', function(req, res){
// Create a new instance of the TropoWebAPI object.
var tropo = new TropoWebAPI();
var tropo = new tropowebapi.TropoWebAPI();
tropo.say("Hello from resource one!");
tropo.on("continue", null, "/two", true);

res.send(TropoJSON(tropo));
res.send(tropowebapi.TropoJSON(tropo));
});

app.post('/two', function(req, res){
// Create a new instance of the TropoWebAPI object.
var tropo = new TropoWebAPI();
var tropo = new tropowebapi.TropoWebAPI();
tropo.say("Hello from resource two!");
tropo.say("Well, enough of that. Goodbye.");

res.send(TropoJSON(tropo));
res.send(tropowebapi.TropoJSON(tropo));
});

app.listen(8000);
Expand Down
10 changes: 5 additions & 5 deletions samples/express/say-ask.js
Expand Up @@ -3,7 +3,7 @@
* Express must be installed for this sample to work
*/

require('../../lib/tropo-webapi');
var tropowebapi = require('tropo-webapi');
var express = require('express');
var app = express.createServer();

Expand All @@ -17,7 +17,7 @@ app.configure(function(){

app.post('/', function(req, res){
// Create a new instance of the TropoWebAPI object.
var tropo = new TropoWebAPI();
var tropo = new tropowebapi.TropoWebAPI();
// Use the say method https://www.tropo.com/docs/webapi/say.htm
tropo.say("Welcome to my Tropo Web API node demo.");

Expand All @@ -31,15 +31,15 @@ app.post('/', function(req, res){
// use the on method https://www.tropo.com/docs/webapi/on.htm
tropo.on("continue", null, "/answer", true);

res.send(TropoJSON(tropo));
res.send(tropowebapi.TropoJSON(tropo));
});

app.post('/answer', function(req, res){
// Create a new instance of the TropoWebAPI object.
var tropo = new TropoWebAPI();
var tropo = new tropowebapi.TropoWebAPI();
tropo.say("Your zip code is " + req.body['result']['actions']['interpretation']);

res.send(TropoJSON(tropo));
res.send(tropowebapi.TropoJSON(tropo));
});

app.listen(8000);
Expand Down
6 changes: 3 additions & 3 deletions samples/express/use-session.js
Expand Up @@ -3,7 +3,7 @@
* Express must be installed for this sample to work
*/

require('../../lib/tropo-webapi');
var tropowebapi = require('tropo-webapi');
var express = require('express');
var app = express.createServer();

Expand All @@ -19,12 +19,12 @@ app.post('/', function(req, res){
console.log(req.body)

// Create a new instance of the TropoWebAPI object.
var tropo = new TropoWebAPI();
var tropo = new tropowebapi.TropoWebAPI();
// Use the say method https://www.tropo.com/docs/webapi/say.htm
tropo.say("You are a " + req.body['session']['userType']);
tropo.say("Did you not know that already? Goodbye.")

res.send(TropoJSON(tropo));
res.send(tropowebapi.TropoJSON(tropo));
});


Expand Down
6 changes: 3 additions & 3 deletions samples/hello-world-http.js
Expand Up @@ -4,16 +4,16 @@
*/

var http = require('http');
require('../lib/tropo-webapi');
var tropowebapi = require('tropo-webapi');

var server = http.createServer(function (request, response) {

// Create a new instance of the TropoWebAPI object.
var tropo = new TropoWebAPI();
var tropo = new tropowebapi.TropoWebAPI();
tropo.say("Hello, World!");

// Render out the JSON for Tropo to consume.
response.writeHead(200, {'Content-Type': 'application/json'});
response.end(TropoJSON(tropo));
response.end(tropowebapi.TropoJSON(tropo));

}).listen(8000); // Listen on port 8000 for requests.
6 changes: 3 additions & 3 deletions samples/hello-world-nohttp.js
Expand Up @@ -4,15 +4,15 @@
* ~$ node path/to/tropo-webapi-node/samples/sample-1.js
*/

require('../lib/tropo-webapi');
var tropowebapi = require('tropo-webapi');
var sys = require('sys');

// Create a new instance of the TropoWebAPI object.
var tropo = new TropoWebAPI();
var tropo = new tropowebapi.TropoWebAPI();

// Say something and then hangup. (Note, null values are excluded from rendered JSON.)
tropo.say("Hello, World.", null, null, true, "carmen");
tropo.hangup();

// Write out the rendered JSON.
sys.puts(TropoJSON(tropo));
sys.puts(tropowebapi.TropoJSON(tropo));
4 changes: 2 additions & 2 deletions samples/provisioning/add-address.js
Expand Up @@ -5,14 +5,14 @@
*
*/

require('../../lib/tropo-provisioning');
var tropowebapi = require('tropo-webapi');
var sys = require('sys');

var userid = '';
var password = '';
var applicationID = '';

var p = new TropoProvision(userid, password);
var p = new tropowebapi.TropoProvision(userid, password);

p.updateApplicationAddress(applicationID, 'aim', null, null, null, null, null, 'AIMUser01', 'password', null);

Expand Down
4 changes: 2 additions & 2 deletions samples/provisioning/add-number.js
Expand Up @@ -6,14 +6,14 @@
*
*/

require('../../lib/tropo-provisioning');
var tropowebapi = require('tropo-webapi');
var sys = require('sys');

var userid = '';
var password = '';
var applicationID = '';

var p = new TropoProvision(userid, password);
var p = new tropowebapi.TropoProvision(userid, password);

p.updateApplicationAddress(applicationID, 'number', '1407', null, null, null, null, null, null, null);

Expand Down
4 changes: 2 additions & 2 deletions samples/provisioning/add-token.js
Expand Up @@ -5,14 +5,14 @@
*
*/

require('../../lib/tropo-provisioning');
var tropowebapi = require('tropo-webapi');
var sys = require('sys');

var userid = '';
var password = '';
var applicationID = '';

var p = new TropoProvision(userid, password);
var p = new tropowebapi.TropoProvision(userid, password);

p.updateApplicationAddress(applicationID, 'token', null, null, null, null, 'messaging', null, null, null);

Expand Down
4 changes: 2 additions & 2 deletions samples/provisioning/create-app.js
Expand Up @@ -7,7 +7,7 @@
*
*/

require('../../lib/tropo-provisioning');
var tropowebapi = require('tropo-webapi');
var sys = require('sys');

var userid = '';
Expand All @@ -18,7 +18,7 @@ var messagingURL = 'http://somefakehost.com/tropo/app.json';
var platform = 'webapi';
var partition = 'staging';

var p = new TropoProvision(userid, password);
var p = new tropowebapi.TropoProvision(userid, password);

p.createApplication(name, voiceURL, messagingURL, platform, partition);

Expand Down
4 changes: 2 additions & 2 deletions samples/provisioning/delete-address.js
Expand Up @@ -4,15 +4,15 @@
*
*/

require('../../lib/tropo-provisioning');
var tropowebapi = require('tropo-webapi');
var sys = require('sys');

var userid = '';
var password = '';
var applicationID = '';
var myNumber = '';

var p = new TropoProvision(userid, password);
var p = new tropowebapi.TropoProvision(userid, password);

p.deleteApplicationAddress(applicationID, 'number', myNumber);

Expand Down
4 changes: 2 additions & 2 deletions samples/provisioning/delete-app.js
Expand Up @@ -5,14 +5,14 @@
*
*/

require('../../lib/tropo-provisioning');
var tropowebapi = require('tropo-webapi');
var sys = require('sys');

var userid = '';
var password = '';
var applicationID = '';

var p = new TropoProvision(userid, password);
var p = new tropowebapi.TropoProvision(userid, password);

p.deleteApplication(applicationID);

Expand Down
6 changes: 3 additions & 3 deletions samples/resource-routing.js
Expand Up @@ -6,7 +6,7 @@


var http = require('http');
var tropo = require('../lib/tropo-webapi');
var tropowebapi = require('tropo-webapi');

var server = http.createServer(function (request, response) {

Expand All @@ -30,7 +30,7 @@ var server = http.createServer(function (request, response) {
request.addListener('end', function() {

// Create a new instance of the TropoWebAPI object.
var tropo = new TropoWebAPI();
var tropo = new tropowebapi.TropoWebAPI();

if(pathname == '/') {

Expand Down Expand Up @@ -61,7 +61,7 @@ var server = http.createServer(function (request, response) {

// Render out the JSON for Tropo to consume.
response.writeHead(200, {'Content-Type': 'application/json'});
response.end(TropoJSON(tropo));
response.end(tropowebapi.TropoJSON(tropo));

})
}
Expand Down
6 changes: 3 additions & 3 deletions samples/say-ask.js
Expand Up @@ -4,12 +4,12 @@
*/

var http = require('http');
require('../lib/tropo-webapi');
var tropowebapi = require('tropo-webapi');

var server = http.createServer(function (request, response) {

// Create a new instance of the TropoWebAPI object.
var tropo = new TropoWebAPI();
var tropo = new tropowebapi.TropoWebAPI();
tropo.say("Welcome to my Tropo Web API node demo.");

// Demonstrates how to use the base Tropo action classes.
Expand All @@ -22,6 +22,6 @@ var server = http.createServer(function (request, response) {

// Render out the JSON for Tropo to consume.
response.writeHead(200, {'Content-Type': 'application/json'});
response.end(TropoJSON(tropo));
response.end(tropowebapi.TropoJSON(tropo));

}).listen(8000); // Listen on port 8000 for requests.

0 comments on commit 68f50cc

Please sign in to comment.